/* Source Han Serif TC Medium — 已裁切為本頁所需字集（含常見姓名、公司與備註用字）。
   字集外的字會退回 Noto Serif TC，兩者為同一套字體設計，字形一致。 */
@font-face {
  font-family: 'SHSerifTC';
  src: url('./assets/fonts/shserif-tc-subset.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
:root {
  --paper: #F6F2E9;
  --paper-2: #EEE6D4;
  --card: #FCFAF5;
  --ink: #1E2A32;
  --ink-2: #55636B;
  --ink-3: #8B8676;
  --brass: #8F6E33;
  --brass-strong: #6E5424;
  --brass-soft: #C9A467;
  --line: #DED2B7;
  --line-soft: #E9E0CB;
  --error: #963C36;
  --error-bg: #F6E7E4;
  --success: #3E6B52;
  --focus: #8F6E33;
  --shadow: rgba(30, 30, 20, 0.10);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14181B;
    --paper-2: #1B2024;
    --card: #191E22;
    --ink: #EAE4D4;
    --ink-2: #AFA890;
    --ink-3: #7C7867;
    --brass: #CBA669;
    --brass-strong: #E2C08A;
    --brass-soft: #8F6E33;
    --line: #34393C;
    --line-soft: #262B2E;
    --error: #E2A29B;
    --error-bg: #2A1E1C;
    --success: #8FC3A6;
    --focus: #CBA669;
    --shadow: rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  --paper: #14181B;
  --paper-2: #1B2024;
  --card: #191E22;
  --ink: #EAE4D4;
  --ink-2: #AFA890;
  --ink-3: #7C7867;
  --brass: #CBA669;
  --brass-strong: #E2C08A;
  --brass-soft: #8F6E33;
  --line: #34393C;
  --line-soft: #262B2E;
  --error: #E2A29B;
  --error-bg: #2A1E1C;
  --success: #8FC3A6;
  --focus: #CBA669;
  --shadow: rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'SHSerifTC', 'Noto Serif TC', serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  padding: clamp(20px, 5vw, 64px) clamp(16px, 4vw, 24px);
}

h1, h2, h3 {
  font-family: 'SHSerifTC', 'Noto Serif TC', serif;
  font-weight: 600;
  text-wrap: balance;
  margin: 0;
  color: var(--ink);
}

.preview-banner {
  max-width: 980px;
  margin: 0 auto 20px;
  padding: 11px 18px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.preview-banner strong { color: var(--brass-strong); font-weight: 600; }

.sheet {
  max-width: 980px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 60px -32px var(--shadow);
  overflow: hidden;
}

.masthead {
  padding: clamp(28px, 4vw, 44px) clamp(24px, 5vw, 56px) clamp(22px, 3vw, 32px);
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, var(--paper-2), transparent);
}

.masthead .logo {
  display: block;
  width: clamp(150px, 19vw, 194px);
  height: auto;
  margin: 0 0 26px;
}

/* 深色背景改用反白字標版本；兩個檔案皆為官方 logo，未經改色或變形 */
.masthead .logo-dark { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .masthead .logo-light { display: none; }
  :root:not([data-theme="light"]) .masthead .logo-dark { display: block; }
}

:root[data-theme="dark"] .masthead .logo-light { display: none; }
:root[data-theme="dark"] .masthead .logo-dark { display: block; }

.masthead h1 {
  font-size: clamp(26px, 3.4vw, 34px);
  letter-spacing: 0.01em;
}

.masthead .sub {
  margin-top: 10px;
  font-size: 15px;
  color: var(--ink-2);
  max-width: 62ch;
}

.masthead .rule {
  width: 46px;
  height: 2px;
  background: var(--brass);
  margin: 18px 0 0;
}

form {
  padding: clamp(24px, 3vw, 40px) clamp(22px, 4vw, 48px) clamp(32px, 4vw, 48px);
}

fieldset {
  border: none;
  margin: 0 0 34px;
  padding: 0;
}

legend {
  font-family: 'SHSerifTC', 'Noto Serif TC', serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  padding: 0;
  margin-bottom: 4px;
}

.legend-note {
  font-size: 12.5px;
  color: var(--ink-3);
  margin: 0 0 18px;
}

/* ── 日期選擇 ───────────────────────────── */

.avail-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--ink-3);
}

.avail-state {
  display: flex;
  align-items: center;
  gap: 7px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex: none;
}
.dot.stale { background: var(--brass-soft); }

.refresh {
  font: inherit;
  font-size: 12px;
  color: var(--brass);
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 11px;
  cursor: pointer;
}
.refresh:hover { border-color: var(--brass); }
.refresh:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.refresh:disabled { opacity: .5; cursor: default; }

.date-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 10px;
}

.date-opt { position: relative; }

.date-opt input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.date-opt label {
  display: block;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 13px 11px;
  cursor: pointer;
  background: var(--paper);
  transition: border-color .15s ease, background .15s ease;
}

.date-opt label:hover { border-color: var(--brass-soft); }

.date-opt input:checked + label {
  border-color: var(--brass);
  box-shadow: inset 0 0 0 1px var(--brass);
  background: color-mix(in srgb, var(--brass) 8%, var(--paper));
}

