/* ==========================================================================
   Nevai Translate - modern, fast, accessible. Light & dark themes.
   Transitions are minimal and silent; disabled for reduced-motion users.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --sidebar-w: 248px;
  --nav-h: 3.25rem;
  --transition: 120ms linear;

  /* Light theme (default) — clean paper white with crisp elevation */
  --bg: #f4f6f9;
  --bg-card: #ffffff;
  --bg-hover: #edf0f4;
  --bg-inset: #f1f3f7;
  --border: #e2e6ec;
  --border-strong: #c9d0da;
  --fg: #14171c;
  --fg-subtle: #3f4a5a;
  --fg-muted: #737e8e;
  --accent: #0f3460;
  --accent-hover: #164a80;
  --accent-soft: rgba(15, 52, 96, 0.08);
  --accent-fg: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 2px 6px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14), 0 2px 8px rgba(16, 24, 40, 0.06);
  color-scheme: light;

  /* Aliases used by newer sections (kept in sync automatically) */
  --surface: var(--bg-card);
  --surface-2: var(--bg-inset);
  --panel: var(--bg-card);
  --text: var(--fg);
  --text-muted: var(--fg-muted);
}

html.dark {
  /* Deep blue-black — rich but easy on the eyes, true OLED-friendly base */
  --bg: #06080c;
  --bg-card: #10141c;
  --bg-hover: #1b2230;
  --bg-inset: #151a26;
  --border: #232c3e;
  --border-strong: #35415a;
  --fg: #e8ecf3;
  --fg-subtle: #9aa5ba;
  --fg-muted: #66738f;
  --accent: #5c97ea;
  --accent-hover: #7cabf0;
  --accent-soft: rgba(92, 151, 234, 0.15);
  --accent-fg: #071018;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.1);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.62);
  color-scheme: dark;
}

html { height: 100%; overflow-y: scroll; }
body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  background:
    radial-gradient(1200px 620px at 50% -8%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%),
    var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--accent); color: var(--accent-fg); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--fg-muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Manual "Reduce animations" control (instant, silent UI) */
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after {
  transition: none !important;
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
}

textarea, input, select, button { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================ Sidebar ============================ */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform 160ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
.sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
.sidebar-overlay {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(8, 10, 14, 0.45);
  opacity: 0; pointer-events: none;
  transition: opacity 140ms linear;
}
.sidebar-overlay.visible { opacity: 1; pointer-events: auto; }

.sidebar-head {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex-shrink: 0;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 80%, #fff 20%), var(--accent-hover));
  color: var(--accent-fg);
  border-radius: 8px; font-weight: 800; font-size: 0.95rem;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--accent) 35%, transparent);
}
.brand-mark.sm { width: 24px; height: 24px; font-size: 0.8rem; border-radius: 6px; }
.brand-name { font-weight: 650; font-size: 0.95rem; letter-spacing: -0.01em; flex: 1; white-space: nowrap; }
.sidebar-close { margin-left: auto; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.625rem 0.625rem 1rem; }
.nav-section-label {
  margin: 0.875rem 0.5rem 0.3rem;
  font-size: 0.65rem; font-weight: 700; color: var(--fg-muted);
  text-transform: uppercase; letter-spacing: 0.09em;
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 0.625rem;
  width: 100%; padding: 0.5rem 0.625rem; margin-bottom: 1px;
  font-size: 0.85rem; font-weight: 500; text-align: left;
  color: var(--fg-subtle); background: transparent;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--bg-hover); color: var(--fg); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.active::before {
  content: ''; position: absolute; left: -0.375rem; top: 20%; bottom: 20%;
  width: 3px; border-radius: 999px; background: var(--accent);
}
.nav-item svg { flex-shrink: 0; }
.nav-badge {
  margin-left: auto; min-width: 1.15rem; height: 1.15rem;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 0.3rem; font-size: 0.65rem; font-weight: 700;
  background: var(--accent); color: var(--accent-fg); border-radius: 999px;
}

.sidebar-foot { border-top: 1px solid var(--border); padding: 0.625rem 0.875rem; }
.nav-theme-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  font-size: 0.8rem; color: var(--fg-subtle);
}
.theme-select {
  height: 1.7rem; font-size: 0.75rem; padding: 0 1.6rem 0 0.5rem;
  background-color: var(--bg-inset); border-radius: var(--radius-sm);
}
.sidebar-version { margin-top: 0.5rem; font-size: 0.68rem; color: var(--fg-muted); text-align: center; }

/* Desktop: floating sidebar always visible */
@media (min-width: 1024px) {
  .sidebar { transform: none; box-shadow: none; }
  .sidebar-overlay { display: none; }
  .sidebar-close { display: none; }
  body { padding-left: calc(var(--sidebar-w) + 10px); }
}

/* ============================ Header (rounded floating pill) ============================ */
.nav {
  position: sticky; top: calc(0.55rem + env(safe-area-inset-top)); z-index: 50;
  margin: 0.55rem 0.75rem 0;
  height: calc(var(--nav-h) + 2px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-md), inset 0 0 0 1px color-mix(in srgb, #ffffff 5%, transparent);
}
.nav-links .icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.nav-inner {
  max-width: 1080px; margin: 0 auto;
  padding: 0 1rem;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.nav-left { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.nav-brand {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-weight: 650; font-size: 0.95rem; letter-spacing: -0.01em;
  color: var(--fg); text-decoration: none !important; white-space: nowrap;
}
.nav-links { display: flex; align-items: center; gap: 0.375rem; }
.nav-group { display: flex; align-items: center; }
.nav-divider {
  width: 1px; height: 1.15rem; margin: 0 0.15rem; flex-shrink: 0;
  background: var(--border-strong); opacity: 0.6;
}

/* Cloud sync status chip */
.sync-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  height: 1.85rem; padding: 0 0.7rem; max-width: 170px;
  font-size: 0.72rem; font-weight: 600; color: var(--fg-subtle);
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: 999px; cursor: pointer; white-space: nowrap; overflow: hidden;
  transition: border-color var(--transition), color var(--transition);
}
.sync-chip:hover { border-color: var(--accent); color: var(--accent); }
.sync-chip .dot { width: 7px; height: 7px; }
.sync-chip-label { overflow: hidden; text-overflow: ellipsis; }
.dot-busy { background: var(--warn) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 22%, transparent) !important; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; flex-shrink: 0;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--fg-subtle); cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--fg); }
.icon-btn svg { width: 16px; height: 16px; }

/* theme icons: show moon in light mode, sun in dark mode */
.icon-sun { display: none; }
html.dark .icon-sun { display: block; }
html.dark .icon-moon { display: none; }

select {
  font-size: 0.8125rem; color: var(--fg);
  background-color: var(--bg-inset);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.4rem 2rem 0.4rem 0.7rem;
  cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a919c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 13px;
  transition: border-color var(--transition);
}
select:hover { border-color: var(--border-strong); }
select:focus-visible { outline: none; border-color: var(--accent); }
.locale-select { height: 2rem; font-size: 0.75rem; padding: 0 1.8rem 0 0.6rem; max-width: 130px; }

