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

:root {
  --bg: #f8f8f8;
  --surface: #ffffff;
  --border: #e2e2e2;
  --text: #1a1a1a;
  --text-muted: #999;
  --accent: #4a6cf7;
  --accent-light: #eef1fe;
  --radius: 14px;
  --radius-sm: 10px;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --line-height: 1.7;
  --font-size: 15px;
  --gutter-width: 52px;
  --sidebar-w: 260px;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── App Layout ──────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-left 0.25s ease, opacity 0.2s ease;
  z-index: 50;
}

.sidebar.area-focused {
  border-right-color: var(--accent);
  border-right-width: 2px;
}

.sidebar.hidden {
  margin-left: calc(var(--sidebar-w) * -1);
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  user-select: none;
}

.sidebar-actions {
  display: flex;
  gap: 2px;
}

.sidebar-actions button {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.sidebar-actions button svg {
  width: 15px;
  height: 15px;
}

.sidebar-actions button:hover {
  background: var(--bg);
  color: var(--text);
}

/* ── Sidebar Footer ─────────────────────────── */
.sidebar-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-muted);
  user-select: none;
  flex-shrink: 0;
}

/* ── Sidebar Tree ────────────────────────────── */
.sidebar-tree {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.tree-item-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px 5px 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s ease;
  position: relative;
  min-height: 30px;
}

.tree-item-row:hover {
  background: var(--bg);
}

.tree-item-row.active {
  background: var(--accent-light);
  color: var(--accent);
}

.tree-item-row.selected {
  background: #e8eaed;
}

.tree-item-row.selected.active {
  background: var(--accent-light);
}

.tree-item-row.active .tree-icon svg {
  stroke: var(--accent);
}

.tree-item-row.active-editing {
  border-left: 2px solid var(--accent);
}

.tree-item-row.active-editing .tree-name {
  color: var(--accent);
  opacity: 0.6;
}

.tree-item-row.active-editing .tree-icon svg {
  stroke: var(--accent);
  opacity: 0.5;
}

.tree-chevron {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.tree-chevron svg {
  width: 12px;
  height: 12px;
}

.tree-chevron.expanded {
  transform: rotate(90deg);
}

.tree-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tree-icon svg {
  width: 14px;
  height: 14px;
  stroke: var(--text-muted);
}

.tree-name-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.tree-name {
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.tree-name.auto-name {
  font-style: italic;
  opacity: 0.75;
}

.tree-date {
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.tree-name-input {
  flex: 1;
  font-size: 0.82rem;
  font-family: var(--font-sans);
  padding: 1px 4px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  min-width: 0;
}

.tree-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
  pointer-events: none;
  opacity: 0.6;
}

.tree-children {
  overflow: hidden;
}

/* Tree drag indicators */
.tree-item-row.drag-above {
  box-shadow: inset 0 2px 0 var(--accent);
}

.tree-item-row.drag-below {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.tree-item-row.drag-inside {
  background: var(--accent-light);
  outline: 1px dashed var(--accent);
  outline-offset: -1px;
}

/* ── Sort Menu ──────────────────────────────── */
.sort-menu {
  display: none;
  position: fixed;
  z-index: 300;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 4px;
}

.sort-menu.visible {
  display: block;
}

.sort-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 7px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  font-family: var(--font-sans);
  cursor: pointer;
  border-radius: 6px;
  text-align: left;
}

.sort-menu button:hover {
  background: var(--bg);
}

.sort-menu button.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}

/* ── Context Menu ────────────────────────────── */
.context-menu {
  display: none;
  position: fixed;
  z-index: 300;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.context-menu.visible {
  display: block;
}

.context-menu button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s ease;
}

.context-menu button:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.context-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Sidebar Backdrop (mobile) ───────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 40;
}

.sidebar-backdrop.visible {
  display: block;
}

/* ── Main Content ────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.container {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 24px 80px;
}

/* ── Top Bar ─────────────────────────────────── */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.top-bar.area-focused {
  border-bottom-color: var(--accent);
  border-bottom-width: 2px;
}

