/* ==========================================================================
   ライチ 管理画面 デザインシステム (Lychee Admin Design System)
   Version: 1.0.0
   ========================================================================== */

/* ===== 1. デザイン トークン (CSS Variables) ===== */
:root {
  /* 面 (Surface)。ライミーの桃色と、葉っぱの薄い緑。 */
  --bg: #fff7fa;
  --card: #ffffff;
  --card-2: #fff0f5;
  --side-bg: #fffafc;
  --surface-elevated: #ffffff;
  --surface-input: #ffffff;
  --scrim: rgba(90, 30, 52, 0.45);
  --page-bg:
    radial-gradient(880px 380px at 100% -8%, #ffe4f1 0%, transparent 62%),
    radial-gradient(640px 320px at -8% 8%, #e7f7ea 0%, transparent 58%),
    var(--bg);
  --side-grad: linear-gradient(180deg, #ffe4f0 0%, var(--side-bg) 240px);
  --hello-bg: linear-gradient(105deg, #ffffff 0%, #ffe8f2 58%, #f4fbe9 100%);
  --hello-border: #f3c6d8;
  --nav-label: #b85a7c;
  --mascot-ring: #ffffff;

  /* 文字 (Text) */
  --text: #3b2430;
  --sub: #7a5566;
  --text-muted: #b07a90;
  --text-inverse: #ffffff;

  /* 線・境界 (Borders) */
  --line: #f3d5e2;
  --line-subtle: #fbeaf1;
  --line-strong: #e7b7cb;

  /* 強調・ブランド (Accent / Primary)。ライミーのスカーフの桃色。 */
  --accent: #e0568a;
  --accent-hover: #c73d74;
  --accent-weak: #ffe4ef;
  --accent-text: #ffffff;
  --focus: #e0568a;

  /* 状態 4 種 (Status: OK / Warn / Err / Info) */
  --ok: #16a34a;
  --ok-bg: #f0fdf4;
  --ok-border: #bbf7d0;
  --ok-text: #15803d;

  --warn: #d97706;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --warn-text: #b45309;

  --err: #dc2626;
  --err-bg: #fef2f2;
  --err-border: #fecaca;
  --err-text: #b91c1c;

  --info: #0284c7;
  --info-bg: #f0f9ff;
  --info-border: #bae6fd;
  --info-text: #0369a1;

  /* 非活性・ニュートラル (Off / Neutral) */
  --off: #64748b;
  --off-bg: #f1f5f9;
  --off-border: #e2e8f0;

  /* 影 (Shadows) */
  --shadow-xs: 0 1px 2px rgba(176, 70, 110, 0.06);
  --shadow: 0 1px 3px rgba(176, 70, 110, 0.08), 0 1px 2px rgba(176, 70, 110, 0.04);
  --shadow-md: 0 8px 22px rgba(176, 70, 110, 0.12), 0 1px 3px rgba(176, 70, 110, 0.06);
  --shadow-pop: 0 16px 40px rgba(140, 40, 80, 0.22);
  --accent-glow: 0 6px 14px rgba(224, 86, 138, 0.28);

  /* 余白の段 (Spacing Scale) */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  /* 角丸の段 (Radius Scale)。まるくてやわらかい形。 */
  --r-xs: 8px;
  --r-sm: 12px;
  --r: 16px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-pill: 9999px;

  /* 文字の大きさの段 (Typography Scale) */
  --fs-xs: 11px;
  --fs-sm: 13px;
  --fs: 14px;
  --fs-base: 14px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-2xl: 28px;

  /* フォント指定。丸ゴシックを優先し、読めない環境では通常のゴシックに戻る。 */
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", "Noto Sans JP", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace;

  /* 動きの長さ (Motion) */
  --dur-fast: 0.15s;
  --dur: 0.2s;
  --dur-slow: 0.3s;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* シェルの寸法 */
  --side-w: 256px;
  --top-h: 54px;
}

/* ダークテーマ (Dark Theme) */
:root[data-theme="dark"] {
  --bg: #161014;
  --card: #241820;
  --card-2: #321f29;
  --side-bg: #1c1218;
  --surface-elevated: #3a2430;
  --surface-input: #140e12;
  --scrim: rgba(0, 0, 0, 0.65);
  --page-bg:
    radial-gradient(720px 320px at 100% -8%, rgba(224, 86, 138, 0.22) 0%, transparent 62%),
    radial-gradient(520px 260px at -8% 8%, rgba(61, 154, 74, 0.16) 0%, transparent 58%),
    var(--bg);
  --side-grad: linear-gradient(180deg, #3a1c2a 0%, var(--side-bg) 240px);
  --hello-bg: linear-gradient(105deg, #241820 0%, #3a1c2a 62%, #1a2a1e 100%);
  --hello-border: #5a3044;
  --nav-label: #f0a8c4;
  --mascot-ring: #3a2430;

  --text: #f8e8ef;
  --sub: #d4a8b8;
  --text-muted: #a07888;
  --text-inverse: #1c1218;

  --line: #4a2c3a;
  --line-subtle: #321f29;
  --line-strong: #6a4054;

  --accent: #f472b6;
  --accent-hover: #f9a8d4;
  --accent-weak: #3a2030;
  --accent-text: #1c1218;
  --focus: #f9a8d4;

  --ok: #22c55e;
  --ok-bg: #0f2d1b;
  --ok-border: #144929;
  --ok-text: #86efac;

  --warn: #f59e0b;
  --warn-bg: #322108;
  --warn-border: #4d330c;
  --warn-text: #fde68a;

  --err: #ef4444;
  --err-bg: #351315;
  --err-border: #521c20;
  --err-text: #fca5a5;

  --info: #38bdf8;
  --info-bg: #0b273b;
  --info-border: #133e5c;
  --info-text: #7dd3fc;

  --off: #94a3b8;
  --off-bg: #1e2634;
  --off-border: #2d3748;

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
  --shadow-pop: 0 12px 36px rgba(0, 0, 0, 0.7);
  --accent-glow: 0 6px 16px rgba(244, 114, 182, 0.28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161014;
    --card: #241820;
    --card-2: #321f29;
    --side-bg: #1c1218;
    --surface-elevated: #3a2430;
    --surface-input: #140e12;
    --scrim: rgba(0, 0, 0, 0.65);
    --page-bg:
      radial-gradient(720px 320px at 100% -8%, rgba(224, 86, 138, 0.22) 0%, transparent 62%),
      radial-gradient(520px 260px at -8% 8%, rgba(61, 154, 74, 0.16) 0%, transparent 58%),
      var(--bg);
    --side-grad: linear-gradient(180deg, #3a1c2a 0%, var(--side-bg) 240px);
    --hello-bg: linear-gradient(105deg, #241820 0%, #3a1c2a 62%, #1a2a1e 100%);
    --hello-border: #5a3044;
    --nav-label: #f0a8c4;
    --mascot-ring: #3a2430;

    --text: #f8e8ef;
    --sub: #d4a8b8;
    --text-muted: #a07888;
    --text-inverse: #1c1218;

    --line: #4a2c3a;
    --line-subtle: #321f29;
    --line-strong: #6a4054;

    --accent: #f472b6;
    --accent-hover: #f9a8d4;
    --accent-weak: #3a2030;
    --accent-text: #1c1218;
    --focus: #f9a8d4;

    --ok: #22c55e;
    --ok-bg: #0f2d1b;
    --ok-border: #144929;
    --ok-text: #86efac;

    --warn: #f59e0b;
    --warn-bg: #322108;
    --warn-border: #4d330c;
    --warn-text: #fde68a;

    --err: #ef4444;
    --err-bg: #351315;
    --err-border: #521c20;
    --err-text: #fca5a5;

    --info: #38bdf8;
    --info-bg: #0b273b;
    --info-border: #133e5c;
    --info-text: #7dd3fc;

    --off: #94a3b8;
    --off-bg: #1e2634;
    --off-border: #2d3748;

    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
    --shadow-pop: 0 12px 36px rgba(0, 0, 0, 0.7);
    --accent-glow: 0 6px 16px rgba(244, 114, 182, 0.28);
  }
}

/* クール。白を基調に、角を抑えた墨色。 */
:root[data-theme="cool"] {
  --bg: #f5f7fb;
  --card: #ffffff;
  --card-2: #f3f6fa;
  --side-bg: #ffffff;
  --surface-elevated: #ffffff;
  --surface-input: #ffffff;
  --scrim: rgba(15, 23, 42, 0.4);
  --page-bg:
    radial-gradient(880px 360px at 100% -12%, rgba(37, 99, 235, 0.10) 0%, transparent 60%),
    var(--bg);
  --side-grad: #ffffff;
  --hello-bg: #ffffff;
  --hello-border: #e6ebf2;
  --nav-label: #64748b;
  --mascot-ring: #ffffff;

  --text: #0f172a;
  --sub: #526277;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --line: #e6ebf2;
  --line-subtle: #f1f5f9;
  --line-strong: #cbd5e1;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-weak: #e8f0fe;
  --accent-text: #ffffff;
  --focus: #2563eb;

  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --ok-border: #bbf7d0;
  --ok-text: #166534;

  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --warn-text: #92400e;

  --err: #dc2626;
  --err-bg: #fef2f2;
  --err-border: #fecaca;
  --err-text: #b91c1c;

  --info: #0369a1;
  --info-bg: #f0f9ff;
  --info-border: #bae6fd;
  --info-text: #075985;

  --off: #64748b;
  --off-bg: #f1f5f9;
  --off-border: #e2e8f0;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-pop: 0 16px 40px rgba(15, 23, 42, 0.14);
  --accent-glow: 0 8px 20px rgba(37, 99, 235, 0.22);

  --font: "Hiragino Sans", "Yu Gothic UI", "Meiryo", "Noto Sans JP", system-ui, sans-serif;
  --r-xs: 4px;
  --r-sm: 6px;
  --r: 8px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-pill: 8px;
  color-scheme: light;
}

:root[data-theme="cool"] .card,
:root[data-theme="cool"] .stat,
:root[data-theme="cool"] .table-wrap {
  box-shadow: var(--shadow);
}

:root[data-theme="cool"] .nav-link[aria-current="page"] {
  background: var(--accent-weak);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* ===== 2. ベーススタイル (Base & Reset) ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

:root[data-theme="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.6;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}

body.nav-open {
  overflow: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 2px;
  transition: color var(--dur-fast) ease;
}

a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4 {
  line-height: 1.35;
  margin: 0;
  color: var(--text);
  font-weight: 700;
}

h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs); }

p {
  margin: 0 0 var(--s3);
}

ul, ol {
  margin: 0;
}

code, .mono {
  font-family: var(--mono);
  font-size: 0.9em;
}

code {
  background: var(--card-2);
  border: 1px solid var(--line-subtle);
  border-radius: var(--r-xs);
  padding: 1px 6px;
}

pre {
  margin: 0;
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: var(--s2) var(--s4);
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--r-sm);
  font-weight: 600;
}

.skip:focus {
  left: var(--s3);
  top: var(--s3);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* ===== 3. シェル構造 (Shell: Sidebar, Topbar, Main) ===== */
.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--side-grad);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: var(--s4) var(--s3) var(--s5);
  user-select: none;
}

.sidebar-brand-wrap {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s1) var(--s2) var(--s3);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-mascot {
  display: block;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  object-fit: cover;
  background: var(--accent-weak);
  border: 2px solid var(--mascot-ring);
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
}

.brand-block {
  min-width: 0;
}

.brand {
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
  margin: 0;
  line-height: 1.2;
}

.sidebar-mascot.is-tiny {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}

.auth-hello {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: var(--s5) 0 var(--s4);
  text-align: center;
}

.auth-hello .sidebar-mascot {
  width: 88px;
  height: 88px;
  border-radius: 28px;
}

.auth-hello .brand {
  font-size: var(--fs-xl);
}

.whoami {
  color: var(--sub);
  font-size: var(--fs-xs);
  padding: 0 var(--s2) var(--s3);
  border-bottom: 1px solid var(--line-subtle);
  margin-bottom: var(--s3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.whoami::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}

.nav-group {
  margin: 0 0 var(--s3);
}

.nav-group h2 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--nav-label);
  padding: 0;
  margin: 0;
}

/* 区分の見出し: 押すと開き閉じ。右の矢印で、開いているか分かる。件数のバッジは、畳んでも見出しに残る。 */
.nav-group > summary {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 4px var(--s2);
  margin: 0 0 2px;
  border-radius: var(--r-sm, 6px);
  cursor: pointer;
  list-style: none;
}

.nav-group > summary::-webkit-details-marker {
  display: none;
}

.nav-group > summary::after {
  content: "";
  margin-left: auto;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.nav-group[open] > summary::after {
  transform: rotate(45deg);
}

.nav-group > summary:hover h2 {
  color: var(--text);
}

.nav-group > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.nav-group > summary .nav-count {
  margin-left: 0;
}

@media (prefers-reduced-motion: reduce) {
  .nav-group > summary::after {
    transition: none;
  }
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: var(--r-pill);
  box-shadow: none;
  color: var(--sub);
  text-decoration: none;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}

.nav-link:hover {
  background: var(--card-2);
  color: var(--text);
  text-decoration: none;
}

.nav-link svg {
  flex-shrink: 0;
  color: currentColor;
  opacity: 0.8;
  transition: opacity var(--dur-fast) ease;
}

.nav-link:hover svg {
  opacity: 1;
}

.nav-link[aria-current="page"] {
  background: var(--card);
  color: var(--accent);
  font-weight: 700;
  box-shadow: var(--shadow);
}

.nav-link[aria-current="page"] svg {
  color: var(--accent);
  opacity: 1;
}

.nav-count {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--err);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.topbar {
  display: none;
}

.scrim {
  display: none;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page {
  max-width: 1140px;
  width: 100%;
  margin: 0 auto;
  padding: var(--s5) var(--s5) 64px;
}

.page.is-narrow {
  max-width: 640px;
}

/* 900px 未満 (Mobile Drawer & Topbar) */
@media (max-width: 899px) {
  .app {
    display: block;
  }
  .topbar {
    display: flex;
    align-items: center;
    gap: var(--s3);
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--top-h);
    padding: 0 var(--s4);
    background: var(--side-bg);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-xs);
  }
  .nav-toggle {
    width: 40px;
    height: 40px;
    margin-left: -6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    border-radius: var(--r-sm);
    cursor: pointer;
  }
  .nav-toggle:hover {
    background: var(--card-2);
  }
  .nav-toggle {
    box-shadow: none;
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    width: min(300px, 86vw);
    height: auto;
    box-shadow: var(--shadow-pop);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform var(--dur) var(--ease), visibility var(--dur);
  }
  body.nav-open .sidebar {
    transform: none;
    visibility: visible;
  }
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: var(--scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
  }
  body.nav-open .scrim {
    opacity: 1;
    pointer-events: auto;
  }
  .page {
    padding: var(--s4) var(--s4) 48px;
  }
}

@media (min-width: 900px) {
  .nav-toggle {
    display: none;
  }
}

/* ===== 4. 枠ごとスクロール (body.is-fit) ===== */
body.is-fit {
  overflow: hidden;
}

body.is-fit .app {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
}

body.is-fit .sidebar {
  height: 100vh;
  height: 100dvh;
}

body.is-fit .main {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.is-fit .page {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--s3);
}

body.is-fit .page-head,
body.is-fit .pagehead,
body.is-fit .flashes {
  flex: 0 0 auto;
}

@media (max-width: 899px) {
  body.is-fit .app {
    display: flex;
    flex-direction: column;
  }
  body.is-fit .topbar {
    flex: 0 0 var(--top-h);
  }
  body.is-fit .main {
    flex: 1 1 0;
    height: auto;
  }
  body.is-fit .page {
    padding-bottom: var(--s2);
  }
}

/* ===== 5. ページ見出し (Page Header) ===== */
.page-head, .pagehead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2) var(--s4);
  margin: 0 0 var(--s4);
}

.page-head h1, .pagehead h1 {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0;
  flex: 1 1 240px;
  min-width: 0;
}

.page-head h1::before, .pagehead h1::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 1px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
}

.lead {
  color: var(--sub);
  font-size: 13.5px;
  margin: 0 0 var(--s4);
  max-width: 74ch;
}

/* ===== 6. 通知・エラー・バナー (Notice / Flashes / Banner) ===== */
.flashes {
  display: grid;
  gap: var(--s2);
  margin: 0 0 var(--s4);
}

.flashes:empty {
  display: none;
}

.flash, .notice {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: var(--shadow-xs);
}

.flash.ok, .notice-ok {
  color: var(--ok-text);
  background: var(--ok-bg);
  border-color: var(--ok-border);
}

.flash.warn, .notice-warn {
  color: var(--warn-text);
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.flash.err, .notice-err {
  color: var(--err-text);
  background: var(--err-bg);
  border-color: var(--err-border);
}

.flash.info, .notice-info {
  color: var(--info-text);
  background: var(--info-bg);
  border-color: var(--info-border);
}

.banner {
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  margin: 0 0 var(--s2);
  font-size: 13.5px;
}

.banner.help {
  background: var(--err-bg);
  color: var(--err);
  font-weight: 700;
  border: 1px solid var(--err-border);
}

.banner.end {
  background: var(--off-bg);
  color: var(--off);
}

.banner.err {
  background: var(--warn-bg);
  color: var(--warn);
}

/* ===== 7. カード (Cards) ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s4);
  margin: 0 0 var(--s4);
  box-shadow: var(--shadow);
  min-width: 0;
}

.card > h2, .card-head h2, .card-header h2 {
  font-size: var(--fs-md);
  margin: 0 0 var(--s3);
  font-weight: 700;
}

.card-head, .card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2) var(--s4);
  margin: 0 0 var(--s3);
}

.card-head h2, .card-header h2 {
  margin: 0;
}

.section-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
  margin: var(--s5) 0 var(--s3);
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.section-title svg {
  color: var(--accent);
}

.item-card {
  display: grid;
  gap: var(--s3);
}

.auth-card {
  max-width: 400px;
  margin: 0 auto;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
}

.grow {
  flex: 1 1 260px;
  min-width: 0;
}

.name {
  font-weight: 600;
  color: var(--text);
}

.desc, .muted {
  color: var(--sub);
  font-size: var(--fs-sm);
}

.note {
  color: var(--sub);
  font-size: var(--fs-sm);
  margin: 0 0 var(--s3);
}

.stack > * + * {
  margin-top: var(--s3);
}

/* ===== 8. 数字カード (Stat / Metric Cards) ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: var(--s3);
  margin: 0 0 var(--s4);
}

.stat {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s4);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  min-width: 0;
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease, transform var(--dur-fast) ease;
}

a.stat {
  position: relative;
  padding-bottom: 38px;
}

a.stat::after {
  content: "開く";
  position: absolute;
  right: 16px;
  bottom: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

a.stat:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transform: translateY(-2px);
}

a.stat.is-alert::after {
  content: "確認する";
  color: var(--err);
}

a.stat.is-warn::after {
  content: "確認する";
  color: var(--warn);
}

.stat-label {
  display: block;
  color: var(--sub);
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-bottom: var(--s1);
}

.stat-value {
  display: block;
  font-size: 26px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stat-sub {
  display: block;
  color: var(--sub);
  font-size: var(--fs-xs);
  margin-top: 4px;
}

.stat.is-alert {
  background: var(--err-bg);
  border-color: var(--err-border);
}

.stat.is-alert .stat-value,
.stat.is-alert .stat-sub {
  color: var(--err);
}

.stat.is-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.stat.is-warn .stat-value,
.stat.is-warn .stat-sub {
  color: var(--warn);
}

.stat.is-ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
}

.stat.is-ok .stat-value,
.stat.is-ok .stat-sub {
  color: var(--ok);
}

/* ===== 9. 表 (Tables) ===== */
.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  margin: 0 0 var(--s4);
  max-width: 100%;
}

.table-wrap.is-long {
  max-height: 72vh;
  overflow: auto;
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 560px;
}

table.table.is-wide {
  min-width: 860px;
}

.table th, .table td {
  text-align: left;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card-2);
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-top: 0;
  border-bottom: 1px solid var(--line);
}

.table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--card-2) 40%, transparent);
}

