/* 工具箱 box.bfsuapa.com — shares the association's tokens so it sits beside Hub and bfsuapa.com.
   Square panels, 1px --line rules, sparse accents, transform/opacity motion only. */

:root {
  --paper: #fff;
  --ink: #121315;
  --muted: #65676c;
  --line: color-mix(in srgb, #121315 16%, transparent);
  --surface: color-mix(in srgb, #121315 4%, #fff);
  --accent-red: #b84f42;
  --accent-blue: #2a5b9e;
  --accent-green: #277158;
  --accent-gold: #a57218;
  --on-accent: #fff;
  --focus: #1f5aa8;
  --radius: 10px;
  --motion: 200ms cubic-bezier(0.22, 1, 0.36, 1);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --gutter: clamp(1rem, 4vw, 2rem);
  --font-cjk: 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #14161a;
    --ink: #eef0f3;
    --muted: #a2a7ae;
    --surface: color-mix(in srgb, #eef0f3 7%, #14161a);
    --line: color-mix(in srgb, #eef0f3 18%, transparent);
    --accent-red: #e08c7f;
    --accent-blue: #8fb2e0;
    --accent-green: #7fc4a8;
    --accent-gold: #d9b26a;
    --on-accent: #14161a;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --paper: #14161a;
  --ink: #eef0f3;
  --muted: #a2a7ae;
  --surface: color-mix(in srgb, #eef0f3 7%, #14161a);
  --line: color-mix(in srgb, #eef0f3 18%, transparent);
  --accent-red: #e08c7f;
  --accent-blue: #8fb2e0;
  --accent-green: #7fc4a8;
  --accent-gold: #d9b26a;
  --on-accent: #14161a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-cjk);
  font-size: 16px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.75rem; letter-spacing: -0.01em; text-wrap: balance; }
p { margin: 0 0 0.75rem; text-wrap: pretty; }
a { color: var(--accent-blue); text-underline-offset: 0.18em; }
a:hover { color: var(--accent-red); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* Header and footer ------------------------------------------------------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 68rem; width: calc(100% - 2 * var(--gutter)); margin: 0 auto;
  min-height: 64px; border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--ink); text-decoration: none; min-height: 44px; }
.brand:hover { color: var(--ink); }
.brand img { width: 48px; height: 27px; object-fit: contain; }
.brand strong { font-size: 1.05rem; letter-spacing: 0.02em; }
.brand span { color: var(--muted); font-size: 0.8rem; padding-left: 0.6rem; border-left: 1px solid var(--line); }
.header-actions { display: flex; align-items: center; gap: 0.25rem; }
.icon-button {
  display: inline-grid; place-items: center; width: 44px; height: 44px; min-height: 44px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer;
}
.icon-button:hover { background: var(--surface); }
.icon-button svg { width: 20px; height: 20px; }
.theme-icon-dark { display: none; }
:root[data-theme='dark'] .theme-icon-light { display: none; }
:root[data-theme='dark'] .theme-icon-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .theme-icon-light { display: none; }
  :root:not([data-theme='light']) .theme-icon-dark { display: block; }
}
.site-footer {
  max-width: 68rem; width: calc(100% - 2 * var(--gutter)); margin: auto auto 0;
  padding: 1.5rem 0 2rem; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem;
  color: var(--muted); font-size: 0.8rem;
}
.site-footer a { color: var(--muted); }

.page { max-width: 68rem; width: calc(100% - 2 * var(--gutter)); margin: 0 auto; padding: 0 0 3.5rem; }
.page-intro { padding: 3rem 0 2rem; }
.page-intro h1 { font-size: clamp(32px, 4vw, 44px); letter-spacing: -0.035em; margin: 0 0 0.75rem; }
.page-intro p { color: var(--muted); margin: 0; max-width: 36rem; }
.back-link { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 44px; color: var(--muted); text-decoration: none; font-size: 0.9rem; margin-top: 1rem; }
.back-link:hover { color: var(--accent-red); }
.tool-intro { padding: 0.5rem 0 1.75rem; }
.tool-intro h1 { font-size: clamp(28px, 3.4vw, 38px); letter-spacing: -0.03em; margin: 0.25rem 0 0.4rem; }
.tool-intro p { color: var(--muted); margin: 0; }

/* Home tiles -------------------------------------------------------------- */
.tool-section { margin-top: 2.25rem; }
.tool-section h2 { font-size: 0.8rem; font-weight: 650; color: var(--muted); letter-spacing: 0.08em; margin: 0 0 0.75rem; }
.tool-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tool-tile {
  position: relative; display: block; padding: 20px 20px 18px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); text-decoration: none;
  transition: transform var(--motion), border-color var(--motion);
}
.tool-tile:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 40%, transparent); transform: translateY(-2px); }
.tool-tile:active { transform: translateY(0); }
.tool-tile svg { display: block; width: 26px; height: 26px; color: var(--accent-red); margin-bottom: 16px; }
.tool-tile strong { display: block; font-size: 1.05rem; margin-bottom: 4px; }
.tool-tile span { display: block; font-size: 0.8rem; color: var(--muted); line-height: 1.6; }
.recent-row { display: flex; flex-wrap: wrap; gap: 8px; }
.recent-row a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px; background: var(--surface);
  color: var(--ink); text-decoration: none; font-size: 0.9rem;
}
.recent-row a:hover { color: var(--accent-red); }

