/* ===========================
   Theme Variables
   =========================== */

/* ダークテーマ (デフォルト) */
:root,
[data-theme="dark"] {
  --bg-primary: #08080d;
  --bg-secondary: #101018;
  --bg-tertiary: #181824;
  --bg-elevated: #1e1e2e;
  --bg-hover: #24243a;
  --bg-active: #2c2c48;
  --border: #262640;
  --border-subtle: #1e1e34;
  --border-focus: #5b8def;
  --text-primary: #e6e6f0;
  --text-secondary: #8e8ea8;
  --text-muted: #5c5c74;
  --accent: #5b8def;
  --accent-hover: #7aa4ff;
  --accent-dim: rgba(91, 141, 239, 0.12);
  --accent-glow: rgba(91, 141, 239, 0.06);
  --danger: #ef5b5b;
  --danger-dim: rgba(239, 91, 91, 0.12);
  --success: #5bef8d;
  --success-dim: rgba(91, 239, 141, 0.12);
  --warning: #efcf5b;
  --warning-dim: rgba(239, 207, 91, 0.12);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
  --overlay: rgba(0, 0, 0, 0.65);
  --input-bg: var(--bg-primary);
}

/* ライトテーマ */
[data-theme="light"] {
  --bg-primary: #f4f4f8;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eaeaf0;
  --bg-elevated: #ffffff;
  --bg-hover: #e8e8f0;
  --bg-active: #dddde8;
  --border: #d0d0dc;
  --border-subtle: #e0e0ea;
  --border-focus: #4a7ae0;
  --text-primary: #1a1a2e;
  --text-secondary: #5a5a74;
  --text-muted: #8a8aa0;
  --accent: #4a7ae0;
  --accent-hover: #3a68d0;
  --accent-dim: rgba(74, 122, 224, 0.1);
  --accent-glow: rgba(74, 122, 224, 0.04);
  --danger: #dc4444;
  --danger-dim: rgba(220, 68, 68, 0.1);
  --success: #2da85a;
  --success-dim: rgba(45, 168, 90, 0.1);
  --warning: #c4a020;
  --warning-dim: rgba(196, 160, 32, 0.1);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --overlay: rgba(0, 0, 0, 0.4);
  --input-bg: #f8f8fc;
}

/* ===========================
   Shared Design Tokens
   =========================== */
:root {
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --font-body: 'Noto Sans JP', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition-fast: 0.12s ease;
  --transition-normal: 0.2s ease;
}

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

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition-normal), color var(--transition-normal);
}

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

/* ===========================
   App Layout
   =========================== */
#app {
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: 48px;
}

/* ===========================
   Header
   =========================== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background var(--transition-normal);
}

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

.header-logo {
  color: var(--accent);
}

.header-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ===========================
   Icon Button
   =========================== */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* テーマトグルアイコン */
[data-theme="dark"] .icon-sun { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: inline; }

/* ===========================
   Main Content
   =========================== */
.main {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===========================
   Search Section
   =========================== */
.search-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-input-wrap {
  position: relative;
}

.search-icon-left {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
}

.search-input {
  width: 100%;
  padding: 13px 40px 13px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal), background var(--transition-normal);
}
.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-dim), var(--shadow-sm);
  background: var(--bg-secondary);
}
.search-input::placeholder {
  color: var(--text-muted);
}

.clear-input-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 50%;
  line-height: 1;
  transition: all var(--transition-fast);
}
.clear-input-btn:hover {
  color: var(--text-primary);
  background: var(--bg-active);
}

/* ===========================
   Input Sub Hint
   =========================== */
.input-sub-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 0 4px;
  line-height: 1.4;
}

/* ===========================
   Input Suggest (条件移動提案)
   =========================== */