.table tbody tr:hover td {
  background: var(--accent-weak);
}

.table .num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.table audio {
  display: block;
  width: 220px;
  max-width: 100%;
  margin-top: 4px;
}

/* ===== 10. ボタン (Buttons: 4 Kinds) ===== */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 40px;
  padding: 8px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: background var(--dur-fast) ease, border-color var(--dur-fast) ease, transform var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
  user-select: none;
}

button:hover, .btn:hover {
  background: var(--card-2);
  border-color: var(--sub);
  text-decoration: none;
}

button:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 主 (Primary) */
.btn-primary, button.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 700;
  box-shadow: var(--accent-glow);
}

.btn-primary:hover, button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-text);
}

/* 危険 (Danger) */
.btn-danger, button.danger {
  color: var(--err);
  border-color: var(--err-border);
  background: var(--card);
}

.btn-danger:hover, button.danger:hover {
  background: var(--err-bg);
  border-color: var(--err);
}

/* 静か (Ghost / Subdued) */
.btn-ghost, button.link {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
  padding: 8px 12px;
}

.btn-ghost:hover, button.link:hover {
  background: var(--accent-weak);
  border-color: transparent;
}

/* サイズ展開 (Sizes) */
.btn-sm {
  min-height: 36px;
  padding: 4px 14px;
  font-size: 13px;
  border-radius: var(--r-pill);
}

