:root {
  --ink: #333333;
  --ink-deep: #002b4c;
  --ink-soft: #666666;
  --paper: #f7f7f7;
  --paper-deep: #ececec;
  --white: #ffffff;
  --red: #e84124;
  --red-dark: #842211;
  --gold: #0062a7;
  --line: #dbdbdb;
  --shadow: 0 18px 50px rgba(35, 25, 15, .09);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 95% 8%, rgba(0, 98, 167, .08), transparent 26rem),
    linear-gradient(180deg, #ffffff 0, var(--paper) 30rem);
  font-family: "Microsoft JhengHei", "PingFang TC", "Helvetica Neue", Helvetica, Arial, sans-serif;
  min-height: 100vh;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 100; background: var(--ink); color: white; padding: .75rem 1rem; }
.skip-link:focus { top: 1rem; }

.masthead { background: var(--white); color: var(--ink); border-bottom: 4px solid #0062af; }
.masthead__inner { width: min(1440px, calc(100% - 48px)); margin: 0 auto; min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 16px; color: var(--ink-deep); text-decoration: none; }
.brand__logo { display: block; width: auto; height: 48px; object-fit: contain; }
.brand__name { padding-left: 16px; border-left: 1px solid var(--line); font-weight: 650; letter-spacing: .12em; }
.masthead__meta { display: flex; align-items: center; gap: 10px; }
.sync-pill { display: flex; align-items: center; gap: 9px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-soft); font-size: .8rem; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(189, 140, 61, .12); }
.sync-pill.is-ready .sync-dot { background: #73b783; box-shadow: 0 0 0 4px rgba(115, 183, 131, .12); }
.sync-pill.is-error .sync-dot { background: #eb6a62; }
.icon-button { width: 38px; height: 38px; border: 1px solid #0062af; background: #0062af; color: white; border-radius: 50%; cursor: pointer; font-size: 1.25rem; transition: .2s ease; }
.icon-button:hover, .icon-button:focus-visible { background: var(--ink-deep); border-color: var(--ink-deep); color: white; transform: rotate(18deg); outline: none; }

.shell { width: min(1440px, calc(100% - 48px)); margin: 0 auto; }
.hero { padding: clamp(44px, 7vw, 92px) 0 42px; border-bottom: 1px solid var(--line); }
.eyebrow, .rail__kicker, .state-card__kicker { margin: 0 0 10px; font-size: .72rem; letter-spacing: .22em; font-weight: 800; color: var(--red); }
.hero__row { display: flex; justify-content: space-between; align-items: flex-end; gap: 40px; }
.hero h1 { margin: 0; font: 700 clamp(3.2rem, 7.5vw, 7.4rem)/.92 Georgia, "Noto Serif TC", serif; letter-spacing: -.075em; }
.hero__copy { max-width: 650px; margin: 22px 0 0; color: var(--ink-soft); font-size: 1.05rem; line-height: 1.8; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(88px, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stats div { padding: 15px 20px; border-left: 1px solid var(--line); text-align: center; }
.stats div:last-child { border-right: 1px solid var(--line); }
.stats strong { display: block; font: 700 1.7rem/1 Georgia, serif; }
.stats span { display: block; margin-top: 6px; color: var(--ink-soft); font-size: .75rem; letter-spacing: .12em; }

.state-card { max-width: 760px; margin: 72px auto; padding: 54px; text-align: center; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.state-card h2 { margin: 20px 0 8px; font: 700 1.9rem/1.25 Georgia, "Noto Serif TC", serif; }
.state-card p { color: var(--ink-soft); line-height: 1.7; }
.state-card--error { border-top: 4px solid var(--red); }
.loader { display: flex; justify-content: center; gap: 8px; }
.loader span { width: 10px; height: 10px; background: var(--red); border-radius: 50%; animation: pulse 1.2s infinite ease-in-out; }
.loader span:nth-child(2) { animation-delay: .15s; }.loader span:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 80%, 100% { transform: scale(.55); opacity: .35; } 40% { transform: scale(1); opacity: 1; } }
.state-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.button { border: 1px solid var(--ink); border-radius: 999px; padding: 11px 18px; cursor: pointer; font-weight: 700; }
.button--primary { background: var(--red); border-color: var(--red); color: white; }.button--primary:hover { background: var(--red-dark); }
.button--ghost { background: transparent; }
.button--blue { background: #0062a7; border-color: #0062a7; color: white; }.button--blue:hover { background: var(--ink-deep); border-color: var(--ink-deep); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.local-note { margin: 15px 0 0; font-size: .78rem; }

.command-bar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding: 24px 0 20px; background: rgba(247, 247, 247, .94); backdrop-filter: blur(14px); }
.search-wrap { position: relative; flex: 1; max-width: 850px; }
.search-wrap > label { display: block; margin-bottom: 8px; font-size: .78rem; font-weight: 750; letter-spacing: .08em; }
.search-field { height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--white); border: 1px solid #bdb4a7; border-radius: 12px; box-shadow: 0 6px 22px rgba(35, 25, 15, .05); }
.search-field:focus-within { border-color: #0062af; box-shadow: 0 0 0 3px rgba(0, 98, 175, .12); }
.search-field > span { font: 2rem/1 Georgia, serif; transform: rotate(-12deg); color: var(--red); }
.search-field input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; font-size: 1rem; }
kbd { border: 1px solid var(--line); background: #f5f1eb; color: var(--ink-soft); border-radius: 5px; padding: 3px 8px; font-size: .75rem; }
.search-panel { position: absolute; top: calc(100% + 8px); left: 0; right: 0; max-height: 420px; overflow: auto; background: var(--white); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.search-group-title { padding: 13px 16px 8px; color: var(--red); font-size: .68rem; font-weight: 800; letter-spacing: .18em; }
.search-result { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 16px; border: 0; border-top: 1px solid #eee8df; background: transparent; text-align: left; cursor: pointer; }
.search-result:hover, .search-result:focus-visible { background: #f7f2ea; outline: none; }
.search-result strong { display: block; }.search-result small { color: var(--ink-soft); }
.mode-switch { display: flex; padding: 4px; background: var(--paper-deep); border-radius: 999px; }
.mode-switch__button { border: 0; border-radius: 999px; background: transparent; padding: 10px 20px; cursor: pointer; font-weight: 750; }
.mode-switch__button.is-active { background: #0062af; color: white; }

.workspace { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 28px; padding-bottom: 70px; }
.rail { align-self: start; position: sticky; top: 123px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 10px 35px rgba(35, 25, 15, .055); }
.rail__heading { display: flex; justify-content: space-between; align-items: center; padding: 22px 22px 17px; border-bottom: 1px solid var(--line); }
.rail__heading h2 { margin: 0; font: 700 1.3rem/1.2 Georgia, "Noto Serif TC", serif; }
.rail__kicker { margin-bottom: 6px; }
.count-badge { min-width: 34px; padding: 5px 8px; text-align: center; color: var(--red); border: 1px solid #e6b7b3; border-radius: 999px; font-size: .75rem; font-weight: 800; }
.field-label { display: block; padding: 17px 22px 7px; color: var(--ink-soft); font-size: .74rem; font-weight: 750; letter-spacing: .08em; }
.rail select, .text-field { width: calc(100% - 44px); margin: 0 22px 14px; border: 1px solid var(--line); border-radius: 9px; background: #faf8f4; padding: 10px 12px; outline: 0; }
.rail select:focus, .text-field:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(183, 41, 36, .1); }
.rail-list { max-height: calc(100vh - 340px); overflow: auto; border-top: 1px solid var(--line); }
.rail-item { width: 100%; display: block; padding: 13px 22px; border: 0; border-bottom: 1px solid #eee8df; background: transparent; text-align: left; cursor: pointer; }
.rail-item:hover, .rail-item:focus-visible { background: #f7f2ea; outline: none; }
.rail-item.is-active { background: #0062af; color: white; }
.rail-item strong { display: block; font-weight: 700; line-height: 1.35; }.rail-item small { display: block; margin-top: 4px; color: var(--ink-soft); }
.rail-item.is-active small { color: #e5f2fb; }
.rail-empty { padding: 28px 22px; color: var(--ink-soft); text-align: center; line-height: 1.6; }

.detail-pane { min-width: 0; outline: 0; }
.welcome-panel { min-height: 430px; display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: clamp(20px, 6vw, 80px); padding: clamp(30px, 6vw, 80px); color: white; background: var(--ink-deep); border-radius: var(--radius); overflow: hidden; position: relative; }
.welcome-panel::after { content: ""; position: absolute; width: 300px; height: 300px; border: 70px solid var(--red); border-radius: 50%; right: -130px; bottom: -170px; opacity: .75; }
.welcome-panel__number { margin: 0; color: var(--gold); font: italic 700 4rem/1 Georgia, serif; align-self: start; }
.welcome-panel h2 { margin: 0 0 18px; max-width: 620px; font: 700 clamp(2rem, 4vw, 4rem)/1.08 Georgia, "Noto Serif TC", serif; letter-spacing: -.04em; }
.welcome-panel > div > p:last-child { max-width: 610px; color: #cfc8bf; line-height: 1.9; }

.record-header { padding: clamp(28px, 5vw, 62px); background: var(--ink-deep); color: white; border-radius: var(--radius) var(--radius) 0 0; position: relative; overflow: hidden; }
.record-header::after { content: attr(data-index); position: absolute; right: 26px; bottom: -22px; color: rgba(255,255,255,.055); font: 700 9rem/1 Georgia, serif; }
.record-header__meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.tag { display: inline-flex; padding: 5px 10px; border: 1px solid #5a544f; border-radius: 999px; color: #e5ddd4; font-size: .74rem; }
.tag--red { border-color: #e37872; color: #ffc7c3; }
.record-header h2 { position: relative; z-index: 1; max-width: 900px; margin: 0; font: 700 clamp(2.2rem, 5vw, 5rem)/1.02 Georgia, "Noto Serif TC", serif; letter-spacing: -.055em; }
.record-header__en { position: relative; z-index: 1; margin: 12px 0 0; color: #bbb3aa; font: italic 1.1rem/1.5 Georgia, serif; }
.record-body { background: var(--white); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
.record-section { padding: clamp(24px, 4vw, 46px); border-top: 1px solid var(--line); }
.record-section:first-child { border-top: 0; }
.section-title { display: flex; align-items: baseline; gap: 12px; margin: 0 0 22px; font: 700 1.45rem/1.2 Georgia, "Noto Serif TC", serif; }
.section-title span { color: var(--red); font: 800 .68rem/1 sans-serif; letter-spacing: .16em; }
.performance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.performance-card { padding: 18px; background: #f7f3ed; border-left: 3px solid var(--red); border-radius: 0 9px 9px 0; }
.performance-card strong { display: block; margin-bottom: 8px; }.performance-card dl { margin: 0; }
.performance-card dl div { display: grid; grid-template-columns: 52px 1fr; gap: 8px; margin-top: 5px; }
.performance-card dt { color: var(--ink-soft); font-size: .75rem; }.performance-card dd { margin: 0; font-size: .88rem; line-height: 1.5; }
.credit-list { border-top: 1px solid var(--line); }
.credit-row { display: grid; grid-template-columns: minmax(135px, 22%) 1fr; border-bottom: 1px solid var(--line); }
.credit-role { padding: 17px 18px 17px 0; color: var(--red-dark); font-weight: 800; }
.credit-people { display: flex; flex-wrap: wrap; gap: 7px 18px; padding: 15px 0 15px 18px; border-left: 1px solid var(--line); }
.credit-people--actors { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; }
.credit-people--actors > div { width: 100%; }
.person-chip { border: 0; background: transparent; padding: 1px 0; text-align: left; cursor: pointer; border-bottom: 1px solid transparent; }
.person-chip:hover, .person-chip:focus-visible { color: var(--red); border-color: var(--red); outline: none; }
.person-chip small { color: var(--ink-soft); }.character { color: var(--ink-soft); font-size: .85rem; }
.history-table { width: 100%; border-collapse: collapse; }
.history-table th { padding: 10px 12px; color: var(--ink-soft); font-size: .72rem; letter-spacing: .08em; text-align: left; border-bottom: 2px solid var(--ink); }
.history-table td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.5; }
.link-button { border: 0; background: transparent; padding: 0; color: var(--red-dark); cursor: pointer; font-weight: 750; text-align: left; }
.link-button:hover, .link-button:focus-visible { text-decoration: underline; outline: none; }
.empty-note { margin: 0; color: var(--ink-soft); font-style: italic; }

.footer { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 28px 0 40px; display: flex; justify-content: space-between; gap: 24px; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .76rem; }
.footer div { display: flex; flex-wrap: wrap; gap: 8px 24px; }.footer p { margin: 0; }

@media (max-width: 900px) {
  .hero__row { display: block; }.stats { margin-top: 34px; width: fit-content; }
  .workspace { grid-template-columns: 1fr; }.rail { position: static; }.rail-list { max-height: 300px; }
  .command-bar { top: 0; }.welcome-panel { min-height: 360px; grid-template-columns: 1fr; }.welcome-panel__number { display: none; }
}
@media (max-width: 640px) {
  .masthead__inner, .shell, .footer { width: min(100% - 28px, 1440px); }
  .brand__name, .sync-pill { display: none; }.masthead__inner { min-height: 64px; }
  .hero { padding-top: 42px; }.hero h1 { font-size: clamp(3rem, 17vw, 5rem); }
  .stats { width: 100%; }.stats div { padding-inline: 10px; }
  .command-bar { display: block; padding-top: 14px; }.mode-switch { margin-top: 12px; width: fit-content; }
  .search-field { height: 52px; }kbd { display: none; }
  .record-header, .record-section { padding: 25px 20px; }.credit-row { grid-template-columns: 1fr; }.credit-role { padding-bottom: 6px; }
  .credit-people { border-left: 0; padding: 0 0 15px; }.history-table { min-width: 660px; }.table-scroll { overflow-x: auto; }
  .footer { display: block; }.footer p { margin-top: 15px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; } }
