:root {
  color-scheme: light;
  --bg: #f6f4ee;
  --paper: #fffefa;
  --surface: #ffffff;
  --surface-soft: #f3f6f9;
  --ink: #141923;
  --muted: #647084;
  --quiet: #8792a4;
  --line: #e1ddd3;
  --line-strong: #cdd6e3;
  --primary: #1f3147;
  --primary-hover: #18273a;
  --accent: #276ef1;
  --accent-soft: #eaf2ff;
  --gold: #d7ae5f;
  --danger: #b3454f;
  --danger-soft: #fff0f1;
  --ok: #23765e;
  --action-danger: #e0202d;
  --action-ok: #16a34a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 22px;
  padding: 24px 32px 36px;
}

.brand-panel {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.stage-switch {
  display: inline-flex;
  width: max-content;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .58);
}

.stage-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
}

.stage-link.active {
  color: #fff;
  background: var(--primary);
}

.mode-note {
  max-width: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

h1 {
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.stats {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

dd {
  margin: 0;
  font-size: 17px;
  font-weight: 850;
}

.workspace {
  display: grid;
  grid-template-rows: minmax(118px, 18vh) auto auto;
  gap: 18px;
  min-width: 0;
  max-width: 1800px;
  width: 100%;
  margin: 0 auto;
}

body.has-images .workspace {
  grid-template-rows: 96px auto auto;
}

body.has-images .drop-zone {
  min-height: 96px;
  grid-template-columns: auto auto auto minmax(180px, 300px);
  justify-content: center;
  align-content: center;
  text-align: left;
}

body.has-images .drop-zone small {
  display: none;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  min-height: 118px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .94), rgba(255, 254, 250, .92)),
    var(--paper);
  text-align: center;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.drop-zone.dragging,
.drop-zone:hover {
  border-color: var(--accent);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(234, 242, 255, .96)),
    var(--accent-soft);
  box-shadow: 0 18px 46px rgba(43, 61, 89, .08);
}

.drop-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid #dfd7c8;
  border-radius: 50%;
  background: #fff;
}

.upload-icon span {
  position: relative;
  width: 20px;
  height: 20px;
}

.upload-icon span::before,
.upload-icon span::after {
  content: "";
  position: absolute;
  border-radius: 99px;
  background: var(--primary);
}

.upload-icon span::before {
  left: 0;
  top: 8px;
  width: 20px;
  height: 4px;
}

.upload-icon span::after {
  left: 8px;
  top: 0;
  width: 4px;
  height: 20px;
}

.drop-zone strong {
  font-size: 20px;
  line-height: 1.05;
}

.drop-zone small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.upload-progress {
  display: grid;
  gap: 8px;
  width: min(300px, calc(100% - 44px));
  margin-top: 2px;
}

.upload-progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: #ebe4d8;
}

.upload-progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width .18s ease;
}

.upload-progress-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(660px, 1fr) minmax(320px, 360px);
  gap: 18px;
  align-items: start;
  min-height: 0;
}

.thumb-pane,
.editor-pane {
  min-width: 0;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
}

