:root {
  --ink: #0f1c2e;
  --ink-soft: rgba(15, 28, 46, 0.72);
  --paper: rgba(255, 255, 255, 0.78);
  --paper-strong: rgba(255, 255, 255, 0.92);
  --line: rgba(15, 28, 46, 0.14);
  --accent: #1c4d8c;
  --ok: #1f6b45;
  --err: #9b2c2c;
  --shadow: 0 18px 50px rgba(12, 28, 48, 0.18);
  --font-display: "Fraunces", "Times New Roman", serif;
  --font-body: "Sora", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font-body);
  background: #7eb6e0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.scene-photo {
  position: absolute;
  inset: 0;
  background: url("/static/bg.jpg") left center / cover no-repeat;
  transform: scale(1.04);
  animation: drift 28s ease-in-out infinite alternate;
}

.scene-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0%, transparent 42%, rgba(126, 182, 224, 0.18) 62%, rgba(190, 220, 240, 0.55) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 28%, rgba(15, 40, 70, 0.18) 100%);
}

@keyframes drift {
  from { transform: scale(1.04) translate3d(0, 0, 0); }
  to { transform: scale(1.08) translate3d(-1.2%, 0.6%, 0); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.top,
.stage,
.browse-layout,
.content,
.banner {
  position: relative;
  z-index: 1;
}

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1rem, 3vw, 1.75rem) clamp(1rem, 4vw, 2.5rem);
}

.top-app {
  align-items: center;
  flex-wrap: wrap;
  background: rgba(15, 40, 70, 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
}

.top-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 0.9;
  color: #fff;
  text-shadow: 0 2px 24px rgba(10, 30, 60, 0.35);
  text-decoration: none;
  animation: rise 0.7s ease-out both;
}

a.brand:hover { text-decoration: none; color: #fff; }

.who {
  margin: 0;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.92rem;
  font-weight: 500;
  text-shadow: 0 1px 12px rgba(10, 30, 60, 0.35);
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.top-nav > a {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 500;
  text-shadow: 0 1px 10px rgba(10, 30, 60, 0.3);
}

.top-nav > a:hover { color: #fff; }

.draft-pill {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent);
  box-shadow: 0 4px 16px rgba(10, 30, 60, 0.15);
}

.stage {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: calc(100dvh - 6rem);
  padding: 0 clamp(1rem, 4vw, 2.5rem) clamp(1.5rem, 4vw, 3rem);
}

.panel,
.panel-glass {
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: var(--paper);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  box-shadow: var(--shadow);
}

.panel {
  width: min(420px, 100%);
  padding: clamp(1.25rem, 3vw, 1.75rem);
  animation: rise 0.75s ease-out 0.12s both;
}

.auth-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

h1 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 4vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.lead {
  margin: 0 0 1rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.45;
}

.lead.tight { margin-bottom: 0; }

.eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.88rem;
  font-weight: 500;
}

input[type="text"],
input[type="password"] {
  font: inherit;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper-strong);
  color: var(--ink);
  padding: 0.65rem 1.1rem;
  font: 500 0.92rem/1 var(--font-body);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn.primary {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.32);
  border-color: #fff;
}

.btn.small {
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
}

.actions { margin-top: 0.4rem; }
.actions .btn.primary { width: 100%; }

.inline { display: inline; margin: 0; }
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.status {
  margin: 0;
  min-height: 1.25em;
  color: var(--ink-soft);
  font-size: 0.88rem;
}
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

.muted { color: var(--ink-soft); font-size: 0.92rem; }

.banner {
  margin: 0;
  padding: 0.75rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(255, 255, 255, 0.85);
}
.banner.err { color: var(--err); }

/* App layout */
.browse-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 1.75rem) 2rem;
  min-height: calc(100dvh - 5.5rem);
}

.tree-panel,
.grid-panel {
  padding: 1rem 1.1rem;
  overflow: auto;
}

.tree-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
  font-weight: 600;
}

.tree, .tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree details { margin-bottom: 0.35rem; }
.tree summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.35rem 0.2rem;
  font-size: 0.92rem;
}

.tree ul { padding-left: 0.35rem; margin-top: 0.15rem; }

.tree a {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.86rem;
  border: 1px solid transparent;
}

.tree a:hover { background: rgba(28, 77, 140, 0.08); }
.tree a.active {
  background: rgba(28, 77, 140, 0.12);
  border-color: rgba(28, 77, 140, 0.2);
  font-weight: 600;
}

.tree .ev-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree .count {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.grid-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.save-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.save-form input { min-width: 200px; }
.save-form .btn.primary { width: auto; }

.toolbar-actions {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.7rem;
}

.photo-card {
  position: relative;
  display: block;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.7);
  cursor: default;
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.photo-card:hover { transform: translateY(-1px); }
.photo-card.is-selected { border-color: var(--accent); }

.photo-card input {
  position: absolute;
  top: 0.45rem;
  left: 0.45rem;
  z-index: 2;
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
}

.photo-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: rgba(15, 28, 46, 0.06);
  pointer-events: none;
}

.photo-name {
  display: block;
  padding: 0.4rem 0.5rem;
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink-soft);
}

.preview-dialog {
  border: 0;
  padding: 0;
  width: min(1100px, 96vw);
  max-width: 96vw;
  max-height: 96vh;
  background: rgba(10, 24, 40, 0.92);
  color: #fff;
  box-shadow: var(--shadow);
}

.preview-dialog::backdrop {
  background: rgba(8, 20, 36, 0.72);
}

