@charset "utf-8";

/* Design tokens: the application always renders the resolved system or user theme. */
:root {
  color-scheme: light;
  --bg: #f5f1ea;
  --surface: #fffdf9;
  --surface-elevated: #ffffff;
  --text: #20242a;
  --text-muted: #64686f;
  --border: rgba(54, 45, 39, .13);
  --accent: #a43b4d;
  --accent-strong: #81283a;
  --accent-soft: #f4e2e5;
  --gold: #b88a4a;
  --gold-ink: #78552a;
  --term-color: #006b75;
  --term-glow: rgba(0, 133, 145, .16);
  --button-on-accent: #fff8f6;
  --success: #457260;
  --warning: #96653a;
  --soft: #eee9e1;
  --shadow-1: 0 3px 10px rgba(54, 45, 39, .035), 0 1px 2px rgba(54, 45, 39, .04);
  --shadow-2: 0 16px 40px rgba(54, 45, 39, .07), 0 3px 9px rgba(54, 45, 39, .045);
  --shadow-3: 0 28px 72px rgba(54, 45, 39, .09), 0 5px 15px rgba(54, 45, 39, .06);
  --paper: var(--surface);
  --ink: var(--text);
  --muted: var(--text-muted);
  --line: var(--border);
  --accent-light: var(--accent-soft);
  --green: var(--success);
  font-family: "BIZ UDPGothic", "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  font-optical-sizing: auto;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101216;
  --surface: #171a20;
  --surface-elevated: #1e2229;
  --text: #f2eee8;
  --text-muted: #a9adb5;
  --border: rgba(255, 255, 255, .105);
  --accent: #d45d72;
  --accent-strong: #ea7185;
  --accent-soft: rgba(212, 93, 114, .15);
  --gold: #d0a461;
  --gold-ink: #d0a461;
  --term-color: #72d5dc;
  --term-glow: rgba(0, 133, 145, .16);
  --button-on-accent: #101216;
  --success: #89b59e;
  --warning: #d2a070;
  --soft: #232730;
  --shadow-1: 0 3px 10px rgba(0, 0, 0, .18), 0 1px 2px rgba(0, 0, 0, .22);
  --shadow-2: 0 18px 44px rgba(0, 0, 0, .28), 0 3px 10px rgba(0, 0, 0, .2);
  --shadow-3: 0 30px 78px rgba(0, 0, 0, .34), 0 6px 18px rgba(0, 0, 0, .2);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  transition: color .2s ease, background-color .2s ease;
}
button, input, textarea, select { font: inherit; }
button { color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
summary:focus-visible, [tabindex]:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 72%, white);
  outline-offset: 3px;
}
::selection { color: var(--text); background: var(--accent-soft); }
.term-display { color: var(--term-color); font-weight: 760; text-shadow: 0 0 18px var(--term-glow), 0 7px 26px color-mix(in srgb, var(--term-glow) 42%, transparent); transition: color .18s ease, text-shadow .18s ease; }
.term-label { display: block; margin: 0 0 5px; color: var(--text-muted); font-size: 10px; font-weight: 700; letter-spacing: .12em; line-height: 1.4; }

/* Header and navigation */
.app-header {
  position: sticky;
  z-index: 12;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  max-width: 1560px;
  margin: 0 auto;
  padding: 10px clamp(20px, 4vw, 54px);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; flex: 0 0 auto; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  border-radius: 13px;
  background: linear-gradient(145deg, var(--accent-strong), var(--accent));
  color: #fff7f3;
  box-shadow: 0 5px 14px color-mix(in srgb, var(--accent) 22%, transparent), inset 0 1px rgba(255,255,255,.17);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -.05em;
}
.brand strong { display: block; font-size: 15px; letter-spacing: .025em; line-height: 1.3; }
.brand small { display: block; margin-top: 3px; color: var(--text-muted); font-size: 11px; }
.main-nav { display: flex; align-items: center; gap: 4px; }
.nav-button {
  position: relative;
  min-height: 44px;
  padding: 9px 13px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  transition: color .18s ease, background .18s ease;
}
.nav-button:hover { color: var(--text); background: var(--soft); }
.nav-button.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow-1); }
.nav-button.active::after { position: absolute; right: 13px; bottom: 4px; left: 13px; height: 1px; background: var(--gold); content: ""; }
.appearance-control { position: relative; flex: 0 0 auto; }
.appearance-control > summary { display: grid; min-width: 60px; min-height: 42px; place-items: center; padding: 6px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text-muted); font-size: 12px; font-weight: 650; cursor: pointer; list-style: none; }
.appearance-control > summary::-webkit-details-marker { display: none; }
.appearance-control[open] > summary { border-color: color-mix(in srgb, var(--gold) 54%, var(--border)); color: var(--text); }
.appearance-menu { position: absolute; z-index: 16; top: calc(100% + 8px); right: 0; display: grid; width: min(280px, calc(100vw - 24px)); gap: 13px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-elevated); box-shadow: var(--shadow-2); }
.appearance-menu label { display: grid; gap: 6px; color: var(--text-muted); font-size: 12px; font-weight: 650; }
.appearance-menu select { width: 100%; min-height: 44px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 14px; }
.appearance-preview { display: grid; justify-items: start; margin: 0; padding-top: 12px; border-top: 1px solid var(--border); }
.appearance-preview .term-display { font-size: 20px; }
.mobile-nav { display: none; }