.header {
  display: flex;
  align-items: center;
  padding: 0 4px;
}

/* ── Toolbar ─────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 3px;
  flex-shrink: 0;
}

.toolbar button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.toolbar button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.toolbar button:active:not(:disabled) {
  transform: scale(0.97);
}

.toolbar button:disabled {
  opacity: 0.35;
  cursor: default;
}

.toolbar button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.toolbar button svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Collapse button */
.btn-collapse {
  margin-left: auto;
  opacity: 0.4;
  border: none !important;
  background: transparent !important;
  padding: 6px !important;
}

.btn-collapse:hover {
  opacity: 0.8 !important;
  background: transparent !important;
  border: none !important;
  color: var(--text) !important;
}

.btn-collapse svg {
  transition: transform 0.2s ease;
}

.top-bar.collapsed .toolbar button .label {
  display: none;
}

.top-bar.collapsed .toolbar button {
  padding: 7px 9px;
}

.top-bar.collapsed .toolbar {
  gap: 3px;
}

.top-bar.collapsed .toolbar-sep {
  margin: 0 2px;
}

.top-bar.collapsed .btn-collapse svg {
  transform: rotate(180deg);
}

/* ── Find & Replace Panel ────────────────────── */
.find-replace {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  gap: 8px;
  flex-direction: column;
  animation: slideDown 0.2s ease;
}

.find-replace.visible {
  display: flex;
}

.find-row,
.replace-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.find-replace input {
  flex: 1;
  min-width: 100px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s ease;
}

.find-replace input:focus {
  border-color: var(--accent);
}

.find-replace input::placeholder {
  color: var(--text-muted);
}

.match-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 32px;
  text-align: center;
  user-select: none;
}

.btn-find-nav {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  padding: 0;
}

.btn-find-nav svg {
  width: 13px;
  height: 13px;
}

.btn-find-nav:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.find-replace .btn-replace {
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.find-replace .btn-replace:hover {
  opacity: 0.88;
}

.find-replace .btn-replace-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.find-replace .btn-replace-outline:hover {
  background: var(--accent-light);
  opacity: 1;
}

.find-replace .btn-close {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.15s ease;
}

.find-replace .btn-close:hover {
  background: var(--bg);
  color: var(--text);
}

/* ── Editor Area ─────────────────────────────── */
.editor-wrap {
  position: relative;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.editor-wrap.focused,
.editor-wrap.area-focused {
  border-color: var(--accent);
}

.editor-wrap.drag-over::after {
  content: 'Thả file vào đây…';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(74, 108, 247, 0.06);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  z-index: 10;
  pointer-events: none;
}

.drop-hint {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  pointer-events: none;
  opacity: 0.5;
  z-index: 0;
}

.editor-wrap.empty .drop-hint {
  display: flex;
}

.gutter {
  width: var(--gutter-width);
  min-height: 100%;
  padding: 16px 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  user-select: none;
  flex-shrink: 0;
  overflow: hidden;
}

.gutter-line {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  width: 100%;
  padding-right: 14px;
  font-family: var(--font-mono);
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--text-muted);
  transition: color 0.1s ease, background 0.1s ease;
}

.gutter-line.active {
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 500;
}

.editor-inner {
  flex: 1;
  position: relative;
  min-width: 0;
}

#space-layer,
#highlight-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 16px 20px;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: var(--font-size);
  line-height: var(--line-height);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  tab-size: 4;
  color: transparent;
  z-index: 0;
}

#space-layer .ws-single {
  background: rgba(0, 0, 0, 0.06);
}

#space-layer .ws-multi {
  background: rgba(255, 170, 0, 0.25);
  border-bottom: 1.5px dashed rgba(255, 140, 0, 0.5);
}

#space-layer .ws-leading {
  background: rgba(74, 108, 247, 0.15);
  border-bottom: 1.5px dashed rgba(74, 108, 247, 0.4);
}

