/* BlibliSummary — editorial reader shell */

:root {
  color-scheme: dark;
  --font-ui: "DM Sans", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-read: "Literata", "Songti SC", "STSong", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --bg-deep: #09090b;
  --bg-base: #0f0f12;
  --bg-elevated: #16161c;
  --bg-hover: #1e1e26;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-strong: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text: #f4f4f5;
  --text-secondary: #c4c4cc;
  --text-muted: #8b8b96;
  --accent: #fb7299;
  --accent-soft: rgba(251, 114, 153, 0.14);
  --accent-blue: #23ade5;
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);

  --reader-paper: #faf7f2;
  --reader-ink: #1a1816;
  --reader-muted: #6b6560;
  --reader-border: rgba(26, 24, 22, 0.1);
  --reader-quote: #8b4513;

  --sidebar-w: 248px;
  --topbar-h: 56px;
  --mobile-nav-h: 64px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(251, 114, 153, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(35, 173, 229, 0.08), transparent 50%);
  z-index: 0;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

a:hover {
  color: var(--accent);
}

/* ── App shell ── */

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.app-shell.guest {
  grid-template-columns: 1fr;
}

.app-shell.reader-mode {
  grid-template-columns: 1fr;
}

.app-shell.reader-mode .sidebar,
.app-shell.reader-mode .mobile-nav {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px;
  border-right: 1px solid var(--border);
  background: rgba(15, 15, 18, 0.82);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 20px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #ff9ec0 55%, var(--accent-blue));
  box-shadow: 0 8px 24px rgba(251, 114, 153, 0.25);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}

.brand-text h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.15s var(--ease);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  opacity: 0.75;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: #fff;
}

.nav-item.active svg {
  opacity: 1;
  color: var(--accent);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, #334155, #1e293b);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.user-meta {
  min-width: 0;
}

.user-meta strong {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-meta span {
  font-size: 11px;
  color: var(--text-muted);
}

.main-area {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 9, 11, 0.75);
  backdrop-filter: blur(16px);
}

.topbar-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.page-body {
  flex: 1;
  padding: 24px;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
}

.page-body.wide {
  max-width: 1280px;
}

.page-body.reader-page {
  max-width: none;
  padding: 0;
}

.mobile-nav {
  display: none;
}

/* ── Alerts ── */

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  animation: slideIn 0.35s var(--ease);
}

.alert-error {
  color: #fecaca;
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.alert-notice {
  color: #bbf7d0;
  background: var(--ok-soft);
  border: 1px solid rgba(74, 222, 128, 0.25);
}

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

/* ── Cards & layout ── */

.stack {
  display: grid;
  gap: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.4s var(--ease) both;
}

.card h2,
.card h3 {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.card-sub {
  margin: -8px 0 16px;
  font-size: 13px;
  color: var(--text-muted);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.muted {
  color: var(--text-muted);
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Forms & buttons ── */

label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-base);
  color: var(--text);
  font: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(251, 114, 153, 0.45);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--accent), #ff8fb3);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 4px 16px rgba(251, 114, 153, 0.25);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(251, 114, 153, 0.3);
}

button:active {
  transform: translateY(0);
}

button.secondary {
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--border);
}

button.secondary:hover {
  background: var(--bg-hover);
  box-shadow: none;
}

button.ghost {
  background: transparent;
  color: var(--text-secondary);
  box-shadow: none;
  border: 1px solid transparent;
}

button.ghost:hover {
  background: var(--surface);
  color: var(--text);
  box-shadow: none;
}

