:root {
  color-scheme: dark;
  --bg: #12110f;
  --band: #1b1916;
  --panel: #24211d;
  --panel-2: #2d2923;
  --line: #4a4136;
  --muted: #b9afa1;
  --text: #f4efe6;
  --soft: #d8cfbf;
  --gold: #c7a35a;
  --teal: #7fb1a4;
  --blue: #839fc9;
  --red: #ca725e;
  --violet: #b197bf;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", sans-serif;
  letter-spacing: 0;
}

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

button,
.file-fallback,
.ghost {
  border: 1px solid var(--line);
  background: #27231e;
  color: var(--text);
  border-radius: 6px;
  min-height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

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

button:hover,
.file-fallback:hover,
.ghost:hover {
  border-color: #75664e;
  background: #312c25;
}

button.listening {
  border-color: var(--red);
  background: #4a211c;
  color: #fff4ee;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.primary {
  background: var(--gold);
  color: #191510;
  border-color: var(--gold);
  font-weight: 700;
}

.shell {
  height: 100vh;
  min-height: 720px;
  display: grid;
  grid-template-rows: 70px 58px minmax(0, 1fr) 36px;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--band);
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  border: 1px solid var(--gold);
  display: grid;
  place-items: center;
  font-family: Georgia, serif;
  font-size: 22px;
  color: var(--gold);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  font-weight: 700;
}

.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  max-width: 460px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.quiet-button b {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid #6b5c45;
  border-radius: 50%;
  color: var(--gold);
  font-size: 13px;
}

.apply-button {
  border-color: #6f8f85;
  background: #243d36;
  color: #eaf8f2;
  font-weight: 700;
}

.apply-button:hover {
  border-color: var(--teal);
  background: #2b4b42;
}

.more-menu {
  position: relative;
}

.more-menu summary {
  list-style: none;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #27231e;
  color: var(--text);
  display: flex;
  align-items: center;
  cursor: pointer;
}

.more-menu summary::-webkit-details-marker {
  display: none;
}

.more-menu[open] summary {
  border-color: var(--gold);
}

.more-menu-panel {
  position: absolute;
  z-index: 30;
  right: 0;
  top: 44px;
  width: 270px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1d1a16;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  display: grid;
  gap: 8px;
}

.more-menu-panel .keyword-field {
  width: 100%;
  height: auto;
  padding: 9px;
  align-items: flex-start;
  flex-direction: column;
}

.more-menu-panel .keyword-field input {
  width: 100%;
}

.menu-file-action {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.menu-file-action:hover {
  border-color: #75664e;
  background: #29241e;
}

.menu-file-action input,
.hidden-file-input {
  display: none;
}

.browser-notice {
  position: fixed;
  z-index: 35;
  top: 78px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border: 1px solid #7d6340;
  border-radius: 6px;
  background: #352819;
  color: #f1dfbf;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  font-size: 13px;
}

.keyword-field {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #181613;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}

.keyword-field input {
  width: 185px;
  background: transparent;
  border: 0;
  color: var(--text);
  outline: 0;
}

.file-fallback input,
.ghost input {
  display: none;
}

.status-band {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: #171512;
  border-bottom: 1px solid var(--line);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--soft);
  font-size: 13px;
}

.progress-track {
  height: 8px;
  background: #0d0c0b;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #302b25;
}

#progressBar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--teal));
}

.filter-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(86px, 1fr));
  gap: 8px;
}

.filter-tabs button {
  min-width: 0;
  height: 38px;
  padding: 0 8px;
  justify-content: space-between;
  color: var(--soft);
}

.filter-tabs button.active {
  border-color: var(--gold);
  color: var(--text);
  background: #352f25;
}

.filter-tabs span {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.review-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  background: var(--bg);
}

.left-rail,
.right-rail {
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #181613;
}

.right-rail {
  border-right: 0;
  border-left: 1px solid var(--line);
  display: none;
}

.tool-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.quick-panel {
  gap: 12px;
  padding: 14px 12px;
}

.tool-panel.compact {
  grid-template-columns: 1fr;
}

.mark {
  height: 50px;
  justify-content: flex-start;
  padding: 0 10px;
}

.quick-panel .mark {
  height: 86px;
  align-content: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
}

