:root {
  color-scheme: light;
  --bg: #f2f1ec;
  --surface: #fbfaf6;
  --surface-strong: #ffffff;
  --ink: #17191c;
  --muted: #6d7178;
  --line: #c8c7c0;
  --accent: #e85f35;
  --accent-ink: #ffffff;
  --soft-accent: #f9ded3;
  --shadow: 12px 14px 0 rgba(23, 25, 28, 0.12);
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", monospace;
  --sans: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  border-radius: 0;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  min-height: 72px;
  padding: 0 32px;
  border-bottom: 1px solid var(--ink);
  background: rgba(242, 241, 236, 0.95);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  width: fit-content;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.topbar nav {
  display: flex;
  gap: 28px;
}

.topbar nav a {
  color: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.mode-label {
  justify-self: end;
  border: 1px solid var(--ink);
  padding: 8px 10px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 11px;
}

.intro {
  min-height: 560px;
  padding: 76px max(32px, calc((100vw - 1440px) / 2));
  border-bottom: 1px solid var(--ink);
}

.intro-copy {
  max-width: 850px;
}

.kicker {
  margin: 0 0 14px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.intro h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(48px, 7vw, 92px);
  letter-spacing: -0.065em;
  line-height: 0.98;
}

.intro-copy > p:last-child {
  max-width: 620px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.recommend-box {
  max-width: 1080px;
  margin-top: 48px;
  padding: 26px;
  border: 1px solid var(--ink);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.recommend-box > label {
  display: block;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 800;
}

.recommend-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--ink);
  background: var(--surface-strong);
  color: var(--ink);
  padding: 10px 12px;
}

.recommend-input-row input {
  min-height: 58px;
  font-size: 17px;
}

.primary-button {
  min-width: 140px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0 22px;
  font-weight: 800;
}

.primary-button:active,
.preset-list button:active,
.shot-open:active {
  transform: translateY(1px);
}

.preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.preset-list button,
.filters button,
.close-button,
.detail-tabs button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 10px;
  font-size: 13px;
}

.preset-list button:hover,
.detail-tabs button:hover {
  border-color: var(--accent);
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 900px;
  max-width: 1600px;
  margin: 0 auto;
}

.filters {
  padding: 34px 28px;
  border-right: 1px solid var(--ink);
}

.filter-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.filter-heading h2 {
  margin: 0;
  font-size: 24px;
}

.filter-heading button {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  font-weight: 800;
}

.filters > label {
  display: block;
  margin-top: 24px;
  font-size: 13px;
  font-weight: 800;
}

.filters label input,
.filters label select {
  margin-top: 8px;
  font-weight: 500;
}

.check-row {
  display: flex !important;
  gap: 10px;
  align-items: center;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  margin: 0 !important;
  accent-color: var(--accent);
}

.filter-note {
  margin-top: 42px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.filter-note h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.filter-note p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.library-content {
  min-width: 0;
  padding: 36px;
}

.library-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 30px;
}

.library-heading h2 {
  margin: 0;
  font-size: 38px;
  letter-spacing: -0.04em;
}

.library-heading > p {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

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

.shot-card {
  min-width: 0;
}

.shot-open {
  width: 100%;
  border: 1px solid var(--ink);
  background: var(--surface);
  color: inherit;
  padding: 0;
  text-align: left;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.shot-open:hover {
  transform: translate(-4px, -4px);
  box-shadow: 8px 9px 0 rgba(23, 25, 28, 0.16);
}

.video-wrap {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: 1px solid var(--ink);
  background: #deddd7;
}

.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.shot-card-body {
  padding: 20px;
}

.shot-card-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.shot-card h3 {
  margin: 14px 0 8px;
  font-size: 24px;
  letter-spacing: -0.025em;
}

.shot-card p {
  min-height: 48px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.shot-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}

.shot-card-tags span {
  border: 1px solid var(--line);
  padding: 5px 7px;
  font-family: var(--mono);
  font-size: 10px;
}

.shot-card-reason {
  display: grid;
  gap: 5px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.shot-card-reason span {
  color: var(--muted);
}

.empty-state {
  border: 1px solid var(--line);
  padding: 54px;
  text-align: center;
}

.empty-state p {
  color: var(--muted);
}

.detail-dialog {
  width: min(940px, calc(100vw - 32px));
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  border: 0;
  border-left: 1px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  padding: 0;
}

.detail-dialog::backdrop {
  background: rgba(23, 25, 28, 0.55);
}

.detail-shell {
  min-height: 100%;
}

.detail-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 30px;
  border-bottom: 1px solid var(--ink);
  background: var(--surface);
}

.detail-header h2 {
  margin: 0;
  font-size: 32px;
}

.close-button {
  border-color: var(--ink);
}

#detailVideo {
  display: block;
  width: 100%;
  max-height: 52vh;
  background: #202226;
}

.detail-tabs {
  position: sticky;
  top: 98px;
  z-index: 2;
  display: flex;
  gap: 0;
  overflow-x: auto;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  background: var(--surface);
}

.detail-tabs button {
  min-height: 48px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0 18px;
  white-space: nowrap;
}

.detail-tabs button[aria-selected="true"] {
  background: var(--ink);
  color: var(--surface);
}

.detail-body {
  padding: 32px 30px 80px;
}

.story-flow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--ink);
}