#space-layer .ws-trailing {
  background: rgba(239, 68, 68, 0.18);
  border-bottom: 1.5px dashed rgba(239, 68, 68, 0.5);
}

#highlight-layer mark {
  color: transparent;
  border-radius: 3px;
  padding: 1px 0;
}

#highlight-layer mark.match {
  background: rgba(255, 213, 79, 0.45);
}

#highlight-layer mark.current {
  background: rgba(255, 152, 0, 0.55);
  box-shadow: 0 0 0 1px rgba(255, 152, 0, 0.7);
}

#editor {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  min-height: 320px;
  padding: 16px 20px;
  border: none;
  outline: none;
  resize: none;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--text);
  background: transparent;
  tab-size: 4;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  field-sizing: content;
}

#editor::placeholder {
  color: var(--text-muted);
}

#editor::-webkit-scrollbar {
  display: none;
}

#editor {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

#mirror {
  position: fixed;
  visibility: hidden;
  pointer-events: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-family: var(--font-mono);
  font-size: var(--font-size);
  line-height: var(--line-height);
  padding: 0;
  border: none;
  tab-size: 4;
  top: -9999px;
  left: -9999px;
  z-index: -1;
}

/* ── Status Bar ──────────────────────────────── */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 14px;
  font-size: 0.75rem;
  color: var(--text-muted);
  user-select: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.status-left {
  display: flex;
  gap: 12px;
  align-items: center;
}

.status-dot {
  opacity: 0.4;
}

.status-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

.status-focus {
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
  font-size: 0.7rem;
}

.status-save {
  font-weight: 500;
  transition: color 0.2s;
}

.status-save.saving {
  color: var(--accent);
}

.status-clock {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
}

.status-timer {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

.status-timer.alarm {
  animation: timerBlink 0.5s ease infinite alternate;
}

@keyframes timerBlink {
  from {
    opacity: 1;
  }

  to {
    opacity: 0.3;
  }
}

/* ── Find Toggle Buttons ──────────────────────── */
.btn-find-toggle {
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-find-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-find-toggle.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ── Toast ────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 22px;
  background: var(--text);
  color: #fff;
  border-radius: 50px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  animation: toastIn 0.25s ease, toastOut 0.3s ease 1.8s forwards;
  pointer-events: auto;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
}

/* ── Confirm Dialog ──────────────────────────── */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 500;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.confirm-overlay.visible {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.confirm-dialog {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 32px 24px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  animation: dialogIn 0.2s ease;
}

@keyframes dialogIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-8px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.confirm-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.confirm-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.confirm-btn {
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.confirm-btn-cancel {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.confirm-btn-cancel:hover {
  background: var(--border);
}

.confirm-btn-danger {
  background: #ef4444;
  color: #fff;
}

.confirm-btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.confirm-btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Responsive ──────────────────────────────── */
/* ── Confirm Stats ──────────────────────────── */
.confirm-stats {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 0.82rem;
  line-height: 1.8;
  color: var(--text);
}

.confirm-stats .stat-row {
  display: flex;
  justify-content: space-between;
}

.confirm-stats .stat-label {
  color: var(--text-muted);
}

.confirm-stats .stat-value {
  font-weight: 600;
}

/* ── Stats Dialog ──────────────────────────── */
.stats-dialog {
  max-width: 440px;
}

.stats-content {
  margin-bottom: 16px;
}

.stats-section {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.stats-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stats-item {
  display: flex;
  flex-direction: column;
}

.stats-item-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.stats-item-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── Timer Dialog ────────────────────────── */
.timer-dialog {
  max-width: 400px;
}

.timer-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 16px;
}

.timer-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.timer-tab:hover {
  color: var(--text);
}

.timer-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.timer-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.timer-preset,
.timer-alarm-preset {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  flex: 1;
  min-width: 60px;
  text-align: center;
}

.timer-preset:hover,
.timer-alarm-preset:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.timer-custom {
  margin-bottom: 14px;
}

.timer-custom label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.timer-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}

.timer-input:focus {
  border-color: var(--accent);
}

.timer-input-time {
  font-size: 1.4rem;
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.timer-options {
  display: grid;
  grid-template-columns: auto auto auto;
  justify-content: center;
  gap: 8px 20px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  margin-bottom: 4px;
}

.timer-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text);
  user-select: none;
  white-space: nowrap;
}

.timer-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.timer-btn-start {
  background: var(--accent);
  color: #fff;
}

.timer-btn-start:hover {
  background: #3a5ce0;
}

/* Timer Alarm Notification */
.timer-alarm-dialog {
  text-align: center;
  max-width: 340px;
}

.timer-alarm-icon {
  line-height: 1;
  margin-bottom: 8px;
  color: var(--accent);
  animation: alarmPulse 0.6s ease infinite alternate;
}

@keyframes alarmPulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.15) rotate(8deg);
  }
}