/* ============================ Settings dropdown ============================ */
.settings-wrap { position: relative; }
.settings-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 70;
  width: 250px; padding: 0.5rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  display: none; max-height: min(80vh, 480px); overflow-y: auto;
}
.settings-dropdown.open { display: block; }
.settings-item {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.45rem 0.55rem; font-size: 0.82rem; color: var(--fg);
  border-radius: var(--radius-sm); cursor: pointer;
}
.settings-item:hover { background: var(--bg-hover); }
.settings-item label { cursor: pointer; }
.settings-col { flex-direction: column; align-items: stretch; gap: 0.4rem; cursor: default !important; }
.settings-divider { height: 1px; background: var(--border); margin: 0.35rem 0; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 34px; height: 19px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; border-radius: 19px;
  background: var(--border-strong); cursor: pointer;
  transition: background var(--transition);
}
.slider::before {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 15px; height: 15px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm);
  transition: transform var(--transition);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(15px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

.range-input {
  width: 100%; height: 4px; -webkit-appearance: none; appearance: none;
  background: var(--border-strong); border-radius: 2px; outline: none; cursor: pointer;
}
.range-input::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%; background: var(--accent); cursor: pointer; border: none; }
.range-input::-moz-range-thumb { width: 15px; height: 15px; border-radius: 50%; background: var(--accent); cursor: pointer; border: none; }

/* ============================ Layout ============================ */
.app-content { flex: 1; padding: 1.75rem 0 3rem; }
.container { max-width: 860px; margin: 0 auto; padding: 0 1rem; }
.view { animation: none; }

.loading { display: flex; align-items: center; justify-content: center; padding: 5rem; gap: 0.75rem; }
.spinner {
  width: 22px; height: 22px; flex-shrink: 0;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
.spinner.sm { width: 15px; height: 15px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.offline-banner {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.4rem; font-size: 0.78rem; color: #fff; background: var(--danger);
}

.error-banner {
  display: flex; align-items: center; gap: 0.6rem;
  margin-top: 1rem; padding: 0.65rem 1rem;
  background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius); font-size: 0.85rem; color: var(--fg);
}
.error-banner svg { flex-shrink: 0; color: var(--danger); }
.error-banner span { flex: 1; overflow-wrap: anywhere; }
.error-dismiss { background: none; border: none; color: var(--fg-muted); cursor: pointer; font-size: 1.25rem; line-height: 1; padding: 0 0.25rem; }
.error-dismiss:hover { color: var(--fg); }

.alert-banner {
  display: flex; align-items: center; gap: 0.6rem;
  margin-bottom: 1.25rem; padding: 0.65rem 1rem;
  background: rgba(217, 119, 6, 0.08); border: 1px solid rgba(217, 119, 6, 0.25);
  border-radius: var(--radius); font-size: 0.85rem;
}

.view-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.view-head h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.view-head-actions { display: flex; align-items: center; gap: 0.375rem; }

.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.125rem 1.25rem;
  margin-bottom: 1rem; box-shadow: var(--shadow-sm);
}
.card-title { display: flex; align-items: center; gap: 0.45rem; font-size: 0.95rem; font-weight: 700; margin: 0 0 0.875rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.5rem 1rem; font-size: 0.83rem; font-weight: 600;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--bg-inset); color: var(--fg); cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  text-decoration: none !important;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff 12%), var(--accent-hover));
  color: var(--accent-fg);
  box-shadow: 0 1px 2px rgba(16,24,40,.10), 0 6px 16px color-mix(in srgb, var(--accent) 28%, transparent);
  border-color: color-mix(in srgb, var(--accent) 70%, #000 0%);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--accent), var(--accent-hover));
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(16,24,40,.12), 0 10px 22px color-mix(in srgb, var(--accent) 34%, transparent);
}
.btn-primary:active { transform: translateY(0); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 0.32rem 0.65rem; font-size: 0.76rem; }

/* ============================ Tabs (segmented control) ============================ */
.tab-bar {
  display: flex; justify-content: center; gap: 0.15rem;
  margin-bottom: 1.25rem; flex-wrap: nowrap;
  width: 100%; max-width: fit-content;
  margin-left: auto; margin-right: auto;
  padding: 0.25rem;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.45rem 0.85rem; white-space: nowrap;
  font-size: 0.8rem; font-weight: 600;
  border: none; border-radius: 999px;
  background: transparent; color: var(--fg-subtle); cursor: pointer;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--accent); background: var(--accent-soft); }
.tab-btn.active { background: var(--bg-card); color: var(--accent); box-shadow: var(--shadow-sm); }
.tab-btn svg { width: 14px; height: 14px; }

/* Recent pairs */
.recent-pairs { display: flex; justify-content: center; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pair-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.22rem 0.6rem; font-size: 0.7rem; font-weight: 600;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-card); color: var(--fg-subtle); cursor: pointer;
  transition: all var(--transition);
}
.pair-chip:hover { border-color: var(--accent); color: var(--accent); }

/* Language bar */
.language-bar { display: flex; align-items: flex-end; justify-content: center; gap: 0.75rem; margin-bottom: 1.5rem; }
.lang-select-group { display: flex; flex-direction: column; gap: 0.3rem; }
.lang-select-group label {
  font-size: 0.66rem; font-weight: 700; color: var(--fg-muted);
  text-transform: uppercase; letter-spacing: 0.07em;
}
.lang-select-group select { min-width: 160px; height: 2.35rem; }
.detected-badge { font-size: 0.7rem; font-weight: 600; color: var(--ok); }
.swap-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.35rem; height: 2.35rem; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); color: var(--fg-subtle); cursor: pointer;
  transition: all var(--transition);
}
.swap-btn:hover { border-color: var(--accent); color: var(--accent); }
.swap-btn svg { width: 16px; height: 16px; }

/* ============================ Translation panels ============================ */
.translation-panels {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.panel { position: relative; display: flex; flex-direction: column; min-width: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); overflow: hidden; }
.panel-header {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  background: var(--bg-inset);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.panel-header label, .panel-header .panel-header-end + label { font-size: 0.66rem; font-weight: 700; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.07em; white-space: nowrap; }
.panel-actions { display: flex; align-items: center; gap: 0.1rem; flex-wrap: wrap; }
.panel-header-end { display: flex; align-items: center; gap: 0.45rem; min-width: 0; overflow: hidden; }
.word-count, .char-count { font-size: 0.68rem; color: var(--fg-muted); white-space: nowrap; }
.char-count.char-warn { color: var(--warn); font-weight: 700; }
.char-count.char-limit { color: var(--danger); font-weight: 700; }

.mini-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem;
  width: 1.75rem; height: 1.75rem; padding: 0;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--fg-subtle); cursor: pointer;
  font-size: 0.72rem; font-weight: 600;
  transition: all var(--transition);
}
.mini-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.mini-btn:hover { color: var(--fg); background: var(--bg-hover); }
.mini-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.mini-btn-primary, .mini-primary { color: var(--accent); }
.mini-primary:hover { background: var(--accent-soft); }
.mini-text-btn { width: auto; padding: 0 0.55rem; }
.mini-ok { color: var(--ok) !important; }
.mini-danger { color: var(--danger); }
.mini-rec { color: var(--danger); }
.mini-wide { width: auto; padding: 0 0.6rem; height: 1.9rem; }
.voice-dot { position: relative; }
.voice-dot::after {
  content: ''; position: absolute; top: 2px; right: 2px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--danger);
}

