/* ===== Variables ===== */
:root {
  --topbar-h:   44px;
  --status-h:   26px;
  --sidebar-w:  320px;

  --bg-topbar:  #1c1c1e;
  --bg-page:    #f5f5f5;
  --bg-panel:   #ffffff;
  --bg-sidebar: #f9fafb;
  --border:     #e0e0e0;
  --border-md:  #d1d5db;

  --text:       #111827;
  --text-sub:   #6b7280;
  --text-muted: #9ca3af;

  --accent:     #2563eb;
  --accent-h:   #1d4ed8;

  /* 品詞カラー: bg / text */
  --noun:   #e0eeff, #1a56db;
  --verb:   #e6f4ea, #1e7e34;
  --adj:    #fef9c3, #92400e;
  --adjv:   #fff0e0, #b45309;
  --adv:    #f5f0ff, #6d28d9;
  --part:   #e0faf4, #0f766e;
  --aux:    #fce7f3, #9d174d;
  --conj:   #fefce8, #78350f;
  --intj:   #fee2e2, #b91c1c;
  --pre:    #eef2ff, #3730a3;
  --sym:    #f3f4f6, #374151;
  --fill:   #fdf0ff, #a21caf;
  --other:  #f8fafc, #475569;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
               "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-page);
}

/* ===== App Grid ===== */
.app {
  display: grid;
  grid-template-rows: var(--topbar-h) auto 1fr var(--status-h);
  height: 100vh;
  overflow: hidden;
}

/* ===== Topbar ===== */
.topbar {
  background: var(--bg-topbar);
  color: #e5e5e5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
  gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.logo { font-size: 13px; font-weight: 600; letter-spacing: 0.01em; }
.logo-sep { color: #555; }
.logo-sub { font-size: 11px; color: #888; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #9ca3af;
}
.dict-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4b5563;
  flex-shrink: 0;
  transition: background 0.3s;
}
.dict-dot.loading { background: #f59e0b; animation: blink 1.2s ease-in-out infinite; }
.dict-dot.ready   { background: #22c55e; animation: none; }
.dict-dot.error   { background: #ef4444; animation: none; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ===== Workspace ===== */
.workspace {
  display: flex;
  overflow: hidden;
}

/* ===== Left Panel ===== */
.panel-input {
  width: var(--sidebar-w);
  min-width: 220px;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-md);
  overflow: hidden;
  flex-shrink: 0;
}
.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.panel-footer {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-sidebar);
  flex-shrink: 0;
}

/* セクション */
.p-sec {}
.p-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-sub);
  margin-bottom: 7px;
}

/* テキストエリア */
.input-textarea {
  width: 100%;
  height: 140px;
  padding: 9px 10px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.7;
  border: 1px solid var(--border-md);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}
.input-textarea:focus { border-color: var(--accent); }
.input-textarea::placeholder { color: var(--text-muted); line-height: 1.9; }
.input-textarea.drag-over {
  border-color: var(--accent);
  background: #eff6ff;
}
.char-count {
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* サンプル */
.sample-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.btn-sample {
  padding: 3px 10px;
  font-size: 11px;
  border: 1px solid var(--border-md);
  border-radius: 3px;
  background: #fff;
  color: var(--text-sub);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.btn-sample:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #eff6ff;
}

/* フィルター */
.filter-ctrl { display: flex; gap: 4px; }
.btn-micro {
  padding: 1px 7px;
  font-size: 10px;
  border: 1px solid var(--border-md);
  border-radius: 3px;
  background: #fff;
  color: var(--text-sub);
  cursor: pointer;
  font-family: inherit;
}
.btn-micro:hover { background: var(--border); color: var(--text); }

.filter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.filter-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s;
}
.filter-item.off { opacity: 0.35; }
.filter-item input[type="checkbox"] {
  width: 11px;
  height: 11px;
  margin: 0;
  cursor: pointer;
  accent-color: currentColor;
}