@media (pointer: coarse) {
  .btn-sm {
    min-height: 38px;
  }
}

summary.btn {
  list-style: none;
}

summary.btn::-webkit-details-marker {
  display: none;
}

summary.btn::after {
  content: "▾";
  font-size: 11px;
}

details[open] > summary.btn::after {
  content: "▴";
}

/* ===== 11. フォーム (Forms & Fields) ===== */
label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
  margin: 0 0 var(--s1);
}

input[type=text],
input[type=password],
input[type=search],
input[type=date],
input[type=time],
input[type=number],
input[type=url],
input:not([type]),
select,
textarea {
  display: block;
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface-input);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  transition: border-color var(--dur-fast) ease, outline var(--dur-fast) ease;
}

input[type=file] {
  display: block;
  width: 100%;
  min-height: 38px;
  padding: 6px 0;
  font: inherit;
  color: var(--text);
}

textarea {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  min-height: 120px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}

input[type=checkbox], input[type=radio] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

label.check {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 38px;
  margin: 0;
  color: var(--text);
  font-size: 13.5px;
  cursor: pointer;
}

.field {
  min-width: 0;
}

.field .help {
  color: var(--sub);
  font-size: 12px;
  margin-top: var(--s1);
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--err);
}

.field .error {
  color: var(--err);
  font-size: var(--fs-sm);
  margin-top: var(--s1);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: var(--s3);
  align-items: end;
}