.panel textarea {
  flex: 1; min-height: 170px; padding: 0.8rem;
  font-size: 0.95rem; line-height: 1.65; color: var(--fg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  resize: vertical; outline: none;
  transition: border-color var(--transition);
}
.panel textarea:focus { border-color: var(--accent); }
.panel textarea::placeholder { color: var(--fg-muted); }
.panel textarea:disabled { opacity: 0.5; }

.clear-btn {
  position: absolute; top: 2.3rem; right: 0.5rem;
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--fg-muted); cursor: pointer;
  transition: all var(--transition);
}
.clear-btn:hover { color: var(--fg); background: var(--bg-hover); }

.translation-progress { position: absolute; bottom: 0; left: 0; right: 0; height: 2px; overflow: hidden; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.progress-bar { height: 100%; background: var(--accent); animation: progress 1.4s linear infinite; width: 40%; }
@keyframes progress { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

.char-progress-wrap { height: 2px; background: var(--border); overflow: hidden; }
.char-progress-bar { height: 100%; background: var(--accent); }
.char-progress-bar.char-warn { background: var(--warn); }
.char-progress-bar.char-limit { background: var(--danger); }

.manual-translate-row { display: flex; justify-content: center; margin-bottom: 0.85rem; }

/* Alternatives */
.alternatives-box { margin-bottom: 0.85rem; }
.alt-label { margin: 0 0 0.35rem; font-size: 0.7rem; font-weight: 700; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.alt-item {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%; padding: 0.5rem 0.75rem; margin-bottom: 0.3rem;
  text-align: left; font-size: 0.85rem; color: var(--fg);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.alt-item:hover { border-color: var(--accent); background: var(--accent-soft); }

/* Stats chips */
.stats-bar { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 0.85rem; }
.stat-chip {
  padding: 0.24rem 0.6rem; font-size: 0.7rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 999px; color: var(--fg-subtle); white-space: nowrap;
}
.stat-chip strong { color: var(--fg); font-weight: 700; }
.stat-pal.yes { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); font-weight: 600; }

/* Text tools */
.tools-disclosure, .dict-panel, .native-file-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 0.85rem;
}
.tools-disclosure summary, .dict-panel summary, .native-file-box summary {
  padding: 0.55rem 0.85rem; cursor: pointer; user-select: none;
  font-size: 0.78rem; font-weight: 700; color: var(--fg-subtle);
}
.tools-disclosure summary:hover, .dict-panel summary:hover, .native-file-box summary:hover { color: var(--accent); }
.text-tools { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.tool-btn {
  padding: 0.26rem 0.55rem; font-size: 0.7rem; font-weight: 600;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-inset); color: var(--fg-subtle); cursor: pointer;
  transition: all var(--transition);
}
.tool-btn:hover { border-color: var(--accent); color: var(--accent); }

.encode-row, .cipher-row { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.5rem; font-size: 0.78rem; color: var(--fg-muted); }
.encode-result {
  max-width: 100%; overflow-wrap: anywhere; font-size: 0.72rem;
  color: var(--fg-subtle); background: var(--bg-inset);
  border-radius: var(--radius-sm); padding: 0.2rem 0.5rem; cursor: pointer;
}
.cipher-input {
  width: 62px; height: 1.9rem; padding: 0 0.4rem; text-align: center;
  font-size: 0.82rem; color: var(--fg); background: var(--bg-inset);
  border: 1px solid var(--border); border-radius: var(--radius-sm); outline: none;
}
.cipher-input:focus { border-color: var(--accent); }

/* Multi-language compare */
.multi-panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; margin-bottom: 0.85rem; }
.multi-header { font-size: 0.72rem; font-weight: 700; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.5rem; }
.multi-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
.multi-row:last-child { margin-bottom: 0; }
.multi-lang-select { height: 1.85rem; font-size: 0.74rem; min-width: 130px; flex-shrink: 0; }
.multi-result {
  flex: 1; min-height: 1.85rem; padding: 0.3rem 0.55rem;
  font-size: 0.82rem; color: var(--fg);
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow-wrap: anywhere;
}
.multi-dots { color: var(--fg-muted); }

/* Dictionary */
.dict-input-row { display: flex; gap: 0.5rem; margin-bottom: 0.6rem; }
.dict-input {
  flex: 1; height: 2.1rem; padding: 0 0.65rem;
  font-size: 0.84rem; color: var(--fg); background: var(--bg-inset);
  border: 1px solid var(--border); border-radius: var(--radius-sm); outline: none;
}
.dict-input:focus { border-color: var(--accent); }
.dict-loading { display: flex; justify-content: center; padding: 1rem; }
.dict-results { max-height: 320px; overflow-y: auto; }
.dict-cat { font-size: 0.68rem; font-weight: 700; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.3rem; }
.dict-def { color: var(--fg-subtle); font-size: 0.8rem; margin: 0.12rem 0 0.12rem 0.25rem; }
.dict-chips { display: flex; flex-wrap: wrap; gap: 0.28rem; }
.dict-chip {
  display: inline-block; padding: 0.16rem 0.55rem;
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: 999px;
  font-size: 0.73rem; color: var(--fg-subtle); cursor: pointer;
  transition: all var(--transition);
}
.dict-chip:hover { border-color: var(--accent); color: var(--accent); }

/* Daily word & session */
.daily-word {
  display: flex; align-items: center; justify-content: center; gap: 0.45rem; flex-wrap: wrap;
  margin-bottom: 0.85rem; padding: 0.55rem;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  border-radius: var(--radius); font-size: 0.8rem; color: var(--fg-subtle);
}
.daily-word svg { color: var(--accent); flex-shrink: 0; }
.daily-word strong { color: var(--fg); }

.transliteration-panel {
  margin-bottom: 0.85rem; padding: 0.5rem 0.75rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 0.8rem; color: var(--fg-subtle); font-style: italic;
}
.transliteration-panel:empty { display: none; }
.transliteration-label {
  font-size: 0.64rem; font-weight: 700; color: var(--fg-muted);
  text-transform: uppercase; letter-spacing: 0.06em; margin-right: 0.5rem; font-style: normal;
}

.sesh-bar {
  display: flex; align-items: center; justify-content: center; gap: 1rem; flex-wrap: wrap;
  font-size: 0.7rem; color: var(--fg-muted);
}
.sesh-bar strong { color: var(--fg); }

/* Predictive bar */
.predictive-bar {
  display: flex; gap: 0.25rem; flex-wrap: wrap;
  padding: 0.35rem 0.5rem;
  background: var(--bg-inset); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.predictive-bar:empty { display: none; }
.predictive-word {
  padding: 0.14rem 0.5rem; font-size: 0.72rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-card); color: var(--fg-subtle); cursor: pointer;
  transition: all var(--transition);
}
.predictive-word:hover { border-color: var(--accent); color: var(--accent); }

/* ============================ OCR / Document / Website / Video ============================ */
.dropzone, .ocr-dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.6rem; padding: 2.25rem 1rem;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--bg-card); text-align: center; cursor: pointer;
  transition: border-color var(--transition);
  margin-bottom: 0.85rem;
}
.dropzone:hover, .ocr-dropzone:hover { border-color: var(--accent); }
.dropzone svg, .ocr-dropzone svg { color: var(--fg-muted); }
.dropzone p, .ocr-dropzone p { margin: 0; font-size: 0.85rem; color: var(--fg-subtle); }
.dropzone small, .ocr-dropzone small { color: var(--fg-muted); font-size: 0.72rem; }

