/* ============================================================
   StackCase v3 — StackWorld Dark Theme
   stackworld-core 準拠 / 背景 #0d0f14 系
   ============================================================ */

:root {
  --bg:          #0d0f14;
  --bg-panel:    #13161e;
  --bg-card:     #1a1e2a;
  --bg-hover:    #1f2535;
  --border:      #2a2f3f;
  --text:        #d4d8e8;
  --text-muted:  #6b7a99;
  --accent:      #4f8ef7;
  --accent-dim:  rgba(79,142,247,.15);
  --danger:      #c47b7b;
  --danger-dim:  rgba(196,123,123,.12);
  --warning:     #e8c56d;
  --warning-dim: rgba(232,197,109,.12);
  --success:     #5aad7a;
  --ev-high:     #5aad7a;
  --ev-medium:   #e8c56d;
  --ev-low:      #c47b7b;
  --ev-unknown:  #6b7a99;
  --header-h:    52px;
  --col-l:       220px;
  --col-r:       300px; /* 後方互換用。grid側は1frに変更 */
  --r:           6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* [hidden] を確実に機能させる（ID/クラスセレクターが上書きするのを防ぐ） */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 20px;
  line-height: 1.55;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ── Loading ───────────────────────────────────────────────── */
#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 13px;
  z-index: 999;
}

#loading .spinning { font-size: 32px; }

/* ── App Shell ─────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Header ────────────────────────────────────────────────── */
#header {
  height: var(--header-h);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  gap: 12px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  font-size: 16px;
}
.header-brand strong { letter-spacing: 1px; }
.brand-tagline {
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(255,255,255,.05);
  padding: 2px 7px;
  border-radius: 4px;
}

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

.header-notice {
  flex: 1;
  text-align: center;
  font-size: 14px;
  color: var(--warning);
  background: rgba(232,197,109,.08);
  border: 1px solid rgba(232,197,109,.2);
  border-radius: var(--r);
  padding: 5px 14px;
  margin: 0 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-notice strong { color: var(--accent); }
.notice-sep { margin: 0 6px; opacity: .5; }

.sb-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-dim);
  border: 1px solid rgba(79,142,247,.25);
  border-radius: 5px;
  padding: 3px 10px;
}
.sb-label { font-size: 13px; color: var(--accent); font-weight: 700; letter-spacing: .5px; }
#sb-balance { font-size: 17px; font-weight: 600; }
.user-name  { font-size: 15px; color: var(--text-muted); }

/* ── 3カラム ────────────────────────────────────────────────── */
#main {
  display: grid;
  grid-template-columns: var(--col-l) 1.2fr 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

aside, section {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-height: 0;
  overflow: hidden;
}
#panel-right { border-right: none; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  flex-shrink: 0;
  gap: 8px;
}
.panel-header h2 {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
}
.header-actions { display: flex; gap: 6px; }

/* ── Left: ケース一覧 ───────────────────────────────────────── */
#case-list {
  overflow-y: auto;
  padding: 6px;
  flex-shrink: 0;
  max-height: 42%;
  border-bottom: 1px solid var(--border);
}
.case-new-row {
  display: flex;
  gap: 5px;
  padding: 3px 2px 6px;
}
.case-new-row input {
  flex: 1; min-width: 0;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--accent);
  border-radius: var(--r);
  color: var(--text);
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
  font-family: inherit;
}
.case-item {
  padding: 8px 10px;
  border-radius: var(--r);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
  transition: background .1s;
  border: 1px solid transparent;
  min-width: 0;
}
.case-item:hover  { background: var(--bg-hover); }
.case-item.active { background: var(--accent-dim); border-color: rgba(79,142,247,.4); }
.case-icon  { font-size: 12px; flex-shrink: 0; }
.case-title { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.case-count { font-size: 10px; color: var(--text-muted); background: rgba(255,255,255,.06); border-radius: 3px; padding: 1px 5px; flex-shrink: 0; }
.case-actions { display: none; gap: 2px; flex-shrink: 0; }
.case-item:hover .case-actions,
.case-item.active .case-actions { display: flex; }
.btn-case-action {
  background: none; border: none; color: var(--text-muted);
  font-size: 11px; padding: 2px 4px; border-radius: 3px; cursor: pointer; line-height: 1;
}
.btn-case-action:hover { color: var(--text); background: rgba(255,255,255,.1); }
.btn-case-delete:hover { color: var(--danger); }

/* ── Left: エントリサブヘッダー ─────────────────────────────── */
.panel-subheader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px 7px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(79,142,247,.06);
  flex-shrink: 0;
  gap: 6px;
  min-width: 0;
}
.subheader-title {
  font-size: 11px; font-weight: 600; color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1;
}
.subheader-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }

/* フィルター */
.filter-select {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-muted);
  padding: 3px 6px;
  font-size: 11px;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  max-width: 56px;
}
.filter-select:focus { border-color: var(--accent); color: var(--text); }
.filter-select option { background: var(--bg-card); }

/* ケースステータス */
.case-status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0; cursor: pointer;
  transition: transform .12s;
}
.case-status-dot:hover { transform: scale(1.6); }
.status-open       { background: var(--text-muted); }
.status-consulting { background: var(--warning); }
.status-resolved   { background: var(--success); }

/* ── 検索バー ───────────────────────────────────────────────── */
#search-bar {
  padding: 5px 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}
.search-input {
  width: 100%;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  padding: 5px 9px;
  font-size: 12px;
  outline: none;
  font-family: inherit;
}
.search-input:focus { border-color: var(--accent); background: rgba(79,142,247,.04); }

/* ── 移動行 ─────────────────────────────────────────────────── */
.move-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--warning-dim);
  border-bottom: 1px solid rgba(232,197,109,.25);
  flex-shrink: 0;
}
.move-label { font-size: 11px; color: var(--warning); white-space: nowrap; }

/* ── Markdownプレビュー ─────────────────────────────────────── */
.btn-md-toggle {
  background: none; border: none;
  font-size: 10px; color: var(--text-muted);
  cursor: pointer; padding: 1px 5px;
  border-radius: 3px; margin-left: 6px;
  font-family: inherit;
  vertical-align: middle;
}
.btn-md-toggle:hover { background: rgba(255,255,255,.08); color: var(--accent); }
.btn-md-toggle.active { color: var(--accent); background: var(--accent-dim); }

/* 音声入力ボタン */
.btn-voice {
  background: rgba(255,255,255,.06); border: 1px solid var(--border);
  font-size: 21px; color: var(--text);
  cursor: pointer; padding: 4px 10px;
  border-radius: 4px; margin-left: 6px;
  font-family: inherit; vertical-align: middle;
  transition: color .12s, background .12s;
}
.btn-voice:hover { background: rgba(255,255,255,.12); color: var(--accent); }
.btn-voice.recording {
  color: var(--danger);
  background: var(--danger-dim);
  animation: voice-pulse .7s ease-in-out infinite alternate;
}
@keyframes voice-pulse {
  from { opacity: 1; }
  to   { opacity: .45; }
}

.md-preview {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 9px 10px;
  font-size: 13px;
  line-height: 1.75;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 4px;
  color: var(--text);
}
.md-preview p  { margin-bottom: 6px; }
.md-preview ul { padding-left: 18px; margin-bottom: 6px; }
.md-preview li { margin-bottom: 2px; }
.md-preview strong { color: var(--text); font-weight: 600; }
.md-preview em     { color: var(--text-muted); font-style: italic; }

/* ── 次のステップパネル ─────────────────────────────────────── */
.next-steps { padding: 14px; }
.next-steps-title {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--text-muted); margin-bottom: 6px;
  padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.next-steps-sub {
  font-size: 11px; color: var(--text-muted);
  margin-bottom: 14px; line-height: 1.6;
}
.next-step-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; margin-bottom: 6px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: var(--r);
  text-decoration: none; color: var(--text);
  font-size: 12px;
  transition: background .1s, border-color .1s;
}
.next-step-item:hover {
  background: var(--bg-hover); border-color: rgba(79,142,247,.35);
}
.ns-icon { font-size: 18px; flex-shrink: 0; }
.next-step-item strong { display: block; font-size: 12px; font-weight: 600; }
.next-step-item span { font-size: 10px; color: var(--text-muted); }
.next-steps-note {
  font-size: 10px; color: var(--text-muted);
  margin-top: 12px; padding: 7px 10px;
  background: var(--accent-dim); border-radius: var(--r);
  line-height: 1.6;
}