.form-grid .span-all {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
  margin-top: var(--s3);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s2);
}

.inline-form > .field {
  flex: 1 1 200px;
}

.inline-form > input, .inline-form > select {
  flex: 1 1 220px;
  width: auto;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
  gap: var(--s3);
  align-items: end;
}

.filter-bar .filter-actions {
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  align-self: end;
  justify-self: start;
  gap: var(--s2);
  width: max-content;
  max-width: 100%;
  grid-column: span 2;
}

.filter-bar .filter-actions .btn {
  flex: none;
  min-height: 32px;
  padding: 4px 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.form-narrow {
  max-width: 520px;
}

/* ===== 12. 札・チップ・バッジ (Chips, Badges, Tags) ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 9px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.6;
  color: var(--off);
  background: var(--off-bg);
  border: 1px solid var(--off-border);
}

.badge.ok, .badge.db {
  color: var(--ok-text);
  background: var(--ok-bg);
  border-color: var(--ok-border);
}

.badge.warn, .badge.env {
  color: var(--warn-text);
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.badge.off, .badge.unset {
  color: var(--off);
  background: var(--off-bg);
  border-color: var(--off-border);
}

.badge.err {
  color: var(--err-text);
  background: var(--err-bg);
  border-color: var(--err-border);
}

.badge.role {
  color: var(--accent);
  background: var(--accent-weak);
  border-color: var(--accent);
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--off);
}

.dot.db, .dot.ok { background: var(--ok); }
.dot.env, .dot.warn { background: var(--warn); }
.dot.unset { background: var(--err); }

/* チップ (Chip component) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--sub);
  background: var(--card);
  border: 1px solid var(--line);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--dur-fast) ease;
}

.chip:hover {
  color: var(--text);
  border-color: var(--accent);
  text-decoration: none;
}

.chip[aria-current="true"], .chip.is-active {
  color: var(--accent);
  background: var(--accent-weak);
  border-color: var(--accent);
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
}

/* カスハラの危険度 (Risk Badges) */
.risk {
  display: inline-block;
  padding: 1px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.risk-none { background: #64748b; color: #ffffff; }
.risk-caution { background: #f59e0b; color: #ffffff; }
.risk-warning { background: #ea580c; color: #ffffff; }
.risk-danger { background: #dc2626; color: #ffffff; }

/* 通話の評価の点数 */
.q-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.q-score.q-small { font-size: 13px; }
.q-score.q-big { font-size: 38px; line-height: 1.1; }
.q-good { color: var(--ok); }
.q-mid { color: var(--warn); }
.q-low { color: var(--err); }

/* 通話中の共通部品 */
.help-badge {
  display: inline-block;
  padding: 1px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  color: #ffffff;
  background: var(--err);
  margin-right: 4px;
}

tr.lv-help td { background: var(--err-bg) !important; }
tr.lv-warn td { background: var(--warn-bg) !important; }

.lv-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s3);
  margin: 0 0 var(--s3);
}

.ev-kind {
  display: inline-block;
  padding: 1px 9px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  background: var(--off-bg);
  color: var(--off);
}

.ev-kind.help { background: var(--err-bg); color: var(--err); }
.ev-kind.hangup_ok { background: var(--ok-bg); color: var(--ok); }

/* ===== 13. タブ (Tabs Component) ===== */
.tabs, .tab-nav {
  display: flex;
  gap: var(--s1);
  border-bottom: 1px solid var(--line);
  margin: 0 0 var(--s4);
  overflow-x: auto;
}

.tab-item, .tab-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--sub);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--dur-fast) ease;
  white-space: nowrap;
}

.tab-item:hover, .tab-link:hover {
  color: var(--text);
  border-bottom-color: var(--line-strong);
  text-decoration: none;
}

.tab-item[aria-selected="true"],
.tab-link[aria-current="page"],
.tab-item.is-active,
.tab-link.is-active {
  color: var(--accent);
  font-weight: 700;
  border-bottom-color: var(--accent);
}

/* ===== 14. ツールバー (Toolbar) ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2) var(--s3);
  margin: 0 0 var(--s4);
}

/* ===== 15. 分割レイアウト (Split / Panes) ===== */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: var(--s4);
  align-items: start;
}