.story-step {
  min-height: 170px;
  padding: 18px;
  border-right: 1px solid var(--ink);
}

.story-step:last-child {
  border-right: 0;
}

.story-step span,
.evidence-label {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
}

.story-step h3 {
  margin: 12px 0 8px;
  font-size: 17px;
}

.story-step p,
.detail-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.reason-block {
  margin-top: 24px;
  padding: 22px;
  background: var(--soft-accent);
}

.reason-block h3,
.evidence-block h3 {
  margin: 0 0 10px;
}

.evidence-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.evidence-block {
  min-height: 150px;
  border-top: 3px solid var(--ink);
  padding: 16px 0;
}

.evidence-block p {
  color: var(--muted);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.param-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.param-list li {
  border: 1px solid var(--line);
  padding: 14px;
}

.code-panel {
  border: 1px solid var(--ink);
  background: #202226;
  color: #f0eee7;
}

.code-panel header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 14px;
  border-bottom: 1px solid #54575d;
  font-family: var(--mono);
  font-size: 11px;
}

.code-panel pre {
  max-height: 520px;
  margin: 0;
  overflow: auto;
  padding: 18px;
  font: 12px/1.65 var(--mono);
  tab-size: 2;
  white-space: pre;
}

.public-code-note {
  border: 1px solid var(--ink);
  padding: 24px;
}

.public-code-note dl {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  margin: 24px 0 0;
}

.public-code-note dt {
  color: var(--muted);
}

.public-code-note dd {
  margin: 0;
  font-family: var(--mono);
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .topbar nav {
    display: none;
  }

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

  .filters {
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .filters > label {
    display: inline-block;
    width: calc(50% - 12px);
    margin-right: 8px;
    vertical-align: top;
  }

  .filter-note {
    display: none;
  }
}

@media (max-width: 720px) {
  .topbar {
    min-height: 62px;
    padding: 0 16px;
  }

  .brand small,
  .mode-label {
    display: none;
  }

  .intro {
    min-height: auto;
    padding: 48px 16px 56px;
  }

  .intro h1 {
    font-size: 50px;
  }

  .recommend-input-row,
  .shot-grid,
  .evidence-grid,
  .param-list {
    grid-template-columns: 1fr;
  }

  .recommend-input-row .primary-button {
    min-height: 52px;
  }

  .filters {
    padding: 28px 16px;
  }

  .filters > label {
    display: block;
    width: 100%;
    margin-right: 0;
  }

  .library-content {
    padding: 32px 16px;
  }

  .library-heading {
    align-items: start;
  }

  .story-flow {
    grid-template-columns: 1fr;
  }

  .story-step {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .story-step:last-child {
    border-bottom: 0;
  }

  .detail-header,
  .detail-body {
    padding-left: 18px;
    padding-right: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