.date-opt input:focus-visible + label {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.date-opt .d {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.date-opt .w {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 1px;
}

.date-opt .r {
  font-size: 12px;
  color: var(--success);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.date-opt .r b { font-weight: 600; }

.date-opt.low .r { color: var(--brass-strong); }

.date-opt.full label {
  cursor: not-allowed;
  background: var(--paper-2);
  border-style: dashed;
  opacity: .62;
}
.date-opt.full label:hover { border-color: var(--line); }
.date-opt.full .r { color: var(--ink-3); }

.grid-empty {
  grid-column: 1 / -1;
  padding: 22px;
  text-align: center;
  font-size: 13.5px;
  color: var(--ink-3);
  border: 1px dashed var(--line);
  border-radius: 9px;
}

/* ── 一般欄位 ───────────────────────────── */

.row {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 18px;
}
.row.single { grid-template-columns: 1fr; }
.row:last-child { margin-bottom: 0; }

@media (max-width: 560px) {
  .row { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; gap: 7px; }

.field label {
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.field .req { color: var(--brass-strong); margin-left: 3px; }
.field .opt { color: var(--ink-3); font-weight: 400; margin-left: 4px; }

input[type="text"], input[type="tel"], input[type="email"],
input[type="number"], textarea {
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input::placeholder { color: var(--ink-3); }

input:focus, textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent);
}

textarea {
  font-family: inherit;
  min-height: 92px;
  resize: vertical;
  line-height: 1.6;
}

/* 數字欄位後綴單位「位」 */
.with-unit { position: relative; }

.with-unit input {
  padding-right: 38px;
  -moz-appearance: textfield;
  appearance: textfield;
}

.with-unit input::-webkit-outer-spin-button,
.with-unit input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.with-unit .unit {
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--ink-3);
  pointer-events: none;
}

.field.invalid input, .field.invalid textarea { border-color: var(--error); }
.field .err-msg {
  display: none;
  font-size: 12px;
  color: var(--error);
}
.field.invalid .err-msg { display: block; }

.row-note {
  font-size: 12px;
  color: var(--ink-3);
  margin: -6px 0 0;
  line-height: 1.6;
}

.sect-err {
  display: none;
  font-size: 12px;
  color: var(--error);
  margin-top: 10px;
}
.sect-err.show { display: block; }

.consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12.5px;
  color: var(--ink-2);
  margin: 4px 0 28px;
}
.consent input { width: auto; margin-top: 3px; accent-color: var(--brass); }

.actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

button[type="submit"] {
  font-family: 'SHSerifTC', 'Noto Serif TC', serif;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--card);
  background: var(--brass);
  border: none;
  border-radius: 8px;
  padding: 13px 30px;
  cursor: pointer;
  transition: background .15s ease, transform .05s ease;
}
button[type="submit"]:hover { background: var(--brass-strong); }
button[type="submit"]:active { transform: translateY(1px); }
button[type="submit"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button[type="submit"]:disabled { opacity: .6; cursor: wait; }

.actions .hint { font-size: 12px; color: var(--ink-3); }

.status {
  margin-top: 18px;
  padding: 13px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  display: none;
  line-height: 1.6;
}
.status.show { display: block; }
.status.warn {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid color-mix(in srgb, var(--error) 35%, transparent);
}

/* ── 完成畫面 ───────────────────────────── */

.done {
  display: none;
  padding: clamp(36px, 6vw, 64px) clamp(22px, 4vw, 48px);
  text-align: center;
}
.done.show { display: block; }

.done .mark {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1.5px solid var(--success);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  margin: 0 auto 20px;
}

.done h2 { font-size: 25px; margin-bottom: 12px; }

.done p {
  font-size: 14.5px;
  color: var(--ink-2);
  max-width: 46ch;
  margin: 0 auto 8px;
}

.done .recap {
  display: inline-block;
  margin-top: 22px;
  padding: 14px 22px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 13.5px;
  color: var(--ink);
  text-align: left;
}
.done .recap span { color: var(--ink-3); margin-right: 8px; }
.done .recap div + div { margin-top: 5px; }

.footnote {
  max-width: 980px;
  margin: 18px auto 0;
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: center;
}

/* ── 讀取中／錯誤狀態 ───────────────────── */

/* 預設隱藏；僅在伺服器回報為示範模式時顯示，避免正式站誤掛橫幅 */
.preview-banner[hidden] { display: none; }

.date-skeleton {
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  height: 84px;
  background: linear-gradient(
    100deg,
    var(--paper) 30%,
    var(--paper-2) 50%,
    var(--paper) 70%
  );
  background-size: 220% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  from { background-position: 140% 0; }
  to { background-position: -40% 0; }
}

.grid-empty .retry {
  font: inherit;
  font-size: 12.5px;
  color: var(--brass);
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 12px;
  margin-top: 10px;
  cursor: pointer;
  display: inline-block;
}
.grid-empty .retry:hover { border-color: var(--brass); }
.grid-empty .retry:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.status.info {
  background: var(--paper-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.turnstile-holder { margin: 0 0 20px; min-height: 0; }
.turnstile-holder:not(:empty) { min-height: 70px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .date-skeleton { animation: none; }
}