.pane {
  min-height: 0;
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

/* ===== 16. 空の状態 (Empty State) ===== */
.empty {
  text-align: center;
  color: var(--sub);
  padding: var(--s6) var(--s4);
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--r);
  font-size: 13.5px;
}

/* ===== 17. ユーティリティ (Utilities & Facts) ===== */
dl.facts {
  margin: 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--s2) var(--s4);
  font-size: 13.5px;
}

dl.facts dt {
  color: var(--sub);
}

dl.facts dd {
  margin: 0;
  color: var(--text);
}

@media (max-width: 420px) {
  dl.facts {
    grid-template-columns: 1fr;
    gap: 0;
  }
  dl.facts dd {
    margin-bottom: var(--s2);
  }
}

code.pw {
  font-size: 16px;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  user-select: all;
  background: var(--card-2);
  border-radius: var(--r-xs);
}

.codeblock {
  font: 13px/1.6 var(--mono);
  background: var(--card-2);
  border-radius: var(--r-sm);
  padding: var(--s3);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin: var(--s4) 0;
}

.pager a, .pager span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  font-size: 13px;
  text-decoration: none;
  border: 1px solid var(--line);
  color: var(--sub);
  background: var(--card);
}

.pager a:hover {
  color: var(--text);
  border-color: var(--accent);
}