.ocr-preview { max-width: 100%; max-height: 300px; object-fit: contain; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; margin: 0 auto 0.6rem; }
.ocr-text {
  width: 100%; min-height: 90px; padding: 0.6rem;
  font-size: 0.86rem; line-height: 1.6; color: var(--fg);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); resize: vertical; outline: none;
}
.ocr-text:focus { border-color: var(--accent); }
.ocr-status { font-size: 0.78rem; color: var(--fg-muted); }

.doc-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-top: 0.6rem; }
.file-card {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.9rem 1rem; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.file-info { display: flex; align-items: center; gap: 0.55rem; flex: 1; min-width: 0; font-size: 0.85rem; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 0.7rem; color: var(--fg-muted); white-space: nowrap; }
.file-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem; flex-shrink: 0;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--fg-muted); cursor: pointer; font-size: 1.15rem;
}
.file-remove:hover { color: var(--danger); background: var(--danger-soft); }
.hint { font-size: 0.76rem; color: var(--fg-muted); }
.inline-spinner { display: inline-flex; align-items: center; }
.native-file-box { background: transparent; border-style: dashed; }

.website-input-row { display: flex; gap: 0.5rem; margin-bottom: 0.85rem; flex-wrap: wrap; }
.website-input {
  flex: 1; min-width: 180px; height: 2.35rem; padding: 0 0.75rem;
  font-size: 0.86rem; color: var(--fg); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm); outline: none;
  transition: border-color var(--transition);
}
.website-input:focus { border-color: var(--accent); }
.web-frame {
  width: 100%; min-height: 420px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff;
}

.video-player-wrap { position: relative; margin-bottom: 0.75rem; }
.video-player { width: 100%; border-radius: var(--radius); background: #000; display: block; }
.subtitle-overlay {
  position: absolute; bottom: 3.4rem; left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78); color: #fff;
  padding: 0.4rem 0.9rem; border-radius: var(--radius-sm);
  font-size: 0.95rem; text-align: center; max-width: 85%;
  pointer-events: none;
}
.sub-generate-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem; }
.subtitle-list { max-height: 220px; overflow-y: auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
.subtitle-item {
  display: flex; gap: 0.6rem; padding: 0.45rem 0.75rem;
  font-size: 0.8rem; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background var(--transition);
}
.subtitle-item:last-child { border-bottom: none; }
.subtitle-item:hover { background: var(--bg-hover); }
.subtitle-time { font-size: 0.68rem; color: var(--accent); font-weight: 600; flex-shrink: 0; margin-top: 0.1rem; }
.tab-loading { display: flex; align-items: center; justify-content: center; gap: 0.6rem; padding: 1.5rem; }

/* ============================ History ============================ */
.history-toolbar { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.85rem; }
.history-search-wrap { position: relative; flex: 1; }
.history-search-icon {
  position: absolute; top: 50%; left: 0.6rem;
  transform: translateY(-50%); color: var(--fg-muted); pointer-events: none;
}
.history-search {
  width: 100%; height: 2rem; padding: 0 0.6rem 0 2rem;
  font-size: 0.83rem; color: var(--fg); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; transition: border-color var(--transition);
}
.history-search:focus { border-color: var(--accent); }
.favorite-filter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--fg-subtle); cursor: pointer;
  transition: all var(--transition);
}
.favorite-filter:hover { border-color: var(--accent); color: var(--accent); }
.favorite-filter.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

.history-empty {
  padding: 2.5rem 1rem; text-align: center;
  font-size: 0.88rem; color: var(--fg-subtle);
  background: var(--bg-card); border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.history-empty p { margin: 0; }
.history-empty small { color: var(--fg-muted); }

.history-list { max-height: 60vh; overflow-y: auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
.history-item {
  position: relative; padding: 0.7rem 2.9rem 0.7rem 1rem;
  cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--bg-hover); }
.history-item-langs {
  font-size: 0.64rem; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.15rem;
}
.history-item-source { font-size: 0.78rem; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item-target { font-size: 0.86rem; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item-delete, .history-item-fav, .pb-del {
  position: absolute; top: 0.55rem;
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.65rem; height: 1.65rem;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--fg-muted); cursor: pointer;
  transition: all var(--transition);
}
.history-item-delete { right: 0.55rem; opacity: 0; }
.history-item:hover .history-item-delete { opacity: 1; }
.history-item-delete:hover, .pb-del:hover { color: var(--danger); background: var(--danger-soft); }
.history-item-fav { right: 2.35rem; opacity: 0; }
.history-item:hover .history-item-fav { opacity: 1; }
.history-item-fav.favorited { opacity: 1; color: var(--warn); }
.history-item-fav:hover { color: var(--warn); }
.pb-del { position: static; flex-shrink: 0; }

/* ============================ Phrasebook ============================ */
.pb-add-row { display: flex; gap: 0.5rem; margin-bottom: 0.85rem; flex-wrap: wrap; }
.pb-add-row .website-input { min-width: 140px; }
.phrase-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 1rem; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.phrase-item:last-child { border-bottom: none; }
.phrase-item:hover { background: var(--bg-hover); }
.phrase-body { flex: 1; min-width: 0; }

/* ============================ Glossary ============================ */
.gloss-active-row.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.7rem 1rem; margin-bottom: 1rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.84rem; cursor: pointer;
}
.gloss-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 1rem; margin-bottom: 1rem; }
.gloss-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.65rem; }
.gloss-title {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.28rem 0.65rem; font-size: 0.84rem; font-weight: 650;
  border: 1px solid var(--border); border-radius: 999px;
  background: transparent; color: var(--fg-subtle); cursor: pointer;
  transition: all var(--transition);
}
.gloss-title:hover { border-color: var(--accent); color: var(--accent); }
.gloss-title.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.gloss-entry {
  display: grid; grid-template-columns: 1fr auto 1fr auto;
  gap: 0.45rem; align-items: center; margin-bottom: 0.4rem;
}
.gloss-entry input {
  height: 1.95rem; padding: 0 0.55rem; font-size: 0.8rem;
  color: var(--fg); background: var(--bg-inset);
  border: 1px solid var(--border); border-radius: var(--radius-sm); outline: none;
  min-width: 0;
}
.gloss-entry input:focus { border-color: var(--accent); }
.gloss-entry svg { color: var(--fg-muted); flex-shrink: 0; }