/* ===== 統計バーチャート ===== */
.stats-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.stat-row {
  display: grid;
  grid-template-columns: 4em 1fr 2.6em;
  align-items: center;
  gap: 7px;
}
.stat-name {
  font-size: 11px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.stat-track {
  height: 6px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.stat-fill { height: 100%; border-radius: 2px; }
.stat-num {
  font-size: 10px;
  color: var(--text-sub);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ===== ボタン ===== */
.btn-analyze {
  flex: 1;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.btn-analyze:hover:not(:disabled) { background: var(--accent-h); }
.btn-analyze:disabled { background: #9ca3af; cursor: not-allowed; }

.btn-clear {
  padding: 8px 14px;
  font-size: 12px;
  border: 1px solid var(--border-md);
  border-radius: 4px;
  background: #fff;
  color: var(--text-sub);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.btn-clear:hover { background: var(--border); color: var(--text); }

/* ===== リサイザー ===== */
.resizer {
  width: 5px;
  background: var(--border-md);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.15s;
  position: relative;
}
.resizer::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 1px;
  height: 32px;
  background: #b0b0b0;
  border-radius: 1px;
}
.resizer:hover, .resizer.dragging { background: #c0c0c0; }

/* ===== 右パネル ===== */
.panel-result {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-panel);
}

/* タブバー */
.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 4px 0 0;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  flex-shrink: 0;
}
.tabs { display: flex; height: 100%; }
.tab {
  display: flex;
  align-items: center;
  padding: 0 18px;
  height: 100%;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-sub);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.12s, border-color 0.12s;
  font-family: inherit;
}
.tab:hover:not(.active) { color: var(--text); background: #f0f0f0; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.toolbar-actions { display: flex; align-items: center; padding-right: 8px; }
.btn-tool {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 11px;
  border: 1px solid var(--border-md);
  border-radius: 3px;
  background: #fff;
  color: var(--text-sub);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.btn-tool:hover { background: var(--border); color: var(--text); }
.btn-tool.copied { border-color: #22c55e; color: #15803d; background: #f0fdf4; }

/* 結果エリア */
.result-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* 空の状態 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-muted);
}
.empty-state svg { opacity: 0.4; }
.empty-state p { font-size: 13px; }
.kbd-hint {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}
kbd {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  font-family: inherit;
  border: 1px solid var(--border-md);
  border-radius: 3px;
  background: #f3f4f6;
  color: var(--text-sub);
}

/* ===== トークン表示 ===== */
.token-display {
  padding: 20px 24px 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 4px 3px;
}

/* 1トークン = 読み / 表層形 / 品詞 の縦積み */
.token {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 5px 8px 5px;
  border-radius: 3px;
  cursor: default;
  position: relative;
  transition: filter 0.12s, opacity 0.15s;
  min-width: 24px;
}
.token:hover { filter: brightness(0.88); z-index: 5; }
.token.pos-hidden { opacity: 0.08; pointer-events: none; }

/* 読み（常に同じ高さを確保して行揃えを統一） */
.tok-read {
  font-size: 9.5px;
  letter-spacing: 0.06em;
  height: 14px;
  line-height: 14px;
  opacity: 0.75;
  white-space: nowrap;
}

/* 表層形 */
.tok-surf {
  font-size: 19px;
  font-weight: 500;
  line-height: 1.2;
  margin: 1px 0;
  white-space: nowrap;
}

/* 品詞ラベル */
.tok-pos {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-top: 3px;
  white-space: nowrap;
  opacity: 0.82;
}

/* .tip はデータ保持用（非表示） — 表示は .global-tip が担う */
.token .tip { display: none; }

/* ===== グローバルツールチップ（position:fixed でビューポート内に収める） ===== */
.global-tip {
  display: none;
  position: fixed;
  z-index: 9999;
  background: #18181b;
  border: 1px solid #3f3f46;
  color: #e4e4e7;
  font-size: 11.5px;
  line-height: 1.5;
  border-radius: 6px;
  white-space: normal;
  min-width: 200px;
  max-width: 310px;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  overflow: hidden;
}
.global-tip.visible { display: block; }

/* 矢印（下向き：トークンの上に表示するとき） */
.global-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: var(--arrow-x, 50%);
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #3f3f46;
}
/* 矢印（上向き：トークンの下に表示するとき） */
.global-tip.tip-below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #3f3f46;
}

/* ---- ツールチップ内部レイアウト ---- */

/* ヘッダー（表層形・読み・語種バッジ） */
.tip-hd {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px 8px;
  border-bottom: 1px solid #3f3f46;
  flex-wrap: wrap;
}
.tip-surf {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  border-left: 3px solid;    /* POS color をインラインで渡す */
  padding-left: 7px;
  line-height: 1.2;
}
.tip-kana {
  font-size: 12px;
  color: #a1a1aa;
  letter-spacing: 0.05em;
}
.tip-pron-diff {          /* 読みと発音が違う場合のみ表示 */
  font-size: 10px;
  color: #71717a;
}
.tip-pron-diff::before { content: '発音 '; color: #52525b; }
.tip-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 3px;
  flex-shrink: 0;
}
.tip-badge.known   { background: #14532d; color: #4ade80; }
.tip-badge.unknown { background: #450a0a; color: #fca5a5; }

/* 詳細テーブル */
.tip-tbl {
  border-collapse: collapse;
  width: 100%;
  padding: 7px 0 5px;
  display: block;
}
.tip-tbl tr { display: flex; padding: 2px 12px; }
.tip-tbl tr:hover { background: #27272a; }
.tip-k {
  width: 60px;
  flex-shrink: 0;
  font-size: 10px;
  color: #71717a;
  padding-top: 1px;
  font-weight: 500;
}
.tip-v {
  font-size: 11.5px;
  color: #d4d4d8;
  word-break: break-all;
}
.tip-pos-chain {          /* 品詞 › 細分類 の連鎖 */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
}
.tip-pos-chain .tip-pos-main {
  font-weight: 700;
  color: #e4e4e7;
}
.tip-pos-chain .tip-pos-sep { color: #52525b; font-size: 10px; }
.tip-pos-chain .tip-pos-sub { color: #a1a1aa; }

/* 区切り線 */
.tip-divider {
  height: 1px;
  background: #3f3f46;
  margin: 4px 0;
}

/* 文中位置・語ID（薄め） */
.tip-meta {
  padding: 4px 12px 6px;
  font-size: 10px;
  color: #52525b;
  display: flex;
  gap: 14px;
  border-top: 1px solid #27272a;
}

/* ===== テーブル ===== */
.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.result-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}
.result-table th {
  background: #f8f9fa;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-sub);
  text-align: left;
  padding: 9px 12px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.result-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.result-table tbody tr:hover { background: #fafbff; }
.result-table tr.row-hidden { display: none; }
.col-num { width: 40px; }
.result-table td:first-child {
  color: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.cell-surface { font-size: 14px; font-weight: 600; }

/* テーブル内品詞バッジ */
.pos-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px 2px 5px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.pos-dot { width: 6px; height: 6px; border-radius: 50%; }

/* ===== ステータスバー ===== */
.statusbar {
  background: var(--bg-topbar);
  color: #888;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11px;
  border-top: 1px solid #333;
  flex-shrink: 0;
}

/* ===== Topbar ボタン ===== */
.btn-topbar {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid #444;
  border-radius: 3px;
  background: transparent;
  color: #ccc;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.btn-topbar:hover { background: #333; color: #fff; }
.btn-debug-copy { border-color: #7c3aed; color: #a78bfa; }
.btn-debug-copy:hover { background: #2d1b69; color: #c4b5fd; }
.btn-debug-copy.copied { background: #1a3a1a; color: #4ade80; border-color: #16a34a; }

.btn-back{
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid #73f1ff;
  border-radius: 3px;
  background: transparent;
  color: #ccc;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
}

/* ===== 比較タブバッジ ===== */
.compare-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  font-size: 9px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  vertical-align: middle;
}

/* ===== エンジンリスト ===== */
.engine-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.engine-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  transition: background 0.1s;
}
.engine-item:hover { background: #f0f4ff; }
.engine-item input[type="checkbox"] {
  width: 13px; height: 13px; margin: 0; cursor: pointer; flex-shrink: 0;
  accent-color: var(--accent);
}
.engine-item input:disabled { opacity: 0.4; cursor: default; }
.engine-item-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.engine-item-status {
  font-size: 10px;
  color: var(--text-muted);
}

/* エンジン状態ドット */
.engine-status-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: #9ca3af;
  transition: background 0.2s;
}
.engine-status-dot.loading { background: #f59e0b; animation: blink 1.2s ease-in-out infinite; }
.engine-status-dot.ready   { background: #22c55e; }
.engine-status-dot.error   { background: #ef4444; }
.engine-status-dot.idle    { background: #9ca3af; }

/* ===== 比較ビュー ===== */
.compare-panels {
  display: flex;
  gap: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  min-height: 120px;
  max-height: 45vh;
}
.compare-panel {
  display: flex;
  flex-direction: column;
  min-width: 260px;
  flex: 1;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.compare-panel:last-child { border-right: none; }

.compare-panel-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.compare-engine-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
}
.compare-token-count {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
}

.compare-token-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 3px 2px;
  align-content: flex-start;
}

/* コンパクトトークン（比較ビュー用） */
.token-compact { padding: 3px 5px; }
.token-compact .tok-read { font-size: 8px; height: 11px; line-height: 11px; }
.token-compact .tok-surf { font-size: 13px; }
.token-compact .tok-pos  { font-size: 8px; margin-top: 2px; }

.compare-error {
  color: #ef4444;
  font-size: 11px;
  padding: 12px;
  line-height: 1.6;
}
.compare-error-hint { color: var(--text-muted); font-size: 10px; }
.compare-loading { padding: 24px; color: var(--text-muted); font-size: 12px; }
.compare-empty   { padding: 24px; color: var(--text-muted); font-size: 12px; }
.compare-note    { padding: 12px 16px; font-size: 11px; color: var(--text-sub); background: #fffbeb; border-top: 1px solid #fde68a; }

/* ===== 差分テーブル ===== */
.diff-section { overflow: auto; }

.diff-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  flex-wrap: wrap;
}
.diff-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  margin-right: 4px;
}
.diff-summary-item {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}
.diff-summary-item.agree    { background: #dcfce7; color: #15803d; }
.diff-summary-item.pos-diff { background: #fef9c3; color: #92400e; }
.diff-summary-item.seg-diff { background: #fee2e2; color: #b91c1c; }
.diff-summary-total { font-size: 10px; color: var(--text-muted); margin-left: auto; }

.diff-table-wrap { overflow-x: auto; }
.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}
.diff-table th {
  background: #f8f9fa;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-sub);
  text-align: left;
  padding: 7px 12px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
}
.diff-th-status { width: 46px; text-align: center; }
.diff-table td { padding: 5px 10px; border-bottom: 1px solid #f0f0f0; vertical-align: top; }

.diff-row-agree td { background: #f0fdf4; }
.diff-row-pos   td { background: #fefce8; }
.diff-row-seg   td { background: #fff5f5; }
.diff-row-agree:hover td { background: #dcfce7; }
.diff-row-pos:hover   td { background: #fef9c3; }
.diff-row-seg:hover   td { background: #fee2e2; }

.diff-cell-text { min-width: 60px; }
.diff-text-chip {
  display: inline-block;
  padding: 2px 6px;
  background: #f1f5f9;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.diff-engine-td { min-width: 130px; }
.diff-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin: 1px 2px;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  background: #f8fafc;
}
.diff-chip-surf { font-size: 13px; font-weight: 600; color: var(--text); }
.diff-chip-pos  { font-size: 9px;  font-weight: 700; }
.diff-na        { color: var(--text-muted); font-size: 11px; }

.diff-status-td { text-align: center; }
.diff-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}
.diff-status-icon.agree    { background: #dcfce7; color: #15803d; }
.diff-status-icon.pos-diff { background: #fef9c3; color: #92400e; }
.diff-status-icon.seg-diff { background: #fee2e2; color: #b91c1c; }

/* ===== モーダル ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: #fff;
  border-radius: 8px;
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  flex-shrink: 0;
}
.modal-title { font-size: 13px; font-weight: 700; }
.modal-close {
  width: 26px; height: 26px;
  border: none; border-radius: 4px; background: transparent;
  color: var(--text-sub); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #f0f0f0; color: var(--text); }
.modal-body   { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: #fafafa; flex-shrink: 0; }

.api-config {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
}
.api-config-head { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.api-name { font-size: 12px; font-weight: 700; }
.api-desc { font-size: 11px; color: var(--text-sub); margin-bottom: 8px; line-height: 1.5; }
.api-input-row { display: flex; gap: 8px; align-items: center; }
.api-key-input {
  flex: 1;
  padding: 6px 9px;
  font-size: 12px;
  border: 1px solid var(--border-md);
  border-radius: 4px;
  outline: none;
  font-family: 'Consolas', monospace;
  transition: border-color 0.12s;
}
.api-key-input:focus { border-color: var(--accent); }
.api-link {
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
  text-decoration: none;
}
.api-link:hover { text-decoration: underline; }
.api-note {
  font-size: 10.5px;
  color: var(--text-sub);
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 4px;
  padding: 8px 10px;
  line-height: 1.6;
}

.btn-save {
  padding: 7px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-save:hover { background: var(--accent-h); }
.btn-modal-cancel {
  padding: 7px 14px;
  background: #fff;
  color: var(--text-sub);
  border: 1px solid var(--border-md);
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.btn-modal-cancel:hover { background: var(--border); }

/* ===== スクロールバー ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ===== 品詞カラー定義（クラスベース） ===== */
.pos-名詞    { background: #e0eeff; color: #1a56db; }
.pos-動詞    { background: #e6f4ea; color: #1e7e34; }
.pos-形容詞  { background: #fef9c3; color: #92400e; }
.pos-形容動詞{ background: #fff0e0; color: #b45309; }
.pos-副詞    { background: #f5f0ff; color: #6d28d9; }
.pos-助詞    { background: #e0faf4; color: #0f766e; }
.pos-助動詞  { background: #fce7f3; color: #9d174d; }
.pos-接続詞  { background: #fefce8; color: #78350f; }
.pos-感動詞  { background: #fee2e2; color: #b91c1c; }
.pos-接頭詞  { background: #eef2ff; color: #3730a3; }
.pos-記号    { background: #f3f4f6; color: #374151; }
.pos-フィラー{ background: #fdf0ff; color: #a21caf; }
.pos-その他  { background: #f8fafc; color: #475569; }

/* ===== レスポンシブ (スマホ) ===== */
.mobile-panel-tabs { display: none; }

@media (max-width: 768px) {

  /* --- Topbar --- */
  .topbar { padding: 0 10px; }
  .logo-sub { display: none; }
  #dictStatusText { display: none; }
  .btn-debug-copy { display: none; }

  /* --- モバイルパネル切替タブ --- */
  .mobile-panel-tabs {
    display: flex;
    background: var(--bg-topbar);
    border-bottom: 1px solid #333;
  }
  .mobile-tab {
    flex: 1;
    padding: 11px;
    font-size: 13px;
    font-weight: 600;
    color: #888;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.12s, border-color 0.12s;
  }
  .mobile-tab.active { color: #fff; border-bottom-color: var(--accent); }

  /* --- Workspace: 縦積み --- */
  .workspace { flex-direction: column; }

  /* --- リサイザーを非表示 --- */
  .resizer { display: none; }

  /* --- 左パネル: フル幅 --- */
  .panel-input {
    width: 100%;
    min-width: unset;
    max-width: unset;
    border-right: none;
    flex: 1;
  }

  /* --- 右パネル: フル幅 --- */
  .panel-result { flex: 1; }

  /* --- タップ領域を拡大 --- */
  .btn-analyze { padding: 12px; font-size: 14px; }
  .btn-clear   { padding: 12px 16px; font-size: 13px; }
  .btn-sample  { padding: 7px 13px; font-size: 12px; }
  .btn-micro   { padding: 4px 10px; font-size: 11px; }
  .filter-item { padding: 6px 10px 6px 7px; font-size: 12px; }
  .engine-item { padding: 8px 10px; }
  .engine-item input[type="checkbox"] { width: 16px; height: 16px; }

  /* --- テキストエリア --- */
  .input-textarea { height: 180px; font-size: 14px; }

  /* --- トークン表示 --- */
  .tok-surf { font-size: 20px; }

  /* --- テーブル: 横スクロール --- */
  .result-body { overflow-x: auto; }
  .result-table { min-width: 580px; }

  /* --- ステータスバー右側を隠す --- */
  #statusRight { display: none; }

  /* --- モーダル --- */
  .modal { width: 95vw; }

  /* --- キーボードヒントを非表示 --- */
  .kbd-hint { display: none; }
}

/* ===== Dark Mode ===== */
html[data-theme="dark"] {
  --bg-page:    #0f172a;
  --bg-panel:   #1e293b;
  --bg-sidebar: #172033;
  --border:     #334155;
  --border-md:  #334155;
  --text:       #e2e8f0;
  --text-sub:   #94a3b8;
  --text-muted: #64748b;
}
html[data-theme="dark"] .input-textarea {
  background: #1e293b;
  color: #e2e8f0;
}
html[data-theme="dark"] .input-textarea.drag-over {
  background: #1e3a5f;
}
html[data-theme="dark"] .btn-sample {
  background: #1e293b;
  color: #94a3b8;
}
html[data-theme="dark"] .btn-sample:hover {
  background: #334155;
  color: #3b82f6;
}
html[data-theme="dark"] .btn-micro {
  background: #1e293b;
  color: #94a3b8;
}
html[data-theme="dark"] .btn-micro:hover {
  background: #334155;
  color: #e2e8f0;
}
html[data-theme="dark"] .btn-clear {
  background: #1e293b;
  color: #94a3b8;
}
html[data-theme="dark"] .btn-clear:hover {
  background: #334155;
  color: #e2e8f0;
}
html[data-theme="dark"] .btn-tool {
  background: #1e293b;
  color: #94a3b8;
}
html[data-theme="dark"] .btn-tool:hover {
  background: #334155;
  color: #e2e8f0;
}
html[data-theme="dark"] .btn-tool.copied {
  background: #052e16;
  border-color: #22c55e;
  color: #4ade80;
}
html[data-theme="dark"] .result-toolbar {
  background: #172033;
}
html[data-theme="dark"] .tab:hover:not(.active) {
  background: #334155;
  color: #e2e8f0;
}
html[data-theme="dark"] .resizer::after {
  background: #475569;
}
html[data-theme="dark"] .resizer:hover,
html[data-theme="dark"] .resizer.dragging {
  background: #475569;
}
html[data-theme="dark"] .engine-item {
  background: var(--bg-panel);
  border-color: var(--border);
}
html[data-theme="dark"] .engine-item:hover {
  background: var(--bg-sidebar);
}