.pager span.cur {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: var(--s4);
  align-items: start;
}

.detail-side {
  position: sticky;
  top: var(--s4);
  min-width: 0;
}

@media (max-width: 899px) {
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .detail-side {
    position: static;
    order: -1;
  }
}

.back {
  display: inline-block;
  margin: 0 0 var(--s3);
}

/* チャット・文字起こし吹き出し (Chat Bubbles) */
.chat {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.bub {
  max-width: min(80%, 640px);
  padding: 8px 14px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--bg);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 13.5px;
}

.bub.op {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.bub.cu {
  align-self: flex-start;
  background: var(--card);
  color: var(--text);
}

.bub .who {
  display: block;
  font-size: 11px;
  opacity: 0.8;
  margin-bottom: 2px;
}

/* お客様の発話の日本語訳（翻訳を入れた通話だけ）。原文の下に小さく添える。 */
.bub .tr {
  display: block;
  font-size: 12px;
  opacity: 0.8;
  margin-top: 2px;
}

.bub.partial {
  opacity: 0.65;
}

@media (max-width: 520px) {
  .bub {
    max-width: 92%;
  }
}

/* 折りたたみ（details.fold）: 毎日は見ない部分を畳む。見出しを押すと開く。 */
details.fold {
  margin: var(--s4) 0 0;
}

details.fold > summary {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  flex-wrap: wrap;
  padding: var(--s2) 0;
  cursor: pointer;
  list-style: none;
  border-top: 1px solid var(--line);
}

details.fold > summary::-webkit-details-marker {
  display: none;
}

details.fold > summary::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  align-self: center;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

details.fold[open] > summary::before {
  transform: rotate(45deg);
}

details.fold > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  details.fold > summary::before {
    transition: none;
  }
}

/* ダッシュボードの「対応が必要なもの」: いちばん上に集める。重いもの（赤）が先。何も無いときは、1行だけ。 */
.attention {
  margin: 0 0 var(--s4);
  padding: var(--s3) var(--s4);
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--err);
  border-radius: var(--r-lg);
}

.attention.is-clear {
  border-left-color: var(--ok);
  padding-block: var(--s2);
}

.attention h2 {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin: 0;
  font-size: var(--fs-md, 1rem);
}