/* ============================ Account ============================ */
.account-profile-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.875rem; }
.avatar {
  width: 56px; height: 56px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-size: 1.4rem; font-weight: 700;
}
.account-profile-main { flex: 1; min-width: 0; }
.account-name-input {
  width: 100%; max-width: 320px; height: 2.25rem; padding: 0 0.75rem;
  font-size: 1rem; font-weight: 600; color: var(--fg);
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius-sm); outline: none;
  transition: border-color var(--transition);
}
.account-name-input:focus { border-color: var(--accent); background: var(--bg-card); }
.avatar-colors { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.avatar-dot {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
}
.avatar-dot:hover { transform: scale(1.15); }
.avatar-dot.sel { border-color: var(--fg); box-shadow: 0 0 0 2px var(--bg-card) inset; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin-bottom: 1rem; }
.stat-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0.85rem 0.5rem; text-align: center;
  background: var(--bg-inset); border-radius: var(--radius-sm);
}
.stat-num { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; color: var(--accent); line-height: 1.15; }
.stat-lbl { font-size: 0.68rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.15rem; }

.activity-strip { margin-top: 0.25rem; }
.activity-label { display: block; font-size: 0.66rem; font-weight: 700; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.4rem; }
.activity-dots { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.activity-dot {
  width: 14px; height: 14px; border-radius: 4px;
  background: var(--bg-inset); border: 1px solid var(--border);
}
.activity-dot.on { background: var(--ok); border-color: var(--ok); }
.activity-dot.today { box-shadow: 0 0 0 1.5px var(--accent); }

.pref-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.55rem 0; border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.pref-row:last-of-type { border-bottom: none; }
.pref-col { flex-direction: column; align-items: stretch; gap: 0.45rem; }
.pref-select { height: 2rem; font-size: 0.78rem; max-width: 220px; }
.seg-control {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--bg-inset); border-radius: var(--radius-sm);
}
.seg-control button {
  padding: 0.26rem 0.7rem; font-size: 0.74rem; font-weight: 600;
  border: none; border-radius: calc(var(--radius-sm) - 2px);
  background: transparent; color: var(--fg-subtle); cursor: pointer;
  transition: all var(--transition);
}
.seg-control button:hover { color: var(--fg); }
.seg-control button.on { background: var(--accent); color: var(--accent-fg); }
.pref-actions { margin-top: 0.75rem; display: flex; gap: 0.5rem; }

.apikey-row { display: flex; gap: 0.5rem; margin: 0.5rem 0; flex-wrap: wrap; }
.status-ok { color: var(--ok); }
.status-bad { color: var(--danger); }

.danger-zone {
  margin-top: 0.875rem; padding: 0.875rem;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius-sm); background: var(--danger-soft);
}
.dz-title { margin: 0 0 0.5rem; font-size: 0.72rem; font-weight: 800; color: var(--danger); text-transform: uppercase; letter-spacing: 0.07em; }

/* ============================ Features page ============================ */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.9rem; }
.feature-card { margin-bottom: 0; }
.feature-icon { font-size: 1.1rem; }
.feature-list { margin: 0; padding-left: 1.1rem; font-size: 0.8rem; color: var(--fg-subtle); }
.feature-list li { margin-bottom: 0.32rem; }
.feature-list li::marker { color: var(--accent); }

/* ============================ Shortcuts modal ============================ */
.shortcuts-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 10, 14, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.shortcuts-content {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 1.5rem; width: 100%; max-width: 420px;
  max-height: 85vh; overflow-y: auto;
}
.shortcuts-content h3 { margin: 0 0 1rem; font-size: 1rem; font-weight: 700; }
.shortcut-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.42rem 0;
  font-size: 0.84rem; border-bottom: 1px solid var(--border);
}
.shortcut-row:last-of-type { border-bottom: none; }
.shortcut-keys { display: flex; gap: 0.25rem; flex-shrink: 0; }
.shortcut-key {
  padding: 0.14rem 0.45rem;
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: 5px;
  font-size: 0.68rem; font-weight: 600; color: var(--fg-subtle);
}
.shortcuts-close { margin-top: 1rem; width: 100%; }

/* ============================ Zen mode ============================ */
body.zen-on .nav,
body.zen-on .sidebar,
body.zen-on .sidebar-overlay,
body.zen-on .footer { display: none !important; }
body.zen-on { padding-left: 0 !important; }
body.zen-on .app-content { padding-top: 1rem; }
.zen-exit {
  position: fixed; top: 0.75rem; right: 0.75rem; z-index: 80;
  display: none; align-items: center; gap: 0.35rem;
  padding: 0.4rem 0.75rem; font-size: 0.75rem; font-weight: 600;
  background: var(--bg-card); color: var(--fg-subtle);
  border: 1px solid var(--border); border-radius: 999px;
  box-shadow: var(--shadow-md); cursor: pointer;
}
body.zen-on .zen-exit { display: inline-flex; }
.zen-exit:hover { color: var(--fg); }

/* ============================ Footer ============================ */
.footer {
  border-top: 1px solid var(--border);
  padding: 1rem 0; margin-top: auto;
}
.footer-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 1rem;
  display: flex; flex-direction: column; gap: 0.35rem;
  text-align: center; font-size: 0.72rem; color: var(--fg-subtle);
}
.shortcuts-hint { font-size: 0.66rem; color: var(--fg-muted); }

/* ============================ Compact mode ============================ */
.compact .app-content { padding-top: 0.9rem; }
.compact .tab-bar { margin-bottom: 0.75rem; }
.compact .language-bar { margin-bottom: 0.75rem; }
.compact .panel textarea { min-height: 90px; }
.compact .stats-bar, .compact .daily-word { display: none; }
.compact .footer { display: none; }

/* ============================ Responsive ============================ */
@media (max-width: 1023px) {
  .menu-btn { display: inline-flex; }
}
@media (min-width: 1024px) {
  .menu-btn { display: none; }
}

