/* ===== 字型 ===== */
@font-face {
  font-family: "jf-openhuninn";
  src: url("/fonts/huninn.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ===== 調色盤 ===== */
:root {
  --bg: #ffffff;
  --bg-alt: #f4f4f4;
  --paper: #ffffff;
  --input-bg: #fafafa;
  --ink: #1a1a1a;
  --ink-soft: #555555;
  --ink-faint: #888888;
  --rule: #e0e0e0;
  --rule-strong: #bfbfbf;
  --accent: #b8472b;
  --accent-dark: #8e3318;
  --accent-tint: #f5dcd3;
  --good: #4a6b3a;
  --warn: #8a5a14;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }

/* ===== Typography ===== */
:root {
  --font-sans: "jf-openhuninn", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  --font-serif: "jf-openhuninn", Georgia, "PingFang TC", "Noto Sans TC",
    sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, "Cascadia Mono",
    Consolas, "Microsoft JhengHei", monospace;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: normal;
  letter-spacing: 0;
  margin: 0;
}

h1 { font-size: 30px; line-height: 1.2; }
h2 { font-size: 21px; line-height: 1.3; }
h3 { font-size: 17px; line-height: 1.35; font-weight: 500; }

p { margin: 0 0 0.8em; }

/* ===== Layout ===== */
.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 24px 56px;
}

.site-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 32px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-serif);
  font-style: normal;
  font-size: 26px;
  font-weight: 500;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.wordmark-img {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  display: block;
}

.site-nav {
  display: flex;
  gap: 18px;
  font-size: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.site-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color 0.15s, border-color 0.15s;
}

.site-nav a:hover {
  color: var(--ink);
}

.site-nav a.current {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.site-foot {
  margin-top: 56px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--ink-faint);
  text-align: center;
}

.site-foot a {
  color: var(--ink-faint);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
}

.site-foot a:hover {
  color: var(--ink);
}

/* ===== 首頁 tool list ===== */
.tagline {
  font-family: var(--font-serif);
  font-size: 19px;
  color: var(--ink-soft);
  margin: 8px 0 36px;
}

.tool-list {
  display: grid;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}

.tool-list a {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--paper);
  padding: 22px 24px;
  transition: background 0.15s;
}

.tool-list a:hover {
  background: var(--accent-tint);
}

.tool-list h2 {
  margin-bottom: 4px;
}

.tool-list h2 .en {
  font-family: var(--font-serif);
  font-style: normal;
  font-weight: 400;
  color: var(--ink-faint);
  font-size: 16px;
  margin-left: 10px;
}

.tool-list p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14.5px;
}

/* ===== 工具頁共用 ===== */
.tool-head {
  margin-bottom: 22px;
}

.tool-head h1 .en {
  font-family: var(--font-serif);
  font-style: normal;
  font-weight: 400;
  color: var(--ink-faint);
  font-size: 18px;
  margin-left: 12px;
  letter-spacing: 0;
}

.tool-head .hint {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 14.5px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 20px;
}

.panel + .panel {
  margin-top: 18px;
}

/* ===== Form controls ===== */
.input,
textarea,
select {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ink);
  background: var(--input-bg);
  border: 1px solid var(--rule);
  padding: 8px 11px;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  background: #fff;
}

.items-input {
  display: block;
  width: 100%;
  min-height: 280px;
  font-family: var(--font-mono);
  font-size: 14.5px;
  line-height: 1.65;
  padding: 13px 15px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 14px;
}

.field-label {
  color: var(--ink-soft);
  font-size: 13.5px;
}

/* ===== Buttons ===== */
.btn {
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 500;
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  letter-spacing: 0.01em;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.btn-secondary {
  background: var(--paper);
  border-color: var(--rule-strong);
  color: var(--ink);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-alt);
}

.btn-link {
  color: var(--accent);
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--accent-tint);
}

.btn-link:hover:not(:disabled) {
  color: var(--accent-dark);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.actions .meta {
  color: var(--ink-faint);
  font-size: 13px;
  margin-left: auto;
}

/* ===== /draw 結果 ===== */
.draw-result {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}

.draw-result li {
  background: var(--paper);
  padding: 11px 16px;
  display: flex;
  gap: 14px;
  font-size: 15px;
}

.draw-result li .idx {
  color: var(--accent);
  font-family: var(--font-serif);
  font-style: normal;
  font-weight: 500;
  min-width: 28px;
}

/* ===== /wheel ===== */
.wheel-stage {
  position: relative;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1;
  margin: 12px auto 18px;
}

.wheel-stage svg {
  width: 100%;
  height: 100%;
  display: block;
  transition: transform 4.5s cubic-bezier(0.15, 0.85, 0.25, 1);
}

.wheel-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 16px solid var(--accent-dark);
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.08));
}

