/* 與車友首頁共用日系編輯感；工作站維持黑體與清楚的操作狀態。 */

:root {
  --bg:        #171916;
  --surface:   #1b1d1a;
  --surface-2: #252823;
  --border:    #62675c;
  --line:      var(--border);
  --text:      #f2f0e9;
  --muted:     #cacbc4;

  --primary:    #f97316;  /* 橘：主操作 */
  --primary-2:  #ea670c;
  --success:    #4ade80;  /* 已報名 / 成功 */
  --success-bg: #14331f;
  --danger:     #f87171;  /* 未報名 / 阻擋 */
  --danger-bg:  #3a1717;

  --link-shadow: 0 1px 3px #000, 0 0 8px rgba(0, 0, 0, .7);
  --scheme: dark;
  --panel-bg: rgba(25, 28, 24, .97);
  --chrome-bg: rgba(25, 28, 24, .985);
  --topbar-border: #62675c;
  --field-border: #7c8075;
  --placeholder: #cacbc4;
  --accent-ink: #f97316;
  --danger-text: #ffb4b4;
  --success-text: #9be8b4;
  --success-action: #4ade80;
  --danger-action: #f87171;
  --overlay-top: rgba(18, 23, 19, .94);
  --overlay-bottom: rgba(18, 23, 19, .70);
  /* Keep these shape tokens aligned with friend-qr-portal/web/style.css. */
  --radius: 12px;
  --radius-flat: 0;
  --radius-circle: 50%;
  --gap: 16px;
  --font: -apple-system, "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  --mono: "SF Mono", "Roboto Mono", ui-monospace, Menlo, monospace;
}

/* Follow the device appearance without changing the background image. */
@media (prefers-color-scheme: light) {
  :root {
    --link-shadow: 0 1px 2px #fff, 0 0 8px rgba(255, 255, 255, .9);
    --scheme: light;
    --bg: #f4f2ee;
    --surface: #faf9f6;
    --surface-2: #eeece5;
    --border: #8a8e83;
    --text: #232421;
    --muted: #535650;
    --panel-bg: rgba(245, 243, 237, .97);
    --chrome-bg: rgba(245, 243, 237, .985);
    --topbar-border: #8a8e83;
    --field-border: #777a72;
    --placeholder: #535650;
    --accent-ink: #a34308;
    --success: #176b3c;
    --success-bg: #e8f5ec;
    --danger: #b52525;
    --danger-bg: #fcecec;
    --danger-text: #9c2020;
    --success-text: #165f36;
    --overlay-top: rgba(247, 245, 240, .94);
    --overlay-bottom: rgba(247, 245, 240, .70);
  }
}

* { box-sizing: border-box; }

html {
  margin: 0;
  background: var(--bg);
  color-scheme: var(--scheme);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

/* 背景滿版，工作區限制閱讀寬度，內容由上往下捲動。 */
body {
  margin: 0 auto;
  max-width: none;
  min-height: 100dvh;
  background: transparent;
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(180deg, var(--overlay-top), var(--overlay-bottom)),
    url('./event-background.jpg') center / cover no-repeat;
}

/* 頂列 */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 78px;
  padding: 20px 26px;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid var(--topbar-border);
  background: var(--chrome-bg);
}


.operator-bar {
  display: flex;
  justify-content: flex-end;
  padding: 8px 26px 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}
.operator-bar .who {
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--chrome-bg);
  color: var(--muted);
  font: 400 12px var(--font);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 待送佇列指示（離線/失敗暫存的寫入數）*/