@media (max-width: 768px) {
  .nav { margin: 0.45rem 0.5rem 0; border-radius: 22px; top: calc(0.4rem + env(safe-area-inset-top)); }
  .nav-inner { padding: 0 0.6rem; gap: 0.4rem; }
  .nav-brand { gap: 0.35rem; }
  .nav-links { gap: 0.2rem; }
  .locale-select { max-width: 96px; font-size: 0.7rem; }
  .brand-name, .nav-brand span:last-child { font-size: 0.82rem; }
  .sync-chip { max-width: 46px; padding: 0 0.55rem; }
  .sync-chip-label { display: none; }
  .translation-panels { grid-template-columns: 1fr; gap: 0.6rem; }
  .panel textarea { min-height: 110px; font-size: 16px; /* prevents iOS zoom */ }
  .language-bar { flex-wrap: wrap; gap: 0.5rem; }
  .lang-select-group { flex: 1 1 40%; }
  .lang-select-group select { min-width: unset; width: 100%; }
  .swap-btn { order: -1; margin: 0 auto; width: 2.1rem; height: 2.1rem; border-radius: 50%; }
  .page-title { display: none; }
  .tab-btn span { display: none; }
  .tab-btn { padding: 0.48rem 0.62rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .gloss-entry { grid-template-columns: 1fr 1fr; }
  .gloss-entry svg { display: none; }
  .history-item { padding-right: 2.6rem; }
  .history-item-delete, .history-item-fav, .history-item-tagbtn { opacity: 1; }  /* touch devices: always visible */
  .app-content { padding-bottom: 2rem; }
}

@media (max-width: 480px) {
  .container { padding: 0 0.65rem; }
  .nav-brand span:last-child { display: none; }  /* keep only the N mark */
  .tab-bar { width: 100%; max-width: 100%; justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; }
  .tab-btn { white-space: nowrap; }
  .website-input-row .btn { flex-shrink: 0; }
  .stat-chip:nth-child(n+5) { display: none; }
  .sesh-bar { gap: 0.6rem; }
  .shortcuts-hint { display: none; }
  .account-profile-row { flex-direction: column; text-align: center; }
  .avatar-colors { justify-content: center; }
  .pref-row { flex-wrap: wrap; }
}

@media (min-width: 769px) and (max-width: 1279px) {
  .container { max-width: calc(100% - 2rem); }
}

/* ===================== NEW: favorites, accent, conversation ===================== */
.fav-strip {
  display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
  margin: 0.65rem 0 0.25rem;
}
.fav-label { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.fav-chip {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 999px; padding: 0.28rem 0.7rem;
  font-size: 0.82rem; cursor: pointer; transition: all 0.16s ease;
}
.fav-chip:hover { border-color: var(--accent); color: var(--accent); }
.fav-chip.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

.lang-select-wrap { display: flex; align-items: center; gap: 0.35rem; }
.lang-select-wrap select { flex: 1; }
.star-btn {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.16s ease;
}
.star-btn:hover { color: var(--accent); border-color: var(--accent); }
.star-btn.on { color: #f5b301; border-color: #f5b301; }

.accent-dots { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.accent-dot {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: transform 0.15s ease, border-color 0.15s ease; padding: 0;
}
.accent-dot:hover { transform: scale(1.12); }
.accent-dot.sel { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--border-strong); }

.conv-section { display: flex; flex-direction: column; gap: 0.75rem; }
.conv-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.conv-pair { font-weight: 600; color: var(--text-muted); font-size: 0.85rem; }
.conv-log {
  display: flex; flex-direction: column; gap: 0.6rem;
  min-height: 280px; max-height: 460px; overflow-y: auto;
  padding: 0.5rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2);
}
.conv-empty { margin: auto; text-align: center; color: var(--text-muted); max-width: 420px; padding: 1rem; }
.conv-msg { display: flex; }
.conv-msg.you { justify-content: flex-end; }
.conv-msg.nevai { justify-content: flex-start; }
.conv-bubble {
  max-width: 78%; padding: 0.6rem 0.8rem; border-radius: 14px; position: relative;
  display: flex; flex-direction: column; gap: 0.25rem;
}
.conv-msg.you .conv-bubble { background: var(--accent); color: var(--accent-fg); border-bottom-right-radius: 4px; }
.conv-msg.nevai .conv-bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.conv-lang { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.7; }
.conv-text { font-size: 0.95rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.conv-copy { align-self: flex-end; font-size: 0.7rem; padding: 0.1rem 0.45rem; }
.conv-input-row { display: flex; gap: 0.5rem; align-items: flex-end; }
.conv-input-row textarea {
  flex: 1; resize: vertical; min-height: 48px; padding: 0.6rem 0.7rem;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  color: var(--text); font-family: inherit; font-size: 0.95rem;
}
.conv-input-row textarea:focus { outline: none; border-color: var(--accent); }

/* light polish */
.card { transition: box-shadow 0.18s ease, border-color 0.18s ease; }
.card:hover { box-shadow: 0 6px 22px rgba(0,0,0,0.06); }
.btn, .mini-btn, .tab-btn, .nav-item, .fav-chip, .star-btn { transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.12s ease; }
.btn:active, .mini-btn:active { transform: translateY(1px); }

@media (max-width: 768px) {
  .conv-bubble { max-width: 88%; }
  .accent-dots { gap: 0.45rem; }
  .fav-strip { margin-top: 0.5rem; }
}

/* Matrix cloud sync card */
.matrix-connected { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.75rem; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin: 0.25rem 0 0.6rem; }
.mc-user { font-weight: 600; color: var(--text); word-break: break-all; }
.mc-sub { font-size: 0.78rem; color: var(--text-muted); word-break: break-all; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; background: #9ca3af; }
.dot-ok { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.checkbox-inline { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--text); margin: 0.5rem 0; cursor: pointer; }
.checkbox-inline input { width: auto; }

/* Text size control */
html.fs-sm { font-size: 14px; }
html.fs-lg { font-size: 17.5px; }

/* Focus mode */
body.focus-mode header.nav { display: none !important; }
body.focus-mode .sidebar { top: 10px; height: calc(100vh - 20px); }

/* Rounded floating sidebar */
.sidebar {
  top: 10px; bottom: 10px; left: 10px;
  width: calc(var(--sidebar-w) - 6px);
  border-radius: 20px;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.sidebar.open { box-shadow: 0 18px 50px rgba(2, 6, 16, 0.35); }
@media (max-width: 1023px) {
  .sidebar { border-radius: 0 22px 22px 0; left: 0; top: 0; bottom: 0; width: min(84vw, 300px);
             padding-top: env(safe-area-inset-top); }
}

/* ===================== Back-translation check ===================== */
.backtrans-panel {
  display: flex; align-items: flex-start; gap: 0.6rem;
  margin-bottom: 0.85rem; padding: 0.6rem 0.85rem;
  background: var(--bg-card); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--radius);
}
.backtrans-label { font-size: 0.64rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; margin-top: 0.15rem; }
.backtrans-text { flex: 1; font-size: 0.86rem; color: var(--fg-subtle); overflow-wrap: anywhere; }

/* ===================== Detection confidence ===================== */
.detected-badge .conf { color: var(--fg-muted); font-weight: 600; font-size: 0.62rem; }

/* ===================== Readability & word frequency ===================== */
.readability-chip { border-color: color-mix(in srgb, var(--ok) 45%, transparent) !important; }
.freq-list { display: flex; gap: 0.3rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.5rem; }
.freq-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.14rem 0.55rem; font-size: 0.72rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-card); color: var(--fg-subtle); cursor: pointer;
}
.freq-chip b { color: var(--accent); font-weight: 700; }
.freq-chip:hover { border-color: var(--accent); color: var(--accent); }
.tool-section-label { font-size: 0.66rem; font-weight: 700; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 0.4rem 0; }

/* ===================== Daily goal ===================== */
.goal-wrap { margin-top: 0.75rem; }
.goal-head { display: flex; align-items: center; justify-content: space-between; font-size: 0.76rem; color: var(--fg-subtle); margin-bottom: 0.35rem; }
.goal-bar { height: 7px; border-radius: 999px; background: var(--bg-inset); overflow: hidden; border: 1px solid var(--border); }
.goal-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-hover)); border-radius: 999px; transition: width 240ms ease; }
.goal-input { width: 90px; height: 1.9rem; padding: 0 0.5rem; text-align: center; font-size: 0.82rem; color: var(--fg); background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-sm); outline: none; }
.goal-input:focus { border-color: var(--accent); }