.timer-alarm-title {
  font-size: 1.3rem !important;
}

.timer-alarm-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

.timer-alarm-dialog .confirm-actions {
  justify-content: center;
}

/* ── Export Dialog ────────────────────────── */
.export-dialog {
  max-width: 420px;
}

.export-options {
  margin-bottom: 14px;
}

.export-select-all {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  user-select: none;
  padding: 8px 12px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  transition: background 0.15s;
}

.export-select-all:hover {
  background: #dde3fd;
}

.export-select-all input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.export-option-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.export-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.1s;
  user-select: none;
}

.export-option:hover {
  background: var(--bg);
}

.export-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  margin-top: 2px;
  flex-shrink: 0;
}

.export-option-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.export-option-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.export-option-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ── Virtual Keyboard ──────────────────────── */
.virtual-keyboard {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 500;
  background: var(--surface);
  border-top: 2px solid var(--border);
  padding: 8px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

.virtual-keyboard.visible {
  display: block;
}

.vk-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.vk-close-btn {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
}

.vk-close-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.vk-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vk-row {
  display: flex;
  gap: 3px;
  justify-content: center;
}

.vk-key {
  min-width: 34px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  user-select: none;
}

.vk-key:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.vk-key:active {
  transform: scale(0.93);
  background: var(--accent);
  color: white;
}

.vk-key.vk-mod {
  min-width: 48px;
  font-size: 0.9rem;
  background: var(--bg);
}

.vk-key.vk-wide {
  min-width: 64px;
  font-size: 0.75rem;
}

.vk-key.vk-space {
  flex: 1;
  max-width: 240px;
}

.vk-key.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.vk-key.vk-vn {
  font-size: 0.7rem;
  min-width: 46px;
  background: #fff8f0;
  border-color: #e8d5c0;
}

.vk-key.vk-vn-char {
  font-size: 1rem;
  min-width: 38px;
  font-weight: 600;
  background: #f0f4ff;
  border-color: #c0cde8;
  color: var(--accent);
}

.vk-key.vk-vn-char:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.vk-row-vn {
  border-top: 1px solid var(--border);
  padding-top: 4px;
  margin-top: 2px;
}

.vk-row-vn+.vk-row-vn {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
  }

  .sidebar.hidden {
    margin-left: calc(var(--sidebar-w) * -1);
  }

  .toolbar button .label {
    display: none;
  }

  .toolbar button {
    padding: 7px 9px;
  }

  .toolbar {
    gap: 3px;
  }

  .toolbar-sep {
    margin: 0 2px;
  }

  .btn-collapse {
    display: none !important;
  }

  .container {
    padding: 16px 12px 80px;
  }

  :root {
    --gutter-width: 40px;
    --font-size: 14px;
  }
}

@media (max-width: 480px) {
  :root {
    --sidebar-w: 220px;
  }

  .find-replace .btn-replace {
    padding: 8px 10px;
    font-size: 0.75rem;
  }
}