button.danger {
  background: linear-gradient(135deg, #ef4444, #f87171);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.25);
}

button.linkish {
  background: transparent;
  border: 0;
  color: var(--accent-blue);
  padding: 0;
  font-weight: 500;
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}

button.linkish:hover {
  color: var(--accent);
  transform: none;
  box-shadow: none;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ── Login ── */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-grid {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: fadeUp 0.5s var(--ease);
}

.login-hero {
  padding: 48px 40px;
  background: linear-gradient(145deg, rgba(251, 114, 153, 0.18), rgba(35, 173, 229, 0.1) 50%, transparent);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-hero h2 {
  margin: 0 0 12px;
  font-family: var(--font-read);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.login-hero p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.65;
}

.login-form-panel {
  padding: 48px 40px;
  background: var(--bg-elevated);
}

.login-form-panel h3 {
  margin: 0 0 24px;
  font-size: 20px;
  font-weight: 600;
}

/* ── Dashboard ── */

.quota-ring-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
}

.quota-ring {
  --pct: 0%;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--pct), var(--surface-strong) 0);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.quota-ring-inner {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
}

.stat-pill.ok {
  color: var(--ok);
  background: var(--ok-soft);
}

.stat-pill.pending {
  color: var(--warn);
  background: var(--warn-soft);
}

.folder-preview {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  font-size: 13px;
  word-break: break-all;
}

/* ── Notes list ── */

.note-list {
  display: grid;
  gap: 10px;
}

.note-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
}

.note-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  transform: translateX(2px);
}

.note-item-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
  line-height: 1.4;
}

.note-item-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.note-item-action {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.35;
  margin-bottom: 12px;
}

/* ── Markdown reader ── */

.reader {
  min-height: calc(100vh - var(--topbar-h));
  background: linear-gradient(180deg, var(--bg-base) 0%, #0a0a0d 100%);
}

.reader-toolbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 9, 11, 0.9);
  backdrop-filter: blur(12px);
}

.reader-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 0;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.reader-paper {
  background: var(--reader-paper);
  color: var(--reader-ink);
  border-radius: 16px;
  padding: clamp(28px, 5vw, 56px) clamp(24px, 5vw, 64px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 32px 64px rgba(0, 0, 0, 0.4);
  min-height: 60vh;
}

.reader-toc {
  position: sticky;
  top: calc(var(--topbar-h) + 72px);
  align-self: start;
  padding: 16px 0 16px 24px;
  max-height: calc(100vh - 140px);
  overflow: auto;
}

.reader-toc-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.reader-toc a {
  display: block;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  padding-left: 12px;
  transition: color 0.2s, border-color 0.2s;
}

.reader-toc a:hover,
.reader-toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.reader-toc a.level-3 {
  padding-left: 24px;
  font-size: 12px;
}

.markdown-body {
  font-family: var(--font-read);
  font-size: clamp(16px, 1.05vw, 18px);
  line-height: 1.82;
  letter-spacing: 0.01em;
  word-wrap: break-word;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  font-family: var(--font-read);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
  scroll-margin-top: 100px;
}

.markdown-body h1 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  margin: 0 0 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--reader-border);
}

.markdown-body h2 {
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
  margin: 2em 0 0.75em;
  color: var(--reader-ink);
}

.markdown-body h3 {
  font-size: 1.15rem;
  margin: 1.5em 0 0.5em;
}

.markdown-body p {
  margin: 0 0 1.1em;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 1.1em;
  padding-left: 1.4em;
}

.markdown-body li {
  margin: 0.35em 0;
}

.markdown-body li > p {
  margin: 0.25em 0;
}

.markdown-body blockquote {
  margin: 1.5em 0;
  padding: 0.5em 0 0.5em 1.2em;
  border-left: 3px solid var(--accent);
  color: var(--reader-muted);
  font-style: italic;
}

.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.15em 0.45em;
  border-radius: 6px;
  background: rgba(26, 24, 22, 0.08);
  color: #9a3412;
}

.markdown-body pre {
  margin: 1.25em 0;
  padding: 16px 18px;
  border-radius: 12px;
  background: #1e1e1e;
  color: #e4e4e7;
  overflow: auto;
  font-size: 0.85em;
  line-height: 1.6;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25em 0;
  font-size: 0.92em;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--reader-border);
  padding: 10px 12px;
  text-align: left;
}

.markdown-body th {
  background: rgba(26, 24, 22, 0.06);
  font-weight: 600;
}

.markdown-body hr {
  border: 0;
  height: 1px;
  background: var(--reader-border);
  margin: 2em 0;
}