.thumb-pane {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.editor-pane {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 62px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.pane-head h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.pane-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.toolbar,
.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.ghost-button,
.primary-button,
.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 850;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease, opacity .16s ease;
}

.icon-button {
  width: 42px;
  padding: 0;
  color: var(--primary);
  background: var(--surface);
  border-color: var(--line);
}

.mode-button {
  width: auto;
  min-width: 42px;
  padding: 0 14px;
  white-space: nowrap;
}

.compact-button {
  min-width: auto;
  min-height: 42px;
  padding: 0 14px;
  white-space: nowrap;
}

.pane-head .mode-button span {
  color: inherit;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.icon-button:disabled {
  cursor: not-allowed;
}

.ghost-button:disabled {
  cursor: not-allowed;
  opacity: .42;
}

.thumb-help {
  min-height: 38px;
  padding: 11px 16px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.thumb-list {
  position: relative;
  display: grid;
  align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 10px;
  overflow: auto;
  padding: 12px;
  user-select: none;
}

.selection-marquee {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 4;
  pointer-events: none;
  border: 1px solid var(--accent);
  background: rgba(39, 110, 241, .14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35);
}

.thumb-card {
  position: relative;
  display: grid;
  grid-template-rows: 98px auto;
  min-width: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  -webkit-user-drag: none;
}

.thumb-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(39, 110, 241, .14);
}

.thumb-card img {
  width: 100%;
  height: 98px;
  object-fit: cover;
  background: #e9edf2;
  -webkit-user-drag: none;
}

.thumb-fallback {
  display: grid;
  place-items: center;
  height: 98px;
  color: var(--muted);
  background: #e9edf2;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.thumb-name {
  min-width: 0;
  padding: 9px 10px 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metadata-form {
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  display: grid;
  align-content: start;
  gap: 16px;
  overflow: auto;
  padding: 18px 18px 20px;
}

.rename-panel {
  display: grid;
  gap: 14px;
  padding: 20px 18px 0;
  border-top: 1px solid var(--line);
}

.section-label {
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
}

.field {
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
}

.field select {
  min-height: 48px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 24px) 21px,
    calc(100% - 16px) 21px;
  background-repeat: no-repeat;
  background-size: 8px 8px;
  cursor: pointer;
  padding-right: 42px;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--quiet);
  opacity: 1;
}

.field textarea {
  min-height: 148px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(39, 110, 241, .13);
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  color: var(--quiet);
  background: #f4f2ed;
}

.preview-panel {
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.preview-head h3 {
  font-size: 14px;
  letter-spacing: 0;
}

.preview-head span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap {
  max-height: 180px;
  overflow: auto;
  background: var(--surface-soft);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

th,
td {
  height: 36px;
  padding: 0 12px;
  overflow: hidden;
  border-bottom: 1px solid #e6ebf1;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fbfcfe;
  color: #30394b;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}

td {
  color: #313b4d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

th:nth-child(3),
td:nth-child(3) {
  width: 76px;
  text-align: right;
}

.empty-cell {
  height: 74px;
  color: var(--quiet);
  font-family: inherit;
  text-align: center;
}

.unselected-row td {
  color: var(--quiet);
}

.actions {
  justify-content: flex-end;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

.ghost-button,
.primary-button {
  min-width: 130px;
  padding: 0 18px;
}

.ghost-button {
  color: var(--primary);
  background: var(--surface);
  border-color: var(--line);
}

.primary-button {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 12px 24px rgba(28, 45, 69, .16);
}

.primary-button:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: .42;
  box-shadow: none;
}

.status-line {
  min-height: 38px;
  padding: 0 18px 15px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-line.error {
  color: var(--danger);
}

.status-line.ready {
  color: var(--ok);
}

.review-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #090b10;
  color: #fff;
}

.review-overlay[hidden] {
  display: none;
}

.review-topbar {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 68px;
  padding: 0 18px;
  background: rgba(9, 11, 16, .92);
}

.review-topbar div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.review-topbar strong,
.review-topbar span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-topbar span {
  color: #b7c0ce;
  font-size: 13px;
  font-weight: 800;
}

.icon-button.light {
  color: #fff;
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .16);
}

.review-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  padding: 12px 86px 32px;
}

.review-hint {
  position: fixed;
  left: 50%;
  top: 80px;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  max-width: calc(100vw - 32px);
  padding: 9px 16px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 24px;
  color: #b7c0ce;
  background: rgba(18, 24, 32, .8);
  backdrop-filter: blur(12px);
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity .18s ease, visibility .18s ease;
}

.review-hint span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  white-space: nowrap;
}

.review-hint kbd {
  color: #e2e8ef;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: inherit;
}

.review-hint.hidden {
  visibility: hidden;
  opacity: 0;
}

.review-stage img {
  max-width: 100%;
  max-height: 100%;
  border: 4px solid transparent;
  border-radius: 8px;
  object-fit: contain;
  will-change: transform, opacity;
}

.review-stage img.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .88);
}

.review-stage figcaption {
  min-height: 32px;
  padding-top: 12px;
  color: #d6dce6;
  font-size: 14px;
  font-weight: 750;
  text-align: center;
}

.nav-button {
  position: fixed;
  top: 50%;
  width: 54px;
  height: 72px;
  border-color: rgba(255, 255, 255, .13);
  color: #fff;
  background: rgba(255, 255, 255, .08);
  font-size: 48px;
  line-height: 1;
  transform: translateY(-50%);
}

.nav-button:hover {
  background: rgba(255, 255, 255, .14);
}

.nav-button.left {
  left: 18px;
}

.nav-button.right {
  right: 18px;
}

@media (max-width: 1060px) {
  .app-shell {
    gap: 20px;
    padding: 22px;
  }

  .brand-panel {
    padding-bottom: 14px;
  }

  .brand-lockup {
    display: flex;
    gap: 12px;
  }

  .stage-switch {
    grid-column: 1 / -1;
    width: max-content;
  }

  .mode-note {
    max-width: none;
  }

  .stats {
    display: none;
  }

  .logo {
    width: 36px;
    height: 36px;
  }

  h1 {
    font-size: 23px;
  }

  .main-grid {
    grid-template-columns: 1fr;
  }

  .workspace {
    grid-template-rows: minmax(118px, auto) auto auto;
  }

  body.has-images .workspace {
    grid-template-rows: 96px auto auto;
  }
}

.copyright-notice {
  margin-top: 0;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

@media (max-width: 560px) {
  .app-shell {
    padding: 16px;
  }

  .brand-lockup {
    flex-wrap: wrap;
  }

  .mode-note {
    flex-basis: 100%;
  }

  .thumb-list {
    grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .ghost-button,
  .primary-button {
    width: 100%;
  }

  .review-stage {
    padding-inline: 18px;
  }

  .review-hint {
    gap: 12px;
    padding: 8px 12px;
  }

  .nav-button {
    top: auto;
    bottom: 18px;
    width: 48px;
    height: 48px;
    font-size: 36px;
  }
}

/* Reserve one-finger movement for fullscreen photo gestures. */
.review-stage { touch-action: none; }
.review-stage img { -webkit-user-drag: none; user-select: none; -webkit-touch-callout: none; }
.review-hint .touch-hint { display: none; }
@media (pointer: coarse) {
  .review-hint .keyboard-hint { display: none; }
  .review-hint .touch-hint { display: inline-flex; }
}


.thumb-selection {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  cursor: pointer;
  background: rgba(0, 0, 0, .35);
  border-radius: 0 0 0 12px;
}
.thumb-selection input {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.thumb-selection:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

/* Keep the native iOS date control within the metadata column. */
.field input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  text-align: left;
}
.field input[type="date"]::-webkit-date-and-time-value {
  min-height: 1.2em;
  text-align: left;
}
.field input[type="date"]::-webkit-datetime-edit {
  min-width: 0;
  padding: 0;
}