/* ===================== Voice picker & sync controls ===================== */
.voice-select { max-width: 320px; width: 100%; height: 2rem; font-size: 0.78rem; }
.sync-interval-row select { max-width: 160px; }
.last-sync-line { font-size: 0.74rem; color: var(--fg-muted); margin: 0.35rem 0 0.25rem; }

/* ===================== Import row ===================== */
.import-status { font-size: 0.78rem; margin-top: 0.4rem; }
.storage-line { font-size: 0.74rem; color: var(--fg-muted); margin-top: 0.5rem; }

/* ===================== Command palette (Ctrl+K) ===================== */
.palette-content { max-width: 480px; padding: 0.75rem; }
.palette-input { margin-bottom: 0.6rem; }
.palette-list { max-height: 46vh; overflow-y: auto; }
.palette-item {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  width: 100%; padding: 0.55rem 0.7rem;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--fg); cursor: pointer;
  font-size: 0.85rem; text-align: left;
}
.palette-item.sel { background: var(--accent-soft); color: var(--accent); }
.palette-item .shortcut-key { flex-shrink: 0; }
.palette-empty { text-align: center; padding: 1rem 0; }

/* Pinned pair chips */
.pair-chip.pinned {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
  background: var(--accent-soft);
}
.pair-pin, .pair-unpin {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 4px;
  color: var(--fg-muted); opacity: 0.75;
}
.pair-chip:hover .pair-pin { opacity: 1; color: var(--accent); }
.pair-pin.on { opacity: 1 !important; color: var(--accent); fill: currentColor; }
.pair-unpin:hover { color: var(--danger); }

/* Line-by-line panel */
.lines-panel {
  background: var(--bg-card); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: var(--radius); padding: 0.75rem; margin-bottom: 0.85rem;
}
.lines-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.55rem; }
.lines-head .btn { margin-left: auto; }
.lines-list { max-height: 380px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.lines-row {
  display: grid; grid-template-columns: 1fr auto 1fr auto;
  gap: 0.5rem; align-items: start; padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border); font-size: 0.84rem;
}
.lines-row:last-child { border-bottom: none; }
.lines-src { color: var(--fg-muted); overflow-wrap: anywhere; }
.lines-tgt { color: var(--fg); overflow-wrap: anywhere; font-weight: 500; }

/* Perf: long lists render lazily */
.history-item { content-visibility: auto; contain-intrinsic-size: auto 64px; }

/* ===================== History tags ===================== */
.history-tags { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-top: 0.2rem; }
.tag-chip {
  padding: 0.05rem 0.4rem; font-size: 0.64rem; font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  cursor: pointer;
}
.tag-chip:hover { text-decoration: line-through; color: var(--danger); border-color: var(--danger); }
.history-item-tagbtn {
  position: absolute; top: 0.55rem; right: 4.15rem;
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.65rem; height: 1.65rem;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--fg-muted); cursor: pointer;
  opacity: 0; transition: all var(--transition);
}
.history-item:hover .history-item-tagbtn { opacity: 1; }
.history-item-tagbtn:hover { color: var(--accent); background: var(--accent-soft); }