/* ── 同期インジケーター ─────────────────────────────────────── */
.sync-status {
  font-size: 10px; color: var(--text-muted);
  padding: 2px 8px; border-radius: 4px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.sync-status.ok    { color: var(--success); }
.sync-status.error { color: var(--danger); }

/* ── Left: タイムライン ─────────────────────────────────────── */
#timeline-list { flex: 1; overflow-y: auto; padding: 6px; }

.ti {
  padding: 9px 10px;
  border-radius: var(--r);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 2px;
  transition: background .1s;
  position: relative;
}
.ti:hover  { background: var(--bg-hover); }
.ti.active { background: var(--accent-dim); border-color: rgba(79,142,247,.4); }

.ti-header { display: flex; align-items: center; gap: 7px; margin-bottom: 2px; }

.ev-dot {
  width: 7px; height: 7px;
  border-radius: 50%; flex-shrink: 0;
}
.ev-dot.high    { background: var(--ev-high); }
.ev-dot.medium  { background: var(--ev-medium); }
.ev-dot.low     { background: var(--ev-low); }
.ev-dot.unknown { background: var(--ev-unknown); }

.ti-title { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ti-date  { font-size: 15px; color: var(--text-muted); padding-left: 14px; }
.ti-ai    { position: absolute; top: 6px; right: 7px; font-size: 9px; background: var(--accent-dim); color: var(--accent); border-radius: 3px; padding: 1px 4px; }

.panel-empty { padding: 30px 12px; text-align: center; color: var(--text-muted); font-size: 12px; line-height: 1.9; }

/* ── Center: フォーム ───────────────────────────────────────── */
#entry-form { flex: 1; overflow-y: auto; padding: 16px; }

.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 19px; font-weight: 700;
  color: var(--text-muted); margin-bottom: 6px;
}
.req { color: var(--danger); margin-left: 2px; }

.form-group input[type="text"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  padding: 9px 11px;
  font-size: 20px;
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  background: rgba(79,142,247,.04);
}
.form-group textarea { resize: vertical; min-height: 56px; }
.form-group select {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%236b7a99' d='M5 7L0 2h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 28px;
}
input[type="date"] { color-scheme: dark; }

/* 証拠タグ */
#evidence-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; min-height: 4px; }
/* 証拠カード（v3.3） */
#evidence-tags { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.ev-card {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 5px 8px;
  font-size: 12px;
  min-width: 0;
}
.ev-card-icon { flex: 0 0 auto; font-size: 15px; }
.ev-card-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-card-status {
  flex: 0 0 auto;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 3px;
  white-space: nowrap;
}
.ev-s-confirmed { background: rgba(90,173,122,.18); color: var(--ev-high); }
.ev-s-planned   { background: rgba(232,197,109,.15); color: var(--warning); }
.ev-s-lost      { background: rgba(196,123,123,.15); color: var(--danger); }
.ev-card-x { flex: 0 0 auto; cursor: pointer; color: var(--text-muted); font-size: 14px; padding: 0 2px; line-height: 1; }
.ev-card-x:hover { color: var(--danger); }

/* 証拠ヒント */
.ev-hint {
  font-size: 18px; color: var(--text-muted);
  background: rgba(79,142,247,.07);
  border: 1px solid rgba(79,142,247,.2);
  border-radius: var(--r);
  padding: 8px 11px; margin-bottom: 10px;
  line-height: 1.6;
}
.ev-hint strong { color: var(--accent); }

/* 証拠入力行 */
.ev-input-row { display: flex; gap: 6px; }
.ev-input-row input { flex: 1; min-width: 0; }
.ev-type-select {
  flex: 0 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r);
  padding: 4px 6px;
  font-size: 11px;
  cursor: pointer;
  max-width: 130px;
}
.ev-status-row {
  display: flex; gap: 12px; margin-top: 5px; flex-wrap: wrap;
}
.ev-status-opt {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-muted); cursor: pointer;
}
.ev-status-opt input { cursor: pointer; accent-color: var(--accent); }

/* 旧スタイル互換 */
.ev-tag { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-dim); border: 1px solid rgba(79,142,247,.3); border-radius: 4px; padding: 2px 8px; font-size: 11px; }
.ev-tag-x { cursor: pointer; color: var(--text-muted); font-size: 13px; line-height: 1; }
.ev-tag-x:hover { color: var(--danger); }