.attention ul {
  list-style: none;
  margin: var(--s2) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.attention li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  flex-wrap: wrap;
  padding: var(--s1) 0;
  border-top: 1px solid var(--line-subtle, var(--line));
}

.attention li:first-child {
  border-top: 0;
}

.attention li > span {
  flex: 1 1 260px;
  min-width: 0;
}

.attention li.is-err > span {
  font-weight: 600;
}

.attention li.is-warn > span::before,
.attention li.is-err > span::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: var(--s2);
  border-radius: 50%;
  background: var(--warn);
}

.attention li.is-err > span::before {
  background: var(--err);
}

.attention li .btn {
  flex: none;
}

.attention.is-clear h2::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px var(--ok-bg);
}

/* ダッシュボードのあいさつ。ライミーが、次に押す場所を一言で示す。 */
.hello {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 var(--s4);
  padding: 14px 16px;
  background: var(--hello-bg);
  border: 1px solid var(--hello-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

.hello img {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  object-fit: cover;
  flex: none;
  background: var(--accent-weak);
  border: 2px solid var(--mascot-ring);
}

.hello-title {
  margin: 0;
  font-weight: 700;
  font-size: 17px;
  line-height: 1.35;
}

.hello-text {
  margin: 4px 0 0;
  color: var(--sub);
  font-size: 14px;
  line-height: 1.55;
}

/* 初期設定。文章のうしろにリンクを置かず、番号とボタンを分ける。 */
.setup {
  border: 1px solid var(--warn-border);
  background: var(--card);
}

.setup-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setup-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--accent-weak);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-radius: var(--r);
}

.setup-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  display: grid;
  place-items: center;
}

.setup-text {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.5;
}

.setup-go {
  white-space: nowrap;
}

@media (max-width: 640px) {
  .hello {
    align-items: flex-start;
  }

  .hello img {
    width: 56px;
    height: 56px;
    border-radius: 16px;
  }

  .setup-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .setup-go {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  a.stat:hover {
    transform: none;
  }
}

/* ダッシュボードから使い方へ。AIの数字とディスクのあいだで、1行ぶん使う。 */
.manual-jump {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 52px;
  padding: 12px 16px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--accent-glow);
}

.manual-jump:hover {
  background: var(--accent-hover);
  color: var(--accent-text);
}

.manual-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.manual-item {
  margin: 0;
  padding: 0;
  overflow: hidden;
  scroll-margin-top: 16px;
}

.manual-item summary {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 56px;
  padding: 12px 18px;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.manual-item summary::-webkit-details-marker,
.manual-item summary::marker {
  display: none;
  content: "";
}

.manual-item summary:hover {
  background: var(--accent-weak);
}

.manual-title {
  font-size: var(--fs-md);
  font-weight: 700;
}

.manual-chevron {
  width: 9px;
  height: 9px;
  margin-left: auto;
  flex: none;
  border-right: 2px solid var(--sub);
  border-bottom: 2px solid var(--sub);
  transform: rotate(45deg);
  transition: transform 0.25s ease;
}

.manual-item[open] .manual-chevron {
  transform: rotate(225deg);
}

.manual-item[open] summary {
  background: color-mix(in srgb, var(--accent-weak) 70%, transparent);
}

.manual-item::details-content {
  block-size: 0;
  overflow: hidden;
  opacity: 0;
  interpolate-size: allow-keywords;
  transition: block-size 0.32s ease, opacity 0.24s ease;
}

.manual-item[open]::details-content {
  block-size: auto;
  opacity: 1;
}

.manual-body {
  padding: 4px 18px 18px;
  border-top: 1px solid var(--line);
}

.manual-open {
  margin: var(--s4) 0 0;
}

.manual-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: var(--fs-sm);
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .manual-chevron,
  .manual-item::details-content {
    transition: none;
  }
}

.manual-item h3 {
  margin: var(--s3) 0 var(--s2);
  font-size: var(--fs);
}

.manual-item dl {
  display: grid;
  grid-template-columns: minmax(8em, 14em) 1fr;
  gap: var(--s2) var(--s3);
  margin: 0;
}

.manual-item dt {
  font-weight: 700;
}

.manual-item dd {
  margin: 0;
}

@media (max-width: 640px) {
  .manual-item dl {
    grid-template-columns: 1fr;
  }
}

/* 使い方の案内（右下の浮き出し）。キャラクターの色に合わせた桃色。中身は管理画面のトークン。 */
.guide-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1200;
  width: 68px;
  height: 68px;
  padding: 0;
  border: 3px solid var(--mascot-ring);
  border-radius: 50%;
  box-shadow: var(--shadow-pop);
  background: var(--accent-weak);
  overflow: hidden;
  cursor: pointer;
}

.guide-launcher img,
.guide-head img,
.guide-hello img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.guide-panel {
  position: fixed;
  right: 20px;
  bottom: 100px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 24px));
  height: min(560px, calc(100dvh - 124px));
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.guide-panel[hidden] {
  display: none;
}

.guide-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--accent);
  color: var(--accent-text);
}

.guide-head img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--mascot-ring);
  flex: none;
}

.guide-name {
  font-weight: 700;
  line-height: 1.2;
}

.guide-quota {
  font-size: 12px;
  line-height: 1.3;
}