.input-suggest {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fadeIn 0.15s ease;
}
.suggest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--warning-dim);
  border: 1px solid rgba(239, 207, 91, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.suggest-item code {
  font-family: var(--font-mono);
  color: var(--warning);
  font-size: 0.72rem;
}
.suggest-move {
  padding: 3px 10px;
  border: 1px solid var(--warning);
  border-radius: 100px;
  background: transparent;
  color: var(--warning);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}
.suggest-move:hover {
  background: var(--warning);
  color: var(--bg-primary);
}

/* ===========================
   Quick Bar
   =========================== */
.quick-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.quick-bar::-webkit-scrollbar { display: none; }

.quick-chip {
  flex-shrink: 0;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.quick-chip:hover,
.quick-chip.is-active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* ===========================
   Quick Input Area
   =========================== */
.quick-input-area {
  animation: slideDown 0.2s ease;
}
.quick-input-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  animation: slideDown 0.15s ease;
}
.quick-input-row label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}
.quick-input-field {
  display: flex;
  gap: 6px;
}
.quick-input-field input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
}
.quick-input-field input:focus {
  border-color: var(--border-focus);
}
.quick-input-add {
  flex-shrink: 0;
  padding: 7px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}
.quick-input-add:hover {
  background: var(--accent);
  color: #fff;
}

/* ===========================
   Condition Chips
   =========================== */
.condition-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  animation: fadeIn 0.2s ease;
}
.cond-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 10px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cond-chip-del {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 0.55rem;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
.cond-chip-del:hover {
  background: var(--danger-dim);
  color: var(--danger);
}

/* ===========================
   Detail Section Label
   =========================== */
.detail-section-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}
.detail-section-label:first-child {
  border-top: none;
  padding-top: 0;
}

/* ===========================
   Mode Groups ("囲み / 結合方法)
   =========================== */
.mode-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  min-width: 52px;
  letter-spacing: 0.02em;
}
.mode-label-note {
  display: block;
  font-size: 0.58rem;
  color: var(--text-muted);
  font-weight: 400;
  opacity: 0.7;
}

.mode-bar {
  display: flex;
  gap: 4px;
  flex: 1;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 3px;
  border: 1px solid var(--border-subtle);
}

.mode-btn {
  flex: 1;
  padding: 7px 4px;
  border: 1.5px solid transparent;
  border-radius: calc(var(--radius-md) - 2px);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}
.mode-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}
.mode-btn.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* ===========================
   Action Bar
   =========================== */
.action-bar {
  display: flex;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 18px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  flex: 1;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(91, 141, 239, 0.25);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(91, 141, 239, 0.35);
}
.btn-primary:active {
  transform: scale(0.97);
}

[data-theme="light"] .btn-primary {
  box-shadow: 0 2px 8px rgba(74, 122, 224, 0.3);
}