.pending {
  font-size: 11px; font-weight: 700; color: #1a1a1a;
  background: var(--primary); border-radius: var(--radius); padding: 3px 9px;
}
.pending.synced { background: var(--success-action); color: #06230f; }

/* 主容器（寬度由 body 控成手機寬）*/
main {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 26px 26px 36px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

h1.title { font-size: 24px; line-height: 1.3; margin: 4px 0 12px; }
.subtitle { color: var(--muted); font-size: 14px; margin: 0; }
h1.event-name {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: 25px;
  line-height: 1.08;
  font-weight: 600;
  display: flex;
  justify-content: center;
  white-space: nowrap;
}
.event-letters {
  display: flex;
  align-items: baseline;
  gap: 6px;
  transform-origin: center;
}
.mirror-c { display: inline-block; transform: scaleX(-1); transform-origin: center; }
.screen-label {
  margin: 0 0 24px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.3;
  font-weight: 600;
  text-align: left;
}
/* Plain-text links stay legible over the existing photograph. */
.help-link {
  display: block;
  padding: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 4px;
  align-self: center;
  text-shadow: var(--link-shadow);
  border-radius: var(--radius-flat);
}
.help-copy { color: var(--muted); font-size: 15px; line-height: 1.7; margin: 0; }
.help-list { color: var(--muted); font-size: 15px; line-height: 1.7; margin: 0; padding-left: 22px; }
.help-list li + li { margin-top: 8px; }
.help-card-title { margin: 0 0 12px; font-size: 19px; }

.panel {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-bg);
}
.panel > .subtitle { line-height: 1.6; margin-bottom: 18px; }
.panel > .eyebrow + .title { margin-top: 4px; }
.panel > .card,
.panel > .banner { margin-top: 16px; }
.panel > .big-check { margin-top: 20px; }
.panel > .plate-display { margin-top: 14px; }
.panel > .btn:not(.btn-link) { margin-top: 12px; }
.panel > .btn-link { margin-top: 8px; }
.home-actions { display: grid; gap: 12px; margin-top: 24px; }
.home-actions .btn { display: block; text-align: center; text-decoration: none; }
.home-actions .btn:visited { color: inherit; }
.home-actions .btn-primary:visited { color: #1a1a1a; }
.eyebrow {
  margin: 0;
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.6px;
}
.entry-form { text-align: left; }
.entry-form label {
  display: block;
  margin: 18px 0 7px;
  font-weight: 700;
}
.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 17px var(--font);
}
.form-input::placeholder,
.plate-input::placeholder { color: var(--placeholder); }
.form-input:focus { border-color: var(--accent-ink); }
.entry-form .btn { margin-top: 24px; }
.form-status { margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.form-status:empty { display: none; }

/* 車牌大字框 */
.plate-display {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  padding: 18px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.success-plate {
  margin: 10px 0 0;
  padding: 4px;
  border: 0;
  font-size: 26px;
}

/* 手打輸入框 */
.plate-input {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-transform: uppercase;
}
.plate-input:focus { border-color: var(--accent-ink); }
#screen-input .plate-input { margin-top: 12px; }
#screen-input .btn { margin-top: 12px; }

/* 按鈕 */
.btn {
  font-size: 18px;
  font-weight: 700;
  min-height: 56px;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  width: 100%;
  font-family: var(--font);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #1a1a1a; }
.btn-success { background: var(--success-action); color: #06230f; }
.btn-danger  { background: var(--danger-action);  color: #2a0a0a; }
.btn-ghost   { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-link {
  background: none; border: none; border-radius: var(--radius-flat); color: var(--accent-ink);
  font-size: 15px; padding: 8px; cursor: pointer; width: 100%; min-height: 44px;
}

:is(a, button, input):focus-visible {
  outline: 2px solid var(--primary-2);
  outline-offset: 3px;
}
#review-loading:empty { margin: 0; }
.screen-label[tabindex="-1"]:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 3px; }

/* 狀態卡 */
.card {
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.card.ok {
  border-color: var(--success);
  background: var(--success-bg);
}
.card.bad {
  border-color: var(--danger);
  background: var(--danger-bg);
}
.card .head { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.card.ok  .head { color: var(--success); }
.card.bad .head { color: var(--danger); }

/* 欄位列 */
.field { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 6px 0; font-size: 15px; }
.field .k { color: var(--muted); flex-shrink: 0; }
.field .v { font-weight: 600; min-width: 0; overflow-wrap: anywhere; text-align: right; }

/* 單車唯讀明細：長暱稱與識別碼不撐出手機畫面。 */
.query-detail .field { gap: 12px; align-items: flex-start; }
.query-detail .field .k { flex: 0 0 96px; }
.query-detail .field .v { min-width: 0; text-align: right; overflow-wrap: anywhere; }
.query-meta { line-height: 1.7; }
.query-error { color: var(--danger-text); }

/* 結果大勾 */
.big-check {
  width: 96px; height: 96px; border-radius: var(--radius-circle);
  border: 4px solid var(--success);
  display: grid; place-items: center; margin: 8px auto;
  color: var(--success); font-size: 52px; font-weight: 700;
}

/* 雜項 */
.center { text-align: center; }
.muted { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; background: var(--chrome-bg); }
noscript p { padding: 16px; border-radius: var(--radius); background: var(--bg); }

/* 提示橫條（錯誤 / 狀態）*/
.banner {
  border-radius: var(--radius); padding: 12px 14px; font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.banner.err { border-color: var(--danger); color: var(--danger-text); }
.banner.ok  { border-color: var(--success); color: var(--success-text); }

/* 工作站切換器 */
.station-switch {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--border);
}
.station-switch button {
  flex: 1;
  min-height: 44px;
  padding: 10px 6px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  border-radius: var(--radius-flat);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
}
.station-switch button.active {
  color: var(--text);
  border-bottom-color: var(--primary);
  font-weight: 700;
  cursor: default;
}

/* 相機取景 */
.cam-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.cam-wrap video { width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; display: block; }
.cam-frame {
  position: absolute;
  left: 12%; right: 8%; top: 38%; height: 24%;
  border: 3px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: 0 0 0 9999px rgba(0,0,0,.35);
  pointer-events: none;
}
.ocr-guide { top: 41%; height: 18%; }
.crop-height { width: 100%; accent-color: var(--accent-ink); margin: 12px 0; }
.ocr-preview { display: block; width: 100%; height: auto; margin: 12px 0; border-radius: var(--radius); }

#debug-roi {
  width: 100%;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  margin: 6px 0;
  image-rendering: pixelated;
}

pre.dump {
  background: #000; color: #d6d6d6; font-family: var(--mono); font-size: 12px;
  padding: 14px; border-radius: var(--radius); overflow-x: auto; white-space: pre-wrap;
  word-break: break-all; border: 1px solid var(--border);
}

@media (hover: hover) {
  .btn-primary:hover:not(:disabled) { background: var(--primary-2); }
  .btn-ghost:hover:not(:disabled) { border-color: var(--accent-ink); }
}

@media (max-width: 360px) {
  main { padding-inline: 14px; }
  .panel { padding: 18px; }
}