.mark b {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: #16120d;
  font-size: 14px;
}

.quick-panel .mark b {
  width: 42px;
  height: 34px;
  font-size: 18px;
}

.mark span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.keep b,
.badge-keep {
  background: var(--gold);
}

.reject b,
.badge-reject {
  background: var(--red);
}

.viewer {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  background: #0b0a09;
}

.empty-state {
  align-self: center;
  justify-self: center;
  width: min(560px, calc(100% - 40px));
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  font-size: 28px;
  margin-bottom: 12px;
  color: var(--text);
  font-weight: 700;
}

.empty-state p {
  line-height: 1.7;
}

.empty-kicker {
  display: block;
  margin-bottom: 10px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
}

.empty-primary {
  margin: 22px auto 0;
}

.image-stage,
.compare-stage {
  min-width: 0;
  min-height: 0;
  position: relative;
}

.review-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  overflow: hidden;
}

.grid-card {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 2px solid #302a23;
  border-radius: 6px;
  background: #11100e;
  overflow: hidden;
  padding: 0;
  display: block;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
}

.grid-card:hover,
.grid-card.current {
  border-color: var(--gold);
}

.grid-card.keep {
  border-color: var(--gold);
}

.grid-card.reject {
  border-color: var(--red);
}

.grid-card.empty {
  opacity: 0.25;
  border-style: dashed;
}

.grid-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #080706;
}

.slot-number {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(10, 9, 8, 0.78);
  border: 2px solid rgba(255, 255, 255, 0.7);
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(8px);
}

.slot-status {
  position: absolute;
  top: 12px;
  right: 12px;
  min-width: 74px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: rgba(10, 9, 8, 0.76);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 14px;
  font-weight: 800;
  backdrop-filter: blur(8px);
}

.grid-card.keep .slot-status {
  background: rgba(102, 78, 26, 0.86);
}

.grid-card.reject .slot-status {
  background: rgba(126, 45, 34, 0.88);
}

.slot-name {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  min-height: 28px;
  display: flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(10, 9, 8, 0.72);
  color: var(--soft);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.image-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 18px;
}

#mainImage {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 12px 50px var(--shadow);
}

.image-stage.zoomed .image-scroll {
  place-items: start center;
}

.image-stage.zoomed #mainImage {
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
}

.stage-hotspot {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 16%;
  border: 0;
  border-radius: 0;
  background: transparent;
  z-index: 2;
}

.stage-hotspot:hover {
  background: rgba(255, 255, 255, 0.04);
}

.stage-hotspot.left {
  left: 0;
}

.stage-hotspot.right {
  right: 0;
}

.decision-badge {
  position: absolute;
  left: 18px;
  top: 18px;
  min-width: 96px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(18, 17, 15, 0.72);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(10px);
  font-size: 14px;
}

.compare-stage {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  grid-auto-rows: 240px;
  gap: 10px;
  padding: 12px;
  overflow: auto;
}