.markdown-body a {
  color: #c2410c;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.markdown-body img {
  max-width: 100%;
  border-radius: 8px;
}

.markdown-body strong {
  font-weight: 700;
  color: var(--reader-ink);
}

.transcript-panel {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.transcript-panel summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.transcript-panel pre {
  margin-top: 12px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  overflow: auto;
  max-height: 360px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Tables (admin) ── */

.table-wrap {
  overflow: auto;
  margin: 0 -4px;
  border-radius: var(--radius-sm);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data-table th {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 1;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 10px;
  border-bottom: 1px solid var(--border-strong);
  text-align: left;
}

table.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.data-table tbody tr:hover td {
  background: var(--surface);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.badge.ok {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: rgba(74, 222, 128, 0.2);
}

.badge.fail {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.2);
}

.badge.pending {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: rgba(251, 191, 36, 0.2);
}

.badge.source-bili {
  color: #fb7299;
  background: rgba(251, 114, 153, 0.14);
  border: 1px solid rgba(251, 114, 153, 0.25);
}

.badge.source-yt {
  color: #ff4444;
  background: rgba(255, 68, 68, 0.12);
  border: 1px solid rgba(255, 68, 68, 0.22);
}

.folder-preview-row {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.folder-preview-row:last-child {
  border-bottom: 0;
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 160px;
}

.actions-cell button {
  padding: 6px 10px;
  font-size: 12px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chips button {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
}

.filter-chips button.active-filter {
  background: var(--accent-soft);
  color: #fff;
  border: 1px solid rgba(251, 114, 153, 0.35);
  box-shadow: none;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform 0.2s var(--ease);
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-card.ok {
  border-color: rgba(74, 222, 128, 0.25);
}

.stat-card.fail {
  border-color: rgba(248, 113, 113, 0.25);
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.task-error {
  margin-top: 6px;
  font-size: 11px;
  color: var(--danger);
  line-height: 1.4;
}

.credential-card {
  border-color: rgba(74, 222, 128, 0.3);
  background: linear-gradient(135deg, var(--ok-soft), transparent);
}

.credential-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.credential-row:last-of-type {
  border-bottom: 0;
}

.credential-row code {
  font-family: var(--font-mono);
  font-size: 14px;
  word-break: break-all;
}

.row-pending td:first-child {
  font-weight: 600;
}

.folder-cell {
  display: grid;
  gap: 2px;
  font-size: 13px;
}

.folder-cell strong {
  font-weight: 600;
}

.folder-url-cell {
  max-width: 280px;
  word-break: break-all;
  font-size: 12px;
}

.folder-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
}

.folder-meta-grid .muted {
  display: block;
  font-size: 11px;
  margin-bottom: 4px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fadeIn 0.2s var(--ease);
}

.modal-panel {
  width: min(520px, 100%);
  max-height: min(90vh, 640px);
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.25s var(--ease);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ── Mobile ── */

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding-bottom: var(--mobile-nav-h);
  }

  .sidebar {
    display: none;
  }

  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    height: var(--mobile-nav-h);
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: rgba(15, 15, 18, 0.92);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    gap: 4px;
  }

  .mobile-nav .nav-item {
    flex: 1;
    flex-direction: column;
    gap: 4px;
    padding: 6px 4px;
    font-size: 11px;
    text-align: center;
    justify-content: center;
  }

  .mobile-nav .nav-item svg {
    width: 20px;
    height: 20px;
  }

  .topbar {
    padding: 0 16px;
  }

  .page-body {
    padding: 16px;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .login-grid {
    grid-template-columns: 1fr;
  }

  .login-hero {
    display: none;
  }

  .reader-layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .reader-toc {
    display: none;
  }

  .reader-paper {
    padding: 28px 20px;
    border-radius: 12px;
  }

  .reader-toolbar {
    padding: 10px 16px;
    flex-wrap: wrap;
  }

  .quota-ring-wrap {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions-cell {
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .credential-row {
    grid-template-columns: 1fr;
  }

  .filter-chips button {
    flex: 1 1 calc(50% - 4px);
  }
}