/* Controls ---------------------------------------------------------------- */
button, .button {
  font: inherit; min-height: 44px; padding: 0.5rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; text-decoration: none;
  transition: background var(--motion), border-color var(--motion), transform var(--motion), opacity var(--motion);
  touch-action: manipulation;
}
button:hover, .button:hover { background: color-mix(in srgb, var(--ink) 9%, var(--paper)); color: var(--ink); }
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: default; transform: none; }
.button-primary { background: var(--accent-red); border-color: var(--accent-red); color: var(--on-accent); font-weight: 700; }
.button-primary:hover { background: color-mix(in srgb, #000 12%, var(--accent-red)); color: var(--on-accent); }
.button-big { min-height: 56px; padding: 0.75rem 2rem; font-size: 1.1rem; min-width: 10rem; }
.button-quiet { background: transparent; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; }
input[type='text'], input[type='number'], select, textarea {
  font: inherit; width: 100%; min-height: 44px; padding: 0.5rem 0.75rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--paper); color: var(--ink);
}
textarea { min-height: 9rem; resize: vertical; line-height: 1.6; }
.field { margin-bottom: 1rem; }
.hint { color: var(--muted); font-size: 0.8rem; font-weight: 400; margin-top: 0.3rem; }
.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; min-height: 44px; margin: 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent-red); margin: 0; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.segmented button { border-radius: 0; background: transparent; font-size: 0.9rem; min-width: 44px; }
.segmented button[aria-pressed='true'] { color: var(--accent-red); border-color: var(--accent-red); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); }
.stepper button { border: 0; background: transparent; width: 44px; padding: 0; font-size: 1.2rem; }
.stepper output { min-width: 2.5rem; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Tool layout ------------------------------------------------------------- */
.tool-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 20rem); gap: 2rem; align-items: start; }
.panel { border: 1px solid var(--line); background: var(--paper); padding: 1.5rem; }
.panel-accent { border-top: 3px solid var(--accent-red); }
.panel h2 { font-size: 1rem; margin: 0 0 1rem; }
.stage { display: grid; justify-items: center; gap: 1.5rem; padding: 2rem 1.5rem; }
.result {
  min-height: 4.5rem; width: 100%; text-align: center; display: grid; place-items: center;
  border-top: 1px solid var(--line); padding-top: 1.25rem;
}
.result-label { color: var(--muted); font-size: 0.8rem; font-weight: 650; letter-spacing: 0.06em; }
.result-value { font-size: clamp(1.75rem, 5vw, 2.6rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.pop { animation: pop 420ms var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.96); } to { opacity: 1; transform: none; } }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { border-bottom: 1px solid var(--line); padding: 0.6rem 0; display: flex; justify-content: space-between; gap: 1rem; }
.list-plain li:first-child { border-top: 1px solid var(--line); }
.empty-state { margin: 0; padding: 1.5rem; text-align: center; color: var(--muted); border: 1px dashed var(--line); font-size: 0.9rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 0.6rem 1rem; border-radius: var(--radius); font-size: 0.9rem;
  transition: transform var(--motion), opacity var(--motion);
}
.toast.is-on { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 900px) {
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-layout { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .brand span { display: none; }
  .page-intro { padding: 2rem 0 1.25rem; }
  .tool-tile { padding: 16px; }
  .tool-tile svg { margin-bottom: 12px; }
  .panel { padding: 1.1rem; }
  .stage { padding: 1.25rem 0.75rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem !important; }
.result-value.is-placeholder { font-size: 1rem; font-weight: 400; color: var(--muted); letter-spacing: 0; }
@media (max-width: 900px) { .settings-first > aside { order: -1; } }

/* Join by code on the home page -------------------------------------------- */
.join-code { margin-top: 0.5rem; max-width: 22rem; }
.join-code-row { display: flex; gap: 8px; }
.join-code input { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 700; font-variant-numeric: tabular-nums; }
.join-code input::placeholder { letter-spacing: 0; font-weight: 400; text-transform: none; }

/* Dialogs ------------------------------------------------------------------ */
dialog { border: 1px solid var(--line); padding: 0; background: var(--paper); color: var(--ink); max-width: min(26rem, calc(100vw - 32px)); width: 100%; }
dialog::backdrop { background: color-mix(in srgb, #000 45%, transparent); }
.dialog-close { position: absolute; top: 8px; right: 8px; z-index: 1; }