.preview-shell {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem 1rem 1rem;
  max-height: 96vh;
}

.preview-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.preview-meta {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(60vw, 640px);
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.preview-actions .btn.ghost {
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.preview-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  background: rgba(0, 0, 0, 0.25);
}

.preview-stage img {
  max-width: 100%;
  max-height: min(78vh, 900px);
  object-fit: contain;
}

.preview-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.preview-nav:hover { background: rgba(255, 255, 255, 0.22); }
.preview-nav:disabled { opacity: 0.3; cursor: default; }
.preview-nav.prev { left: 0.6rem; }
.preview-nav.next { right: 0.6rem; }

.preview-hint {
  margin: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.65);
}

.content {
  padding: 1.25rem clamp(1rem, 4vw, 2.5rem) 2.5rem;
}

.list-panel {
  padding: clamp(1.25rem, 3vw, 1.75rem);
  animation: rise 0.6s ease-out both;
}

.list-panel h1 { margin-bottom: 1rem; }

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: 0.9rem;
}

.data-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-weight: 600;
}

.data-table tr:last-child td { border-bottom: 0; }
.data-table tr.is-disabled { opacity: 0.55; }

.zip-cell,
.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.zip-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 1.25rem 0;
}

.zip-actions .btn.primary { width: auto; }

.access-link-box {
  margin-bottom: 1.25rem;
  padding: 1rem;
  border: 1px solid rgba(28, 77, 140, 0.25);
  background: rgba(28, 77, 140, 0.08);
}

.access-link-box h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-family: var(--font-display);
  font-weight: 500;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.link-row input {
  flex: 1 1 220px;
  font-size: 0.82rem;
}

.admin-create {
  margin-bottom: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
}

.admin-create h2 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-family: var(--font-display);
  font-weight: 500;
}

.reset-pw input { width: 140px; }

/* Triage + tags */
.triage-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 1.75rem) 2rem;
  min-height: calc(100dvh - 5.5rem);
  position: relative;
  z-index: 1;
}

.triage-side,
.triage-stage {
  padding: 1rem 1.1rem;
}

.triage-side h2 {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
  font-weight: 600;
}

.triage-side h2.spaced { margin-top: 1.25rem; }

.dest-fields {
  display: grid;
  gap: 0.65rem;
}

.dest-fields label,
.credit-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.dest-fields select {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
}

.create-fold {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.create-fold-open .create-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.create-fold-open .create-row input {
  flex: 1;
  min-width: 0;
}

#create-status {
  min-height: 1.1em;
  margin: 0.45rem 0 0;
}

.create-fold summary { cursor: pointer; font-weight: 500; }
.inline-form.tight { margin-top: 0.5rem; }

.tag-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin: 0.5rem 0 0.75rem;
}

.tag-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  padding: 0.45rem 0.55rem;
  font: 500 0.82rem/1.1 var(--font-body);
  cursor: pointer;
  text-align: left;
}

.tag-btn.on {
  border-color: var(--accent);
  background: rgba(28, 77, 140, 0.14);
  color: var(--accent);
}

.tag-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  border-radius: 4px;
  background: rgba(15, 28, 46, 0.08);
  font-size: 0.72rem;
  font-weight: 700;
}

.tag-btn.on .tag-key {
  background: var(--accent);
  color: #fff;
}

.triage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.triage-actions .btn.primary { width: auto; }

.triage-preview {
  margin-top: 0.75rem;
  background: rgba(15, 28, 46, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
}

.triage-preview img {
  max-width: 100%;
  max-height: min(72vh, 900px);
  object-fit: contain;
}

.triage-empty { padding: 2rem 1rem; }

.tiny { font-size: 0.78rem; }

.photo-card .retag-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  z-index: 3;
  border: 0;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font: 600 0.68rem/1 var(--font-body);
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(10, 30, 60, 0.18);
}

.photo-card .retag-btn:hover {
  background: var(--accent);
  color: #fff;
}

.move-create {
  margin-top: 0.5rem;
}

#move-status.err {
  color: #a12b2b;
}

.preview-tags-line {
  margin: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
}

.tag-badge {
  position: absolute;
  bottom: 1.7rem;
  left: 0.4rem;
  z-index: 2;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
}

.photo-card.is-tagged { box-shadow: inset 0 0 0 1px rgba(28, 77, 140, 0.35); }

.retag-dialog {
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: var(--paper-strong);
  backdrop-filter: blur(14px);
  padding: 0;
  max-width: min(420px, 94vw);
  box-shadow: var(--shadow);
}

.retag-dialog::backdrop {
  background: rgba(15, 40, 70, 0.35);
}

.retag-panel {
  padding: 1.25rem;
  margin: 0;
}

.retag-panel h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
}

.nav-active { font-weight: 700; text-decoration: underline; }

@media (max-width: 860px) {
  .browse-layout { grid-template-columns: 1fr; }
  .triage-layout { grid-template-columns: 1fr; }
  .tree-panel { max-height: 220px; }
  .scene-photo { background-position: 18% center; }
  .scene-veil {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, transparent 35%, rgba(15, 40, 70, 0.45) 100%);
  }
  .stage {
    align-items: flex-end;
    justify-content: center;
  }
  .panel { width: min(520px, 100%); background: rgba(255, 255, 255, 0.88); }
}

@media (max-width: 520px) {
  .brand { font-size: 2.1rem; }
  .who {
    max-width: 40%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scene-photo,
  .brand,
  .panel,
  .list-panel {
    animation: none;
  }
  .scene-photo { transform: none; }
}
