/* 共用樣式：色彩、字體、按鈕、欄位與對話視窗。 */
:root {
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Segoe UI", system-ui, sans-serif;
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", "Times New Roman", serif;
  --ink: #2b2a27;
  --ink-soft: #4a4742;
  --muted: #76716a;
  --paper: #ffffff;
  --cream: #f7f5f1;
  --field: #f4f2ee;
  --line: #d9d4cc;
  --line-strong: #4a4742;
  --brown: #6b6253;
  --brown-deep: #574f43;
  --dark: #2e2d2b;
  --danger: #b4432a;
  --danger-soft: #fdf1ee;
  --notice: #fbf3e3;
  --notice-line: #e4cf9f;
  --success: #3f6b4e;
  --focus: #a08a5e;
  --radius: 10px;
  --shadow: 0 18px 60px rgba(43, 42, 39, 0.16);
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.65;
  font-size: 16px;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; background: var(--paper); }
[hidden] { display: none !important; }
h1, h2, h3, p, dl, dd, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
svg { display: block; }
.muted { color: var(--muted); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 0; }

/* 品牌區 */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px;
  background: var(--brown); color: #fff; flex: none;
}
.brand-light .brand-icon { background: transparent; border: 1.5px solid rgba(255, 255, 255, 0.85); }
.brand-name { font-family: var(--serif); font-size: 18px; font-weight: 700; letter-spacing: 0.02em; line-height: 1.3; }
.brand-sub { font-size: 12px; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.brand-light .brand-name { color: #fff; }
.brand-light .brand-sub { color: rgba(255, 255, 255, 0.78); }

/* 標題 */
.page-title, h1 { font-family: var(--serif); font-weight: 700; letter-spacing: 0.01em; line-height: 1.2; }

/* 按鈕 */
.primary-button {
  background: var(--dark); color: #fff; border: 0; border-radius: var(--radius);
  padding: 14px 28px; font-size: 16px; font-weight: 600; letter-spacing: 0.04em; min-height: 52px;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.primary-button:hover:not(:disabled) { background: #1f1e1c; }
.primary-button:active:not(:disabled) { transform: translateY(1px); }
.secondary-button {
  background: #fff; color: var(--ink); border: 1.5px solid var(--line-strong); border-radius: var(--radius);
  padding: 12px 22px; font-size: 15px; font-weight: 600; min-height: 48px;
}
.secondary-button:hover:not(:disabled) { background: var(--cream); }
.secondary-button.block { display: block; width: 100%; }
.link-button {
  background: none; border: 0; padding: 4px 2px; color: var(--ink-soft); font-size: 15px; font-weight: 500;
  text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line);
}
.link-button:hover:not(:disabled) { color: var(--ink); text-decoration-color: currentColor; }
.icon-button {
  background: none; border: 0; width: 40px; height: 40px; border-radius: 50%; font-size: 26px; line-height: 1;
  color: var(--ink-soft); display: grid; place-items: center;
}
.icon-button:hover { background: var(--cream); }

/* 欄位 */
.field { display: grid; gap: 8px; margin-bottom: 26px; }
.field label { font-weight: 700; font-size: 15px; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.field-tag { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }
.count { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.count.over-limit { color: var(--danger); font-weight: 600; }
input:not([type="checkbox"]), textarea, select {
  width: 100%; min-width: 0; padding: 14px 16px; background: var(--field); border: 0; border-bottom: 2px solid var(--line-strong);
  border-radius: 6px 6px 0 0; font-size: 16px; line-height: 1.5; color: var(--ink);
}
input::placeholder, textarea::placeholder { color: #9a948b; }
textarea { resize: vertical; min-height: 220px; }
select { appearance: none; -webkit-appearance: none; padding-right: 44px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a4742' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; }
select:disabled { cursor: not-allowed; color: var(--muted); opacity: 0.75; }
input[readonly], textarea[readonly] { color: var(--ink-soft); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-bottom-color: var(--danger); }
.field-error { color: var(--danger); font-size: 14px; min-height: 1.4em; }
.form-error { color: var(--danger); font-size: 14px; white-space: pre-line; min-height: 1.4em; }
.notice {
  background: var(--notice); border: 1px solid var(--notice-line); border-radius: var(--radius);
  padding: 12px 16px; font-size: 14px; color: var(--ink-soft); margin-bottom: 22px;
}
.chip {
  display: inline-flex; align-items: center; gap: 8px; width: fit-content; max-width: 100%;
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-size: 14px; color: var(--ink-soft);
  background: var(--cream);
}
.chip::before { content: "→"; color: var(--muted); }

/* 對話視窗 */
/* 視窗本身不捲動，改由內容區捲動，捲軸才不會把右側圓角蓋成直角 */
.dialog {
  border: 0; border-radius: 16px; padding: 36px 40px; width: min(92vw, 640px); max-height: 88dvh;
  box-shadow: var(--shadow); color: var(--ink); background: #fff; overflow: hidden;
}
.dialog[open] { display: flex; flex-direction: column; }
.dialog-scroll { overflow-y: auto; min-height: 0; flex: 1 1 auto; padding-right: 6px; margin-right: -6px; }
.dialog::backdrop { background: rgba(43, 42, 39, 0.45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.dialog-head h2 { font-family: var(--serif); font-size: 28px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 14px; margin-top: 30px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

@media (max-width: 640px) {
  .dialog { padding: 26px 20px; width: 94vw; }
  .dialog-head h2 { font-size: 22px; }
  .dialog-actions { justify-content: stretch; }
  .dialog-actions button { flex: 1; }
}

/* 提單結果與需求單卡片共用的單號排版。 */
.ticket-id { font-variant-numeric: tabular-nums; }