.wheel-winner {
  text-align: center;
  font-family: var(--font-serif);
  font-size: 22px;
  margin: 8px 0 0;
  min-height: 30px;
  color: var(--ink);
}

.wheel-winner.empty {
  color: var(--ink-faint);
  font-style: normal;
}

/* ===== /dice ===== */
.dice-controls {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 14px;
}

.dice-display {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 24px 12px;
  min-height: 100px;
  background: var(--bg-alt);
  border: 1px solid var(--rule);
}

.die {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--input-bg);
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 600;
  color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}

.die.rolling {
  color: var(--ink-faint);
}

.dice-total {
  text-align: center;
  margin: 12px 0 0;
  font-family: var(--font-serif);
  font-size: 17px;
  color: var(--ink-soft);
}

.dice-total .num {
  color: var(--accent);
  font-weight: 600;
  font-size: 20px;
}

/* ===== /timer ===== */
.timer-display {
  font-family: var(--font-mono);
  font-size: 64px;
  font-weight: 500;
  text-align: center;
  color: var(--ink);
  padding: 28px 12px;
  background: var(--bg-alt);
  border: 1px solid var(--rule);
  letter-spacing: 0.03em;
  margin-bottom: 18px;
  line-height: 1.1;
}

.timer-display .timer-sep {
  color: var(--accent);
  margin: 0 4px;
}

.timer-display.finished {
  background: var(--accent-tint);
  color: var(--accent-dark);
}

.timer-inputs {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.timer-inputs label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
}

.timer-inputs input {
  width: 84px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 18px;
  padding: 8px;
}

.timer-presets {
  display: flex;
  gap: 6px 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
  font-size: 14px;
}

/* ===== /counter ===== */
.counter-display {
  font-family: var(--font-serif);
  font-size: 110px;
  font-weight: 500;
  text-align: center;
  color: var(--accent);
  padding: 32px 12px 14px;
  line-height: 1;
}

.counter-actions {
  justify-content: center;
  gap: 14px;
  margin-top: 0;
}

.counter-actions .btn {
  padding: 11px 26px;
  font-size: 16px;
  min-width: 90px;
}

/* ===== /clock ===== */
.clock-block {
  background: var(--paper);
  padding: 16px 20px 18px;
  position: relative;
  text-align: center;
}

.clock-block.local {
  padding: 24px 20px;
  border: 1px solid var(--rule);
}

.clock-label {
  font-family: var(--font-serif);
  font-style: normal;
  font-size: 14px;
  color: var(--ink-faint);
  margin-bottom: 4px;
}

.clock-time {
  font-family: var(--font-mono);
  font-size: 38px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink);
  line-height: 1.1;
}

.clock-block.local .clock-time {
  font-size: 60px;
}

.clock-date {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.clock-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin-bottom: 16px;
}

.clock-list:empty {
  display: none;
}

.clock-remove {
  position: absolute;
  top: 5px;
  right: 8px;
  font-size: 18px;
  padding: 0 6px;
  background: transparent;
  border: 0;
  color: var(--ink-faint);
  cursor: pointer;
  line-height: 1;
}

.clock-remove:hover {
  color: var(--accent);
}

/* ===== 關於這個工具（SEO 內容區）===== */
.about {
  margin-top: 36px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 14.5px;
}

.about h2 {
  color: var(--ink);
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 17px;
  margin: 18px 0 6px;
}

.about h2:first-child {
  margin-top: 0;
}

.about p {
  margin: 0 0 0.7em;
  line-height: 1.7;
}

/* ===== Utility ===== */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ===== 響應式 ===== */
@media (max-width: 520px) {
  .shell { padding: 20px 18px 40px; }
  h1 { font-size: 25px; }
  .wordmark { font-size: 22px; }
  .wordmark-img { width: 60px; height: 60px; }
  .site-nav { gap: 14px; font-size: 14.5px; }
  .items-input { min-height: 240px; }
  .die { width: 52px; height: 52px; font-size: 24px; box-shadow: 2px 2px 0 var(--ink); }
  .wheel-stage { max-width: 300px; }
}