/* AI分析 */
.analyze-section {
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.sb-cost-note { font-size: 11px; color: var(--text-muted); }

/* ── Right: AI結果 ─────────────────────────────────────────── */
#analysis-content { flex: 1; overflow-y: auto; padding: 14px; }

.ai-sec { margin-bottom: 18px; }
.ai-sec-title {
  font-size: 19px; font-weight: 700;
  letter-spacing: .3px;
  color: var(--text-muted); margin-bottom: 8px;
  padding-bottom: 5px; border-bottom: 1px solid var(--border);
}
.ai-sec-title.danger  { color: var(--danger); }
.ai-sec-title.warning { color: var(--warning); }
.ai-items { display: flex; flex-direction: column; gap: 7px; }
.ai-item {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 13px; font-size: 21px; line-height: 1.65;
}
.ai-item.danger  { border-color: rgba(196,123,123,.35); background: var(--danger-dim); }
.ai-item.warning { border-color: rgba(232,197,109,.35); background: var(--warning-dim); }
.ai-item.muted   { color: var(--text-muted); font-style: italic; }
.ai-disclaimer {
  margin-top: 16px; padding: 8px 12px;
  background: rgba(107,122,153,.08); border: 1px solid rgba(107,122,153,.2);
  border-radius: var(--r); font-size: 10px; color: var(--text-muted); text-align: center;
}

/* ── Buttons ───────────────────────────────────────────────── */
button { cursor: pointer; border: none; border-radius: var(--r); transition: opacity .12s, background .12s; white-space: nowrap; padding: 7px 14px; font-size: 13px; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-primary      { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #3a7ae8; }
.btn-danger       { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-ghost { background: rgba(255,255,255,.06); color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: rgba(255,255,255,.1); color: var(--text); }
.btn-pdf { background: rgba(90,173,122,.15); color: var(--ev-high); border: 1px solid rgba(90,173,122,.35); font-weight: 600; }
.btn-pdf:hover { background: rgba(90,173,122,.25); }
.btn-analyze {
  background: linear-gradient(135deg, #4f8ef7, #8b5cf6);
  color: #fff; border: none; border-radius: var(--r);
  padding: 10px 20px; font-size: 14px; font-weight: 500;
  cursor: pointer; display: flex; align-items: center; gap: 8px; transition: opacity .15s;
}
.btn-analyze:hover:not(:disabled) { opacity: .88; }
.btn-analyze:disabled { opacity: .45; cursor: not-allowed; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a4460; }

/* ── Animation ─────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinning { display: inline-block; animation: spin .8s linear infinite; }

/* ── SBチャージリンク ───────────────────────────────────────── */
.sb-charge-link {
  font-size: 10px; font-weight: 700;
  color: var(--warning);
  background: rgba(232,197,109,.12);
  border: 1px solid rgba(232,197,109,.3);
  border-radius: 4px;
  padding: 2px 7px;
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s;
}
.sb-charge-link:hover { background: rgba(232,197,109,.22); }

/* ── トースト通知 ────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .22s, transform .22s;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-info    { background: var(--bg-card);           border: 1px solid var(--border); color: var(--text); }
.toast-success { background: rgba(90,173,122,.18);     border: 1px solid var(--success); color: var(--success); }
.toast-error   { background: rgba(196,123,123,.18);    border: 1px solid var(--danger);  color: var(--danger); }
.toast-warning { background: rgba(232,197,109,.15);    border: 1px solid var(--warning); color: var(--warning); }

/* ── 確認・入力ダイアログ ───────────────────────────────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}
.dialog-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
  animation: dialogIn .18s ease;
}
@keyframes dialogIn {
  from { opacity: 0; transform: scale(.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}
.dialog-msg {
  font-size: 14px; line-height: 1.75;
  color: var(--text); margin-bottom: 20px;
  white-space: pre-wrap;
}
.dialog-input {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--accent);
  border-radius: var(--r);
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  margin-bottom: 16px;
}
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── モバイルタブ（デスクトップでは非表示） ─────────────────── */
#mobile-tabs { display: none; }

/* ── スマホ対応 ─────────────────────────────────────────────── */
@media (max-width: 768px) {

  body   { overflow: auto; height: auto; padding-bottom: 56px; }
  #app   { height: auto; min-height: 100vh; }
  #toast-container { bottom: 72px; } /* タブの上 */

  #main {
    display: block;
    height: calc(100dvh - var(--header-h) - 56px);
    overflow: hidden;
    position: relative;
  }

  /* パネルは絶対配置で重ねる */
  #main > aside,
  #main > section {
    position: absolute !important;
    inset: 0;
    display: none !important;
    border-right: none;
    border-left: none;
  }
  .mobile-panel-active { display: flex !important; }

  /* ヘッダーを小さく */
  #header { padding: 0 10px; gap: 6px; }
  .header-brand .brand-tagline { display: none; }
  .header-notice { display: none; }
  .user-name { display: none; }

  /* ケースリストの高さ調整 */
  #case-list { max-height: 38%; }

  /* ボトムタブ */
  #mobile-tabs {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 56px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    z-index: 200;
  }
  .mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    border-radius: 0;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 0;
    transition: color .12s;
    white-space: nowrap;
  }
  .mt-icon  { font-size: 20px; line-height: 1; }
  .mt-label { font-size: 9px; letter-spacing: .3px; }
  .mobile-tab.active { color: var(--accent); }

  /* フォーム余白を詰める */
  #entry-form { padding: 12px; }
  .form-row { grid-template-columns: 1fr; gap: 8px; }
}