.action-bar-main {
  display: flex;
  flex: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  gap: 1px;
  background: var(--border);
}
.action-bar-main .btn-primary {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  flex: 3;
}
.btn-compare {
  flex: 2;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.82rem;
}
.btn-compare:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.btn-compare:active {
  transform: scale(0.97);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.btn-secondary.is-open {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  width: 100%;
}
.btn-ghost:hover {
  color: var(--text-secondary);
  border-color: var(--text-muted);
}

.btn-small {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-small:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.btn-small.btn-danger {
  border-color: rgba(239, 91, 91, 0.3);
  color: var(--danger);
}
.btn-small.btn-danger:hover {
  background: var(--danger-dim);
}

/* ===========================
   URL Copy Button (メイン機能)
   =========================== */
.url-copy-wrap {
  animation: fadeIn 0.2s ease;
}

.btn-url-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 18px;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-url-copy:hover {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px rgba(91, 141, 239, 0.3);
}
.btn-url-copy:active {
  transform: scale(0.98);
}
.btn-url-copy.is-copied {
  background: var(--success-dim);
  border-color: var(--success);
  color: var(--success);
}

[data-theme="light"] .btn-url-copy:hover {
  box-shadow: 0 2px 12px rgba(74, 122, 224, 0.25);
}

/* ===========================
   Query Preview
   =========================== */
.query-preview {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  animation: fadeIn 0.2s ease;
  border-left: 3px solid var(--accent);
}

.query-preview-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.query-preview-text {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent);
  background: var(--bg-primary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  word-break: break-all;
  line-height: 1.55;
  user-select: all;
  border: 1px solid var(--border-subtle);
}

.query-preview-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ===========================
   Detail Modal Actions & Fields
   =========================== */
.detail-modal-actions {
  display: flex;
  gap: 8px;
}
.detail-modal-actions .btn-primary {
  flex: 3;
}
.detail-modal-actions .btn-compare {
  flex: 2;
  border-radius: var(--radius-md);
}
.detail-url-copy {
  margin-top: -4px;
}

.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.detail-field label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.label-note {
  font-size: 0.65rem;
  color: var(--warning);
  font-weight: 400;
}
.detail-field input[type="text"],
.detail-field input[type="number"],
.detail-field input[type="date"],
.detail-field select {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  transition: border-color var(--transition-normal), background var(--transition-normal);
}
.detail-field input:focus,
.detail-field select:focus {
  border-color: var(--border-focus);
  background: var(--bg-secondary);
}

.detail-row {
  display: flex;
  gap: 10px;
}
.detail-field.half { flex: 1; min-width: 0; }
.detail-field.third { flex: 1; min-width: 0; }
.detail-field.third input[type="number"] {
  width: 100%;
}

/* 期間プリセット */
.preset-bar {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.preset-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.preset-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.preset-clear {
  color: var(--text-muted);
}
.preset-clear:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-dim);
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.84rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* ===========================
   History / Favorites
   =========================== */
.history-section {
  display: flex;
  flex-direction: column;
}

.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px 8px;
}
.list-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.list-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.84rem;
  padding: 28px 10px;
}

.list-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.list-item:hover {
  background: var(--bg-hover);
  border-color: var(--accent-dim);
}
.list-item:active {
  background: var(--bg-active);
}

.list-item-body {
  flex: 1;
  min-width: 0;
}
.list-item-name {
  font-size: 0.76rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 2px;
}
.list-item-query {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.list-item-btns {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.list-item-load {
  border: none;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.list-item-load:hover {
  background: var(--accent);
  color: #fff;
}

.list-item-del {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.65rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.list-item-del:hover {
  color: var(--danger);
  background: var(--danger-dim);
}

/* ===========================
   Modal
   =========================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.15s ease;
  padding-top: 32px;
}

.modal {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
  transition: background var(--transition-normal);
}
.modal-small { max-height: 60dvh; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.95rem;
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 1;
}

.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.setting-group-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}
.setting-group-label:first-child {
  border-top: none;
  padding-top: 0;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.setting-item label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.setting-item select {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  transition: background var(--transition-normal);
}

.setting-note {
  font-size: 0.73rem;
  color: var(--text-muted);
  line-height: 1.65;
  padding: 10px 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--warning);
}

/* ===========================
   Compare Modal
   =========================== */
.compare-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 4px;
}

.compare-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.compare-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  transition: border-color var(--transition-fast);
}
.compare-card:hover {
  border-color: var(--accent-dim);
}
.compare-card.is-current {
  border-color: var(--accent);
  border-width: 1.5px;
}

.compare-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.compare-card-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}
.compare-card-badge {
  font-size: 0.62rem;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 100px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.compare-card-badge.badge-current {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}
.compare-card-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.compare-card-query {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--accent);
  background: var(--bg-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  word-break: break-all;
  line-height: 1.45;
  border: 1px solid var(--border-subtle);
  margin-bottom: 6px;
}

.compare-card-actions {
  display: flex;
  gap: 6px;
}

/* ===========================
   Toast
   =========================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.25s;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ===========================
   Animations
   =========================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ===========================
   Responsive
   =========================== */
@media (min-width: 540px) {
  #app { padding-top: 12px; }
  .header {
    border-radius: var(--radius-lg);
    margin: 0 8px;
  }
  .main { padding: 20px; }
  .modal {
    border-radius: var(--radius-xl);
    margin-bottom: 40px;
  }
  .modal-overlay { align-items: center; }
}