.compare-item {
  position: relative;
  border: 1px solid var(--line);
  background: #151311;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}

.compare-item.current {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(199, 163, 90, 0.26);
}

.compare-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.compare-item span {
  position: absolute;
  left: 8px;
  bottom: 8px;
  right: 8px;
  padding: 4px 6px;
  border-radius: 4px;
  background: rgba(12, 10, 8, 0.75);
  color: var(--soft);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.info-panel,
.strip-panel,
.note-panel {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.info-panel h2 {
  font-size: 18px;
  word-break: break-word;
}

.info-panel p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  word-break: break-all;
}

dl {
  margin: 14px 0 0;
  display: grid;
  gap: 10px;
}

dl div {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 0;
  color: var(--soft);
  font-size: 13px;
  word-break: break-word;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.panel-title h2,
.note-panel label {
  color: var(--soft);
  font-size: 14px;
  font-weight: 700;
}

.panel-title span {
  color: var(--gold);
  font-size: 12px;
}

.neighbor-strip {
  display: grid;
  gap: 8px;
}

.thumb {
  height: 78px;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #161411;
  overflow: hidden;
  cursor: pointer;
}

.thumb.current {
  border-color: var(--gold);
  background: #272116;
}

.thumb img {
  width: 86px;
  height: 76px;
  object-fit: cover;
  background: #0b0a09;
}

.thumb-info {
  min-width: 0;
  align-self: center;
  padding-right: 8px;
}

.thumb-info strong,
.thumb-info span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb-info strong {
  font-size: 12px;
  color: var(--soft);
}

.thumb-info span {
  margin-top: 5px;
  font-size: 11px;
  color: var(--muted);
}

.note-panel textarea {
  margin-top: 10px;
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #12100e;
  color: var(--text);
  padding: 10px;
  line-height: 1.5;
}

.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: #171512;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

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

#voiceStatus {
  color: var(--gold);
}

#voiceHeard {
  max-width: 360px;
  color: var(--soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-help {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mini-help span:nth-child(odd) {
  color: var(--gold);
  border: 1px solid #5d503b;
  border-radius: 4px;
  padding: 2px 6px;
  background: #211d18;
}

.hidden {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 24px;
  display: grid;
  place-items: center;
  background: rgba(7, 6, 5, 0.82);
  backdrop-filter: blur(8px);
}

.tutorial-dialog,
.organize-dialog {
  width: min(900px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid #5d503e;
  border-radius: 8px;
  background: #1c1915;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
}

.organize-dialog {
  width: min(660px, 100%);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin-top: 5px;
  font-family: Georgia, "Noto Serif TC", "Songti TC", serif;
  font-size: 28px;
  font-weight: 600;
}

.modal-eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
}

.icon-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.privacy-note {
  margin: 20px 24px 0;
  padding: 14px 16px;
  border-left: 3px solid var(--teal);
  background: #17231f;
  color: #dfeae5;
  line-height: 1.6;
  font-size: 14px;
}

.privacy-note strong {
  margin-right: 5px;
  color: #f0faf5;
}

.tutorial-steps {
  margin: 0;
  padding: 22px 24px;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tutorial-steps li {
  min-height: 112px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  background: #211e19;
}

.step-number {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 18px;
}

.tutorial-steps strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 15px;
}

.tutorial-steps p {
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.tutorial-shortcuts {
  margin: 0 24px 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

kbd {
  min-width: 30px;
  padding: 4px 7px;
  border: 1px solid #6a5a42;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #2c271f;
  color: var(--gold);
  font: 700 12px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.tutorial-footer {
  justify-content: space-between;
}

.tutorial-footer label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.tutorial-footer input {
  width: 16px;
  height: 16px;
  accent-color: var(--gold);
}

.organize-message {
  padding: 20px 24px 8px;
  color: var(--muted);
  line-height: 1.65;
}

.organize-counts {
  padding: 12px 24px 22px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.organize-counts div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #211e19;
}

.organize-counts span,
.organize-counts strong,
.organize-counts small {
  display: block;
}

.organize-counts span {
  color: var(--muted);
  font-size: 12px;
}

.organize-counts strong {
  margin: 8px 0;
  color: var(--text);
  font: 600 30px Georgia, serif;
}

.organize-counts small {
  color: var(--muted);
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.organize-progress {
  height: 8px;
  margin: 0 24px 14px;
  border-radius: 999px;
  overflow: hidden;
  background: #0c0b09;
}

.organize-progress div {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--teal));
  transition: width 180ms ease;
}

.organize-result {
  margin: 0 24px 18px;
  padding: 12px 14px;
  border: 1px solid #46655c;
  border-radius: 6px;
  background: #17231f;
  color: #dfeae5;
  line-height: 1.55;
}

@media (max-width: 1100px) {
  .shell {
    min-height: 780px;
    grid-template-rows: auto auto minmax(0, 1fr) 36px;
  }

  .topbar {
    align-items: flex-start;
    padding: 12px;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .status-band {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .filter-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .review-layout {
    grid-template-columns: 126px minmax(0, 1fr);
  }

  .right-rail {
    display: none;
  }

  .review-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .modal-overlay {
    padding: 12px;
  }

  .tutorial-dialog,
  .organize-dialog {
    max-height: calc(100vh - 24px);
  }

  .tutorial-steps,
  .organize-counts {
    grid-template-columns: 1fr;
  }

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

  .tutorial-footer button {
    width: 100%;
  }

  .tutorial-shortcuts {
    justify-content: flex-start;
  }

  .modal-header h2 {
    font-size: 23px;
  }
}
