:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #5b6270;
  --line: #e3e6ea;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #191d24;
    --ink: #e8eaee;
    --muted: #a7b0bd;
    --line: #2b313a;
    --accent: #7c74ff;
    --accent-ink: #101014;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC",
        "PingFang TC", "Microsoft JhengHei", sans-serif;
}

.skip {
  position: absolute;
  left: -9999px;
}

/* 複製後備方案用的隱藏 textarea */
.sr-only {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.skip:focus {
  left: 12px;
  top: 12px;
  z-index: 20;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 18px 64px;
}

/* ── 標題區 ── */
.head { margin-bottom: 22px; }

.eyebrow {
  margin: 0 0 4px;
  font-size: 13px;
  letter-spacing: .08em;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: -.01em;
}

.lede {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14.5px;
}

/* ── 控制列 ── */
.ctl {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.field-style {
  flex: 0 0 9em;
}

.field-len {
  flex: 0 0 9em;
}

.field > span {
  font-size: 12.5px;
  color: var(--muted);
}

select, input {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
}

select:focus-visible, input:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── 按鈕 ── */
.btn {
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: translateY(1px); }

.btn-main {
  background: var(--accent);
  color: var(--accent-ink);
  padding-inline: 22px;
  box-shadow: var(--shadow);
}

.btn-copy {
  background: transparent;
  color: var(--accent);
  border-color: var(--line);
  font-size: 13.5px;
  min-height: 36px;
  padding: 6px 12px;
}

.btn-copy:hover { border-color: var(--accent); }

.btn-ghost {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
  font-weight: 500;
  min-height: 44px;
}

.btn-ghost:hover { border-color: var(--accent); }

.btn.done {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
}

/* ── 卡片 ── */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.card h2 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--muted);
  text-transform: uppercase;
}

.subject {
  margin: 0;
  font-size: 20px;
  line-height: 1.5;
  font-weight: 600;
  word-break: break-word;
}

.meta {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.body {
  margin: 0;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 15px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}

/* ── 頁尾 ── */
.foot {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.seedrow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.seedrow label {
  font-size: 12.5px;
  color: var(--muted);
}

.seedrow input {
  width: 110px;
  min-height: 40px;
  padding: 6px 10px;
  font-variant-numeric: tabular-nums;
}

.seedrow .btn { min-height: 40px; padding: 6px 14px; }

.hint, .note {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* ── 手機底部固定操作列 ── */
.actionbar {
  display: none;
}

kbd {
  font: inherit;
  font-size: 12px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--bg);
}

/* ── 提示訊息 ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  background: #16181d;
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 30;
}

@media (prefers-color-scheme: dark) {
  .toast { background: #e8eaee; color: #101014; }
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ── 手機 ── */
@media (max-width: 560px) {
  .wrap { padding: 20px 14px 124px; }
  h1 { font-size: 25px; }
  .ctl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: end;
  }
  .ctl .field:first-child { grid-column: 1 / -1; }
  .field-style, .field-len { min-width: 0; }
  .ctl .btn-main { display: none; }       /* 換一封改由底部固定列負責 */
  .subject { font-size: 18px; }
  .seedrow { flex-wrap: wrap; }
  .btn-copy { min-height: 44px; padding: 8px 14px; }
  .hint { display: none; }                 /* 手機沒有實體鍵盤 */
  .note { padding-bottom: 4px; }

  .actionbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    display: flex;
    gap: 8px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 18px rgba(16, 24, 40, .06);
  }

  .actionbar .btn {
    flex: 1;
    min-height: 50px;
    font-size: 15px;
  }

  .actionbar .btn-main { flex: 1.25; }

  .actionbar .ab-copy {
    font-size: 14px;
    padding-inline: 6px;
  }

  /* 提示訊息要浮在固定列上方，不然會蓋住中間那顆按鈕 */
  .toast {
    bottom: calc(86px + env(safe-area-inset-bottom));
  }
}