.guide-head-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.guide-clear,
.guide-close {
  border: 0;
  background: color-mix(in srgb, var(--accent-text) 18%, transparent);
  color: var(--accent-text);
  cursor: pointer;
  font: inherit;
  box-shadow: none;
}

.guide-clear {
  padding: 6px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
}

.guide-close {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
}

.guide-body {
  flex: 1;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-hello {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.guide-hello img {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  flex: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-drag: none;
}

.guide-bubble,
.guide-msg {
  margin: 0;
  white-space: pre-wrap;
  line-break: strict;
  word-break: auto-phrase;
  overflow-wrap: break-word;
  line-height: 1.55;
}

.guide-bubble {
  background: var(--card-2);
  border-radius: 14px;
  padding: 10px 12px;
}

.guide-note {
  margin: 0;
  font-size: 12px;
  color: var(--sub);
}

.guide-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-msg {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 14px;
}

.guide-msg.is-user {
  align-self: flex-end;
  background: var(--accent-weak);
}

.guide-msg.is-assistant {
  align-self: flex-start;
  background: var(--card-2);
}

.guide-msg.is-thinking {
  color: var(--sub);
}

@media (prefers-reduced-motion: no-preference) {
  .guide-msg.is-thinking {
    animation: guide-think 1.2s ease-in-out infinite;
  }
}

@keyframes guide-think {
  50% { opacity: 0.45; }
}

.guide-msg.is-err {
  align-self: flex-start;
  background: var(--err-bg);
  color: var(--err-text);
}

.guide-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  background: var(--card);
}

.guide-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface-input);
}

.guide-send {
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.guide-send:disabled,
.guide-form input:disabled {
  opacity: 0.55;
  cursor: default;
}

@media (max-width: 430px) {
  .guide-launcher {
    right: 12px;
    bottom: 12px;
  }

  .guide-panel {
    right: 12px;
    bottom: 92px;
  }
}

/* 画面の見た目。アイコン（左メニューの上・狭い画面では上の帯）を押すと、選ぶ一覧が開く。 */
.theme-menu {
  position: relative;
  flex: none;
  margin-left: auto;
}

.theme-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  box-shadow: none;
  background: transparent;
  color: var(--sub);
  border-radius: var(--r);
}

.theme-menu-btn:hover,
.theme-menu.is-open .theme-menu-btn {
  background: var(--accent-weak);
  color: var(--text);
}

.theme-switch {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  width: 240px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.16);
}

.theme-menu.is-open .theme-switch {
  display: grid;
}

/* 左メニューの「管理」「一般」タブ */
.nav-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 0 var(--s3);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.nav-tab {
  min-height: 32px;
  padding: 4px;
  border: 0;
  box-shadow: none;
  background: transparent;
  color: var(--sub);
  font-size: 13px;
  font-weight: 700;
  border-radius: calc(var(--r) - 4px);
}

.nav-tab:hover {
  background: var(--accent-weak);
  color: var(--text);
}

.nav-tab[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-text);
}

.admin-nav[hidden] {
  display: none;
}

.theme-opt {
  min-height: 32px;
  padding: 4px 4px;
  border: 0;
  box-shadow: none;
  background: transparent;
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
  border-radius: calc(var(--r) - 4px);
}

.theme-opt:hover {
  background: var(--accent-weak);
  border-color: transparent;
  color: var(--text);
}

.theme-opt[aria-checked="true"] {
  background: var(--accent);
  color: var(--accent-text);
}

.theme-opt[aria-checked="true"]:hover {
  background: var(--accent-hover);
  color: var(--accent-text);
}

.auth-card .theme-menu {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 var(--s3);
}

.auth-card .theme-menu-btn {
  margin-left: auto;
}


.tenant-switch,
.locale-switch {
  display: grid;
  gap: 4px;
  padding: 0 var(--s2) var(--s3);
  font-size: var(--fs-xs);
  color: var(--sub);
}

/* ログイン画面（管理・会議 共通）。入力欄は 16px 未満だと iOS Safari が拡大するので 16px にする。 */
.auth-form { box-shadow: var(--shadow-md); padding: var(--s5); }
.auth-form-head { margin-bottom: var(--s4); }
.auth-form-head h2 { font-size: var(--fs-lg); margin-bottom: var(--s1); }
.auth-form-head .note { margin: 0; }
.auth-form input { font-size: 16px; min-height: 44px; }
.auth-submit { margin-top: var(--s5); }
.auth-submit .btn, .auth-google { width: 100%; min-height: 44px; font-size: 15px; justify-content: center; }
.auth-google { display: inline-flex; align-items: center; gap: var(--s2); }
.auth-divider { display: flex; align-items: center; gap: var(--s3); margin: var(--s4) 0; color: var(--sub); font-size: var(--fs-xs); }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; border-top: 1px solid var(--line-subtle); }
.auth-help { margin: var(--s4) 0 0; text-align: center; }
.auth-other { margin: var(--s2) 0 0; text-align: center; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 64px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-height: 36px; padding: 0 var(--s3); background: none; border: 0; color: var(--accent); font: inherit; font-size: var(--fs-sm); cursor: pointer; border-radius: var(--r-sm); }
.field .help.is-warn { color: var(--err); }