/* ===================== Focus glow + dropzone tint ===================== */
.website-input:focus, .dict-input:focus, .goal-input:focus,
.account-name-input:focus, .gloss-entry input:focus, .cipher-input:focus {
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.panel textarea:focus { box-shadow: 0 0 0 3px var(--accent-soft); }
.dropzone:hover, .ocr-dropzone:hover { background: var(--accent-soft); }

/* ===================== QR share modal ===================== */
.qr-content { max-width: 320px; text-align: center; }
.qr-wrap { display: flex; justify-content: center; padding: 0.75rem 0; }
.qr-wrap canvas { border-radius: 12px; box-shadow: var(--shadow-md); background: #fff; }

/* ===================== Smart swap hint ===================== */
.swap-hint {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  margin: 0 auto 0.85rem; padding: 0.45rem 0.8rem;
  width: fit-content; max-width: 100%;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px; font-size: 0.78rem; color: var(--fg-subtle);
}
.swap-hint svg { color: var(--accent); flex-shrink: 0; }

/* ===================== Font family choices ===================== */
html.ff-serif body { font-family: Georgia, 'Iowan Old Style', 'Times New Roman', serif; }
html.ff-mono body { font-family: ui-monospace, 'Cascadia Code', 'SF Mono', Menlo, Consolas, monospace; }

/* 28-day activity grid wraps into weeks */
.activity-dots { max-width: 300px; }

/* ===================== Mobile bottom navigation ===================== */
.bottom-nav {
  display: none;
  position: fixed; left: 0.6rem; right: 0.6rem;
  bottom: calc(0.55rem + env(safe-area-inset-bottom));
  z-index: 52; /* below the sidebar overlay so the drawer always wins */
  height: calc(3.6rem + env(safe-area-inset-bottom) * 0);
  padding: 0.25rem 0.35rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
}
.bottom-nav button {
  position: relative;
  flex: 1; min-width: 0;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: none; border-radius: 16px;
  background: transparent; color: var(--fg-muted); cursor: pointer;
  font-size: 0.58rem; font-weight: 600; letter-spacing: 0.02em;
  transition: color var(--transition), background var(--transition);
}
.bottom-nav button.active { color: var(--accent); background: var(--accent-soft); }
.bottom-nav button svg { flex-shrink: 0; }
.bn-badge {
  position: absolute; top: 4px; right: 14%;
  min-width: 1rem; height: 1rem; padding: 0 0.25rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.56rem; font-weight: 700;
  background: var(--accent); color: var(--accent-fg); border-radius: 999px;
}

@media (max-width: 767px) {
  .bottom-nav { display: flex; }
  body { padding-bottom: calc(4.9rem + env(safe-area-inset-bottom)); }
  .footer { display: none; }
  body.zen-on .bottom-nav { display: none !important; }
  body.zen-on { padding-bottom: 1rem !important; }
  body.focus-mode .bottom-nav { display: none !important; }
}

/* Small tablets keep the drawer + bottom nav for one-handed use */
@media (min-width: 768px) and (max-width: 1023px) {
  .bottom-nav { display: flex; max-width: 420px; margin: 0 auto; }
  body { padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }
}

/* Chunked long-text progress */
.chunk-status {
  padding: 0.3rem 0.6rem; font-size: 0.72rem; font-weight: 600;
  color: var(--accent); text-align: center;
  background: var(--accent-soft);
  border-top: 1px solid var(--border);
}

/* Drawer scroll lock (mobile) */
@media (max-width: 1023px) {
  body.drawer-open { overflow: hidden; }
}

/* ===================== Print: clean translation sheet ===================== */
@media print {
  .nav, .sidebar, .sidebar-overlay, .bottom-nav, .footer,
  .tab-bar, .fav-strip, .recent-pairs, .swap-hint, .language-bar,
  .panel-header-end, .panel-actions, .clear-btn, .predictive-bar,
  .manual-translate-row, .tools-disclosure, .dict-panel, .multi-panel,
  .daily-word, .sesh-bar, .transliteration-panel, .stats-bar,
  .zen-exit, .shortcuts-modal, .offline-banner, .error-banner,
  .alert-banner, .lines-head .btn, .toast-region, .reading-modal { display: none !important; }
  body, body.zen-on { padding: 0 !important; background: #fff !important; color: #000 !important; }
  .app-content { padding: 0 !important; }
  .container { max-width: 100% !important; padding: 0 !important; }
  .translation-panels { grid-template-columns: 1fr !important; gap: 0.5rem !important; }
  .panel { box-shadow: none !important; border: none !important; break-inside: avoid; }
  .panel-header { background: transparent !important; border: none !important; }
  .panel textarea {
    border: none !important; min-height: auto !important;
    resize: none !important; overflow: visible !important;
    color: #000 !important; background: transparent !important;
    font-size: 12pt !important; line-height: 1.6 !important;
  }
}

/* ===================== Icon system polish ===================== */
.card-title svg { width: 15px; height: 15px; color: var(--accent); flex-shrink: 0; }
.h2-icon { display: inline-flex; vertical-align: -2px; margin-right: 0.35rem; color: var(--accent); }
.h2-icon svg { width: 18px; height: 18px; }
.empty-icon { display: flex; justify-content: center; margin-bottom: 0.6rem; opacity: 0.5; color: var(--fg-muted); }
.icon-sun, .icon-moon { transition: none !important; }
.btn-sm svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ===================== Mobile topbar declutter ===================== */
@media (max-width: 767px) {
  .nav-optional { display: none !important; }
}

/* Key-needed banner */
.key-needed { flex-wrap: wrap; }
.key-needed strong { color: var(--accent); }

/* Settings dropdown icon rows */
.settings-item svg { flex-shrink: 0; opacity: 0.75; }

/* ===================== Silent toast ===================== */
.toast-region {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(5.4rem + env(safe-area-inset-bottom));
  z-index: 90; pointer-events: none;
}
.toast {
  padding: 0.5rem 0.95rem; font-size: 0.8rem; font-weight: 600;
  background: var(--bg-card); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: 999px;
  box-shadow: var(--shadow-lg);
}
.toast-ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.toast-bad { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
@media (min-width: 768px) { .toast-region { bottom: 1.4rem; } }
body.zen-on .toast-region, body.focus-mode .toast-region { bottom: 1rem; }
.transition-none { transition: none !important; }

/* ===================== Round-trip similarity chips ===================== */
.sim-chip {
  flex-shrink: 0; padding: 0.18rem 0.55rem; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; white-space: nowrap;
}
.sim-high { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); }
.sim-mid { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); }
.sim-low { color: var(--danger); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }

/* ===================== History sort select ===================== */
.history-sort { height: 2rem; font-size: 0.78rem; max-width: 150px; flex-shrink: 0; }

/* ===================== Collapsible sidebar (desktop icon rail) ===================== */
.sidebar-collapse, .sidebar-expand { display: none; }
@media (min-width: 1024px) {
  .sidebar-collapse { display: inline-flex; margin-left: auto; }
  .sidebar-close { display: none; }
  body.sidebar-mini { padding-left: 66px; }
  body.sidebar-mini .sidebar {
    width: 56px; left: 10px;
    background: var(--bg-card);
  }
  body.sidebar-mini .sidebar-head { justify-content: center; padding-left: 0; padding-right: 0; }
  body.sidebar-mini .brand-mark { width: 28px; height: 28px; font-size: 0.85rem; }
  body.sidebar-mini .brand-name,
  body.sidebar-mini .nav-item span,
  body.sidebar-mini .nav-section-label,
  body.sidebar-mini .nav-theme-row,
  body.sidebar-mini .nav-badge,
  body.sidebar-mini .sidebar-collapse { display: none; }
  body.sidebar-mini .sidebar-expand { display: inline-flex; margin-left: auto; }
  body.sidebar-mini .sidebar-nav { padding: 0.625rem 0.5rem; }
  body.sidebar-mini .nav-item { justify-content: center; padding: 0.55rem 0; }
  body.sidebar-mini .nav-item.active::before { left: -0.25rem; }
  body.sidebar-mini .sidebar-foot { padding: 0.5rem 0.35rem; }
  body.sidebar-mini .sidebar-version { display: none; }
}

/* ===================== Privacy blur mode ===================== */
body.privacy-blur .panel textarea[readonly],
body.privacy-blur .backtrans-text,
body.privacy-blur .multi-result,
body.privacy-blur .lines-tgt,
body.privacy-blur .history-item-target,
body.privacy-blur .conv-text {
  filter: blur(7px);
  cursor: pointer;
  transition: filter 100ms linear;
}
body.privacy-blur .panel textarea[readonly]:focus,
body.privacy-blur .backtrans-text:hover,
body.privacy-blur .multi-result:hover,
body.privacy-blur .lines-tgt:hover,
body.privacy-blur .history-item-target:active,
body.privacy-blur .conv-text:hover,
body.privacy-blur .conv-msg.you .conv-text {
  filter: none;
}

/* ===================== Features view extras ===================== */
.features-search { max-width: 420px; margin-bottom: 1rem; }
.features-empty { text-align: center; padding: 2rem 0; }
.feature-icon { display: inline-flex; align-items: center; color: var(--accent); }
.feature-icon svg { width: 16px; height: 16px; }
.feature-count {
  margin-left: auto; min-width: 1.3rem; height: 1.15rem; padding: 0 0.35rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.62rem; font-weight: 700; color: var(--fg-muted);
  background: var(--bg-inset); border-radius: 999px;
}

/* Dark-mode input & select polish */
html.dark select option { background: var(--bg-card); color: var(--fg); }
html.dark input, html.dark textarea, html.dark select { caret-color: var(--accent); }

/* Light-mode card hover stays subtle; dark avoids glow */
html.dark .card:hover { box-shadow: var(--shadow-md); }

/* ===================== Storage meter ===================== */
.storage-meter { margin: 0.35rem 0 0.2rem; }
.storage-head { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--fg-subtle); margin-bottom: 0.3rem; }
.storage-bar { height: 8px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.storage-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-hover)); border-radius: 99px; }

/* ===================== Reading mode ===================== */
.reading-modal { align-items: center; justify-content: center; }
.reading-content {
  width: min(760px, calc(100vw - 2rem));
  max-height: min(84vh, 900px);
  display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 1rem 1.25rem;
}
.reading-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding-bottom: 0.6rem; margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.reading-text {
  overflow-y: auto; line-height: 1.75; color: var(--fg);
  white-space: pre-wrap; overflow-wrap: anywhere; padding-right: 0.25rem;
}