/* Shared controls and surfaces */
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: .16em; }
.muted { margin: 8px 0 0; color: var(--text-muted); font-size: 13px; }
.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 9px 15px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  text-decoration: none;
  transition: color .18s ease, background-color .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.button:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--gold) 50%, var(--border)); box-shadow: var(--shadow-2); }
.button:active { transform: translateY(0) scale(.985); }
.button:disabled { opacity: .48; cursor: not-allowed; transform: none; }
.button-primary { border-color: var(--accent); background: linear-gradient(145deg, var(--accent-strong), var(--accent)); color: var(--button-on-accent); box-shadow: 0 5px 15px color-mix(in srgb, var(--accent) 23%, transparent), inset 0 1px rgba(255,255,255,.14); }
.button-primary:hover { border-color: var(--accent-strong); background: var(--accent-strong); }
.button-secondary { background: var(--surface-elevated); }
.button-quiet { border-color: transparent; background: transparent; color: var(--text-muted); box-shadow: none; }
.button-quiet:hover { border-color: var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.button-danger-quiet { border-color: color-mix(in srgb, var(--accent) 34%, var(--border)); background: transparent; color: var(--accent); box-shadow: none; }
.button-large { min-height: 54px; padding: 12px 18px; font-size: 14px; }
.icon-button { display: inline-grid; width: 44px; height: 44px; place-items: center; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text-muted); box-shadow: var(--shadow-1); font-size: 18px; transition: .18s ease; }
.icon-button:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
code { padding: 2px 5px; border-radius: 4px; background: var(--soft); font-size: .9em; }

/* Dialogs, forms, and transient feedback */
.reader-panel-content textarea, .card-dialog textarea, .card-dialog input,
.manage-tools input, .manage-tools select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-elevated);
  color: var(--text);
}
.reader-panel-content textarea, .card-dialog textarea, .card-dialog input,
.manage-tools input, .manage-tools select { padding: 11px 12px; }
.reader-panel-content textarea { min-height: 150px; resize: vertical; line-height: 1.75; }
.text-input-label { display: block; margin: 16px 0 7px; font-size: 12px; font-weight: 700; }
.card-dialog, .confirm-dialog {
  width: min(650px, calc(100vw - 26px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-3);
}
.confirm-dialog { width: min(460px, calc(100vw - 28px)); }
.card-dialog::backdrop, .confirm-dialog::backdrop { background: rgba(6, 8, 12, .56); backdrop-filter: blur(3px); }
.card-dialog form { max-height: calc(100dvh - 32px); overflow: auto; padding: 24px; }
.dialog-heading, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-heading { margin-bottom: 18px; }
.dialog-heading h2, .confirm-content h2 { margin: 0; font-size: 23px; letter-spacing: -.025em; }
.dialog-heading .eyebrow { margin-bottom: 3px; }
.dialog-actions { justify-content: flex-end; margin-top: 20px; }
.dialog-actions-spacer { flex: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid > * { min-width: 0; }
.form-grid label { display: block; font-size: 12px; font-weight: 650; }
.form-grid input, .form-grid textarea { display: block; margin-top: 5px; font-size: 14px; font-weight: 400; }
.form-grid textarea { resize: vertical; }
.full-field { grid-column: 1 / -1; }
.confirm-content { padding: 24px; }
.confirm-content > p:not(.eyebrow) { margin: 14px 0 20px; color: var(--text-muted); font-size: 14px; line-height: 1.7; }
.toast { position: fixed; z-index: 40; right: 20px; bottom: calc(22px + env(safe-area-inset-bottom)); max-width: min(420px, calc(100vw - 32px)); padding: 11px 15px; transform: translateY(8px); border: 1px solid var(--border); border-radius: 9px; background: var(--surface-elevated); color: var(--text); box-shadow: var(--shadow-3); font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
