:root {
  --bg: #111;
  --panel: rgba(24, 24, 24, 0.94);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #eee;
  --muted: #ccc;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

body.auth-page {
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 24px;
}

header {
  padding: 8px 12px 10px;
  background: #222;
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--panel-border);
}

h2 {
  margin: 0;
  font-size: 1.15rem;
}

.meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.3;
}

.source-meta {
  color: #8ab4f8;
}

.logout-form {
  margin-top: 8px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.header-actions .logout-form {
  margin-top: 0;
}

.header-actions .source-reset {
  padding: 0;
}

.flash:empty,
.error:empty {
  display: none;
}

.flash {
  color: #8bd17c;
}

.error {
  color: #ff9a8a;
}

.manual-source {
  margin-top: 8px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(15, 15, 15, 0.9);
}

.manual-source summary {
  cursor: pointer;
  padding: 8px 10px;
  font-weight: 600;
}

.source-form {
  display: grid;
  grid-template-columns: minmax(110px, auto) 1fr;
  gap: 6px;
  align-items: center;
  padding: 0 10px 10px;
}

.source-reset {
  padding: 0 10px 10px;
}

.source-form input {
  min-width: 0;
  width: 100%;
  padding: 7px 9px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #0f0f0f;
  color: #eee;
}

#main {
  position: relative;
  min-height: 0;
  padding-bottom: 0;
}

.viewer {
  position: relative;
  overflow: hidden;
  background: #050505;
  cursor: grab;
  width: 100%;
  min-height: 220px;
}

.stage {
  position: absolute;
  transform-origin: 0 0;
}

#img {
  display: block;
  user-select: none;
  pointer-events: none;
}

#overlay {
  position: absolute;
  left: 0;
  top: 0;
}

.sticky-actions {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 80;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 6px;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
  -webkit-overflow-scrolling: touch;
}

button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  font-size: 14px;
  line-height: 1.15;
  padding: 9px 10px;
  cursor: pointer;
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  min-width: 0;
  white-space: nowrap;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.approve { background: #1b8f3a; color: white; }
.reject { background: #b3261e; color: white; }
.discard { background: #6b2f2f; color: white; }
.edit { background: #1f6feb; color: white; }
.refresh { background: #2f6f9f; color: white; }
.previous { background: #d29922; color: #111; }

.btn-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 11px;
  font-weight: 700;
}

.empty {
  padding: 22px 16px 96px;
}

.hidden {
  display: none;
}

.auth-card {
  width: min(420px, 100%);
  padding: 20px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.auth-form input {
  min-width: 0;
  width: 100%;
  padding: 9px 10px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #0f0f0f;
  color: #eee;
}

.compact-dialog {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: #161b22;
  color: #f3f4f6;
  padding: 14px;
  width: min(92vw, 320px);
}

.compact-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.compact-dialog form {
  display: grid;
  gap: 10px;
}

.compact-dialog h3 {
  margin: 0;
  font-size: 18px;
}

.compact-dialog select {
  min-height: 40px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 960px) {
  header {
    padding-left: 10px;
    padding-right: 10px;
  }
}

@media (max-width: 720px) {
  .source-form {
    grid-template-columns: 1fr;
  }

  .sticky-actions {
    gap: 5px;
    padding: 7px;
  }

  button {
    padding: 8px 9px;
    font-size: 13px;
  }
}
