/* ============ MAINTENANCE BANNER ============ */
.maintenance-banner {
  background: color-mix(in oklch, var(--warn) 14%, #fff);
  color: color-mix(in oklch, var(--warn) 80%, #000);
  border-bottom: 1px solid color-mix(in oklch, var(--warn) 35%, transparent);
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1.4;
}
.maintenance-banner-ico { font-size: 14px; }
@media (max-width: 640px) {
  .maintenance-banner { padding: 8px 14px; font-size: 12px; }
}

/* ============ APP SHELL ============ */
.app-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 66px);
}
.sidebar {
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  background: var(--bg-alt);
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar-section {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--ink-mute); padding: 18px 12px 8px; font-weight: 600;
}
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--ink-2);
  transition: all 0.15s;
  cursor: pointer;
}
.sidebar-link:hover { background: var(--bg-card); color: var(--ink); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.sidebar-ico { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; opacity: 0.7; }
.sidebar-link.active .sidebar-ico { opacity: 1; }

.app-main {
  padding: 32px 40px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}
.page { display: none; }
.page.active { display: block; }

.page-head {
  margin-bottom: 28px;
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: 20px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 36px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 500;
  margin-bottom: 4px;
}
.page-sub { color: var(--ink-mute); font-size: 14px; }

/* ============ STATS ============ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat {
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.stat-label { font-size: 12px; color: var(--ink-mute); margin-bottom: 8px; letter-spacing: 0.04em; text-transform: uppercase; }
.stat-value { font-family: var(--font-display); font-size: 32px; letter-spacing: -0.02em; line-height: 1; font-weight: 500; }
.stat-sub { font-size: 12px; color: var(--ink-mute); margin-top: 8px; }

/* ============ CARDS ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px;
}
.card-title {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: -0.01em;
  font-weight: 500;
}

/* ============ DROPZONE ============ */
.dropzone {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  transition: all 0.2s ease;
  cursor: pointer;
  background: var(--bg-alt);
}
.dropzone:hover, .dropzone.active {
  border-color: var(--accent);
  background: color-mix(in oklch, var(--accent-soft) 40%, var(--bg-alt));
}
.dropzone-ico {
  font-family: var(--font-display);
  font-size: 40px;
  color: var(--accent);
  margin-bottom: 10px;
  line-height: 1;
}
.dropzone-title { font-size: 16px; font-weight: 500; margin-bottom: 4px; }
.dropzone-sub { font-size: 13px; color: var(--ink-mute); }

/* ============ FILE TILE ============ */
.file-tile {
  display: flex; align-items: center; gap: 16px;
  padding: 18px;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.file-ico {
  width: 44px; height: 56px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  color: var(--accent);
  position: relative;
}
.file-ico::after {
  content: ""; position: absolute; top: 0; right: 0;
  width: 10px; height: 10px; background: var(--bg);
  border-left: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 500; font-size: 14.5px; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 12px; color: var(--ink-mute); font-family: var(--font-mono); }

/* ============ FORMS ============ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px; font-weight: 500; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.input, .select, .textarea {
  padding: 10px 14px;
  font-size: 14px;
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--ink);
  outline: none;
  transition: all 0.15s;
  width: 100%;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.select {
  cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-mute) 50%), linear-gradient(135deg, var(--ink-mute) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

/* ============ SEGMENTED CONTROL ============ */
.seg {
  display: inline-flex;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 3px; gap: 2px;
}
.seg-opt {
  padding: 7px 14px; font-size: 13px;
  border-radius: calc(var(--radius-md) - 3px);
  color: var(--ink-2); cursor: pointer;
  transition: all 0.15s;
}
.seg-opt:hover { color: var(--ink); }
.seg-opt.active { background: var(--bg-card); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ============ LANG/OPTION TILES ============ */
.tile {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-card);
  text-align: center;
}
.tile:hover { border-color: var(--line-strong); }
.tile.selected { border-color: var(--ink); border-width: 2px; padding: 13px; }
.tile-native { font-family: var(--font-display); font-size: 18px; margin-bottom: 2px; }
.tile-name { font-size: 11px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: 0.08em; }

/* ============ PROGRESS ============ */
.progress-track {
  width: 100%; height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* ============ TABLE ============ */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.table td { padding: 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-alt); }

/* ============ BADGES ============ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-mono);
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-done { background: color-mix(in oklch, var(--ok) 18%, var(--bg-card)); color: var(--ok); }
.badge-prog { background: color-mix(in oklch, var(--accent) 18%, var(--bg-card)); color: var(--accent); }
.badge-wait { background: color-mix(in oklch, var(--warn) 18%, var(--bg-card)); color: var(--warn); }
.badge-fail { background: color-mix(in oklch, var(--danger) 18%, var(--bg-card)); color: var(--danger); }

/* ============ TOGGLE ============ */
.toggle {
  width: 40px; height: 22px;
  background: var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle.on { background: var(--accent); }
.toggle::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: white;
  border-radius: 50%;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle.on::after { left: 20px; }

/* ============ BOOK COVERS ============ */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}
.book-card { cursor: pointer; }
.book-cover {
  aspect-ratio: 3/4;
  border-radius: 3px 8px 8px 3px;
  padding: 14px 12px 14px 18px;
  color: white;
  display: flex; flex-direction: column; justify-content: space-between;
  font-family: var(--font-display);
  position: relative;
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
  overflow: hidden;
}
.book-cover::before {
  content: ""; position: absolute;
  left: 0; top: 0; bottom: 0; width: 8px;
  background: rgba(0,0,0,0.18);
}
.book-cover .lang-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  opacity: 0.85;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.book-cover .title {
  font-size: 15px;
  line-height: 1.15;
  font-weight: 500;
}
.book-cover .auth {
  font-family: var(--font-ui);
  font-size: 10px;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.book-card .book-t { font-size: 13px; font-weight: 500; margin-top: 6px; }
.book-card .book-a { font-size: 11px; color: var(--ink-mute); }

/* ============ UTILITY ============ */
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.between { display: flex; justify-content: space-between; align-items: center; }

/* ============ PRICING IN APP ============ */
.app-plan {
  padding: 28px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  display: flex; flex-direction: column;
  transition: all 0.2s ease;
  position: relative;
}
.app-plan.current { border-color: var(--ink); border-width: 2px; padding: 27px 21px; }
.app-plan .plan-badge {
  position: absolute; top: -10px; left: 22px;
  padding: 3px 10px; font-size: 10px; font-weight: 600;
  background: var(--ink); color: var(--bg);
  border-radius: 20px;
  letter-spacing: 0.12em; text-transform: uppercase;
}

/* ============ MOBILE BURGER ============ */
.burger {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
  margin-right: 4px;
}
.burger span {
  display: block; width: 16px; height: 2px;
  background: var(--ink);
  position: relative;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.burger span::before, .burger span::after {
  content: ""; position: absolute; left: 0; width: 16px; height: 2px;
  background: var(--ink);
  transition: transform 0.2s ease, top 0.2s ease;
}
.burger span::before { top: -5px; }
.burger span::after { top: 5px; }
body.drawer-open .burger span { background: transparent; }
body.drawer-open .burger span::before { top: 0; transform: rotate(45deg); }
body.drawer-open .burger span::after { top: 0; transform: rotate(-45deg); }

.drawer-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: color-mix(in oklch, var(--ink) 45%, transparent);
  z-index: 40;
  opacity: 0;
  transition: opacity 0.2s ease;
}
body.drawer-open .drawer-backdrop {
  display: block;
  opacity: 1;
}

@media (max-width: 900px) {
  .burger { display: inline-flex; }

  .app-body { grid-template-columns: 1fr; }
  .app-main { padding: 22px 16px; max-width: 100%; }

  /* Sidebar becomes off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(280px, 85vw);
    z-index: 50;
    background: var(--bg-alt);
    border-right: 1px solid var(--line);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
    padding-top: 20px;
    box-shadow: 0 12px 40px -12px rgba(20,12,4,0.25);
  }
  body.drawer-open .sidebar { transform: translateX(0); }

  /* NAV (declared in landing-v2.css) compressed */
  .nav { padding: 10px 14px; gap: 8px; }
  .nav .brand { font-size: 18px; }
  .nav .brand-mark { width: 24px; height: 24px; font-size: 14px; }
  .nav-right { gap: 6px; }
  .nav-right .nav-home { display: none; }  /* hide "На главную" on mobile — burger + sidebar covers nav */

  /* page-head: avatar/summary stack */
  .page-head { gap: 14px; align-items: flex-start; }
  .page-title { font-size: 28px; }

  /* Stats */
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 16px; }
  .stat-value { font-size: 26px; }

  /* Cards */
  .card { padding: 18px; border-radius: var(--radius-md); }

  /* Dropzone compact */
  .dropzone { padding: 32px 16px; }

  /* Forms full-width */
  .input, .select, .textarea { font-size: 16px; }  /* avoid iOS zoom */

  /* Inline 1fr 1fr / 1fr 1fr 1fr grids → stack */
  .grid-2,
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Lang/option tiles denser */
  [id="lang-grid"] {
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)) !important;
  }

  /* Book grid */
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }

  /* Tables → horizontal scroll */
  .table { display: block; overflow-x: auto; white-space: nowrap; }

  /* Modal */
  .modal-overlay { padding: 12px; align-items: flex-end; }
  .modal-card {
    padding: 22px 20px 18px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-width: 100%;
  }
  .modal-actions .btn { flex: 1 1 auto; }

  /* Pricing cards 1 col */
  .pricing-grid, .app-plan + .app-plan { width: 100%; }

  /* Avatar smaller */
  #user-avatar { width: 30px !important; height: 30px !important; font-size: 12px !important; }
}

@media (max-width: 480px) {
  .app-main { padding: 18px 12px; }
  .page-title { font-size: 24px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 22px; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
}

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: color-mix(in oklch, var(--ink) 55%, transparent);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.modal-overlay.visible { opacity: 1; }
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px 28px 22px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,0.35);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.2s ease;
}
.modal-overlay.visible .modal-card { transform: translateY(0) scale(1); }
.modal-title {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: -0.01em;
  font-weight: 500;
  margin-bottom: 10px;
  line-height: 1.2;
}
.modal-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
  margin-bottom: 22px;
}
.modal-body strong { color: var(--ink); font-weight: 600; }
.modal-body .accent { color: var(--accent); font-weight: 500; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
}
