/* ==========================================================================
   KU Neo-Manga Editorial Design System
   Committed World: 90s Manga Ink Panel Craft + High-Legibility Thai Editorial
   ========================================================================== */

:root {
  --paper: #FAF8F3;
  --paper-warm: #F1EDE2;
  --surface: #FFFFFF;
  --ink: #141414;
  --ink-soft: #3D423E;
  --ink-muted: #656C66;
  --rule: #D6D0C2;

  --ku: #0A7A53;
  --ku-dark: #065539;
  --ku-tint: #E4F4ED;
  --signal: #D94E2A;
  --signal-tint: #FCEAE4;
  --amber: #B4630E;
  --amber-tint: #FEF3DF;
  --line-green: #06C755;
  --line-dark: #059E44;

  --font-display: 'Kanit', 'Noto Sans Thai', sans-serif;
  --font-body: 'Noto Sans Thai', system-ui, -apple-system, sans-serif;

  --border-ink: 2px solid var(--ink);
  --shadow-panel: 4px 4px 0 var(--ink);
  --shadow-sm: 2px 2px 0 var(--ink);
  --radius: 6px;
  --radius-sm: 4px;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--ku);
  color: #FFFFFF;
}

input, textarea, select {
  caret-color: var(--ku);
  font-family: var(--font-body);
}

:focus-visible {
  outline: 2.5px solid var(--ku);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--paper-warm);
  border-left: 1px solid var(--rule);
}
::-webkit-scrollbar-thumb {
  background: var(--ink);
  border: 2px solid var(--paper-warm);
}

.tabular {
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

a {
  color: var(--ku-dark);
  text-underline-offset: 3px;
}

/* Halftone texture — used strictly on accent/editorial regions */
.halftone-bg {
  background-color: var(--ku);
  background-image: radial-gradient(rgba(20, 20, 20, 0.22) 1.3px, transparent 1.3px);
  background-size: 9px 9px;
}

.halftone-paper {
  background-color: var(--paper-warm);
  background-image: radial-gradient(rgba(20, 20, 20, 0.1) 1.2px, transparent 1.2px);
  background-size: 10px 10px;
}

/* Boot Loader */
.boot-loader {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.boot-panel {
  background: var(--surface);
  border: var(--border-ink);
  box-shadow: var(--shadow-panel);
  padding: 28px 36px;
  text-align: center;
}
.boot-mark {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  background: var(--ku);
  color: #FFF;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  border: var(--border-ink);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}

/* ==========================================================================
   App Shell (Header + Side/Top Navigation)
   ========================================================================== */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: var(--border-ink);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}
.brand-badge {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: var(--ku);
  color: #FFF;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  border: var(--border-ink);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  line-height: 1.1;
}
.brand-sub {
  font-size: 11px;
  color: var(--ink-muted);
  display: block;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: background 140ms ease, transform 120ms ease, border-color 140ms ease;
}
.nav-link:hover {
  background: var(--paper-warm);
  color: var(--ink);
}
.nav-link.active {
  background: var(--ku);
  color: #FFFFFF;
  border-color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  background: var(--signal);
  color: #FFF;
  border: 1.5px solid var(--ink);
  font-variant-numeric: tabular-nums;
}
.nav-link.active .nav-count {
  background: #FFF;
  color: var(--ink);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 5px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-size: 13px;
  font-weight: 600;
}
.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  object-fit: cover;
  background: var(--ku-tint);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--ku-dark);
}
.role-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  background: var(--ink);
  color: #FFF;
  border-radius: 3px;
  text-transform: uppercase;
}

.page-wrap {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 64px;
  flex: 1;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  margin-bottom: 24px;
  border-bottom: var(--border-ink);
}
.page-header h1 {
  font-size: 28px;
  font-weight: 800;
}
.page-lead {
  margin: 6px 0 0;
  color: var(--ink-soft);
  max-width: 68ch;
  font-size: 14.5px;
}
.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* ==========================================================================
   Buttons & Inputs (Tactile Neo-Manga Press)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: var(--border-ink);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-decoration: none;
  transition: transform 110ms ease, box-shadow 110ms ease, background 120ms ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  background: var(--paper-warm);
}
.btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--ku);
  color: #FFFFFF;
}
.btn-primary:hover:not(:disabled) {
  background: var(--ku-dark);
}

.btn-signal {
  background: var(--signal);
  color: #FFFFFF;
}
.btn-signal:hover:not(:disabled) {
  background: #BC3E1D;
}

.btn-line {
  background: var(--line-green);
  color: #FFFFFF;
}
.btn-line:hover:not(:disabled) {
  background: var(--line-dark);
}

.btn-ink {
  background: var(--ink);
  color: #FFFFFF;
}
.btn-ink:hover:not(:disabled) {
  background: #2C2F2D;
}

.btn-ghost {
  border: 1.5px solid var(--rule);
  box-shadow: none;
  background: transparent;
  font-weight: 600;
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--ink);
  background: var(--paper-warm);
}

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

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--rule);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 120ms ease;
}
.icon-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--paper-warm);
}
.icon-btn.starred {
  border-color: var(--ink);
  background: var(--amber-tint);
  color: var(--amber);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink);
}
.field-hint {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin: 0;
}

.input, .textarea, .select {
  width: 100%;
  padding: 9px 12px;
  border: var(--border-ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 14.5px;
  transition: box-shadow 120ms ease;
}
.input:focus, .textarea:focus, .select:focus {
  box-shadow: var(--shadow-sm);
  outline: none;
  border-color: var(--ku);
}
.textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.55;
}

/* ==========================================================================
   Ink Panels & Structural Layout (Flat hierarchy — no nested cards)
   ========================================================================== */
.panel {
  background: var(--surface);
  border: var(--border-ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
  padding: 22px;
}

.panel-flat {
  background: var(--surface);
  border: var(--border-ink);
  border-radius: var(--radius);
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1.5px solid var(--rule);
}
.panel-header h2 {
  font-size: 19px;
  font-weight: 700;
}

.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.stack-md { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }

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

/* ==========================================================================
   Login View — Neo-Manga Editorial Cover
   ========================================================================== */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  border-top: 6px solid var(--ink);
}

.login-hero {
  position: relative;
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #FFFFFF;
  border-right: var(--border-ink);
  overflow: hidden;
}

.login-hero-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.login-mark {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  border: var(--border-ink);
  box-shadow: 3px 3px 0 var(--ink);
}
.login-hero h1 {
  font-size: clamp(32px, 4.2vw, 48px);
  font-weight: 800;
  line-height: 1.15;
  margin: 28px 0 18px;
  text-shadow: 3px 3px 0 rgba(20, 20, 20, 0.45);
}
.login-hero p {
  font-size: 16px;
  max-width: 48ch;
  color: #EAF7F1;
  margin: 0;
}

.manga-preview-strip {
  margin-top: 32px;
  background: var(--paper);
  color: var(--ink);
  border: var(--border-ink);
  box-shadow: 6px 6px 0 var(--ink);
  padding: 18px 20px;
}
.manga-preview-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--rule);
}
.manga-preview-row:last-child { border-bottom: none; padding-bottom: 0; }
.manga-preview-row:first-child { padding-top: 0; }
.manga-preview-title {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.45;
}
.manga-preview-meta {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.login-side {
  display: grid;
  place-items: center;
  padding: 40px 28px;
  background: var(--paper);
}
.login-box {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: var(--border-ink);
  box-shadow: 6px 6px 0 var(--ink);
  padding: 32px 28px;
}
.login-box h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
}
.login-box .desc {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 22px;
}

.google-btn {
  width: 100%;
  padding: 12px 18px;
  font-size: 15px;
  background: var(--surface);
  color: var(--ink);
}
.google-btn:hover {
  background: var(--ku-tint);
}

.alert-banner {
  padding: 12px 14px;
  border: var(--border-ink);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-error { background: var(--signal-tint); color: #7C1F0A; }
.alert-success { background: var(--ku-tint); color: #05442E; }
.alert-warn { background: var(--amber-tint); color: #753D05; }
.alert-info { background: var(--paper-warm); color: var(--ink); }

/* ==========================================================================
   Stamps, Manga Speech Bubble & Feed Document Rows
   ========================================================================== */
.stamp {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  white-space: nowrap;
}
.stamp-relevant {
  background: var(--ku);
  color: #FFFFFF;
  transform: rotate(-1.5deg);
}
.stamp-uncertain {
  background: var(--amber-tint);
  color: var(--amber);
  transform: rotate(1deg);
}
.stamp-topic {
  background: var(--paper-warm);
  color: var(--ink);
}
.stamp-new {
  background: var(--signal);
  color: #FFFFFF;
}

.manga-bubble {
  position: relative;
  margin-top: 10px;
  padding: 9px 13px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--ink-soft);
  max-width: 75ch;
}
.manga-bubble::before {
  content: '';
  position: absolute;
  top: -7px;
  left: 18px;
  width: 11px;
  height: 11px;
  background: var(--paper);
  border-left: 1.5px solid var(--ink);
  border-top: 1.5px solid var(--ink);
  transform: rotate(45deg);
}
.manga-bubble strong {
  color: var(--ku-dark);
}

/* Filter Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  background: var(--paper-warm);
  border: var(--border-ink);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.toolbar-search {
  flex: 1 1 240px;
  position: relative;
}
.toolbar-search input {
  padding-left: 36px;
}
.toolbar-search .search-ico {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
}

.seg-group {
  display: inline-flex;
  border: var(--border-ink);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.seg-btn {
  padding: 7px 12px;
  border: none;
  border-right: 1.5px solid var(--ink);
  background: transparent;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.seg-btn:last-child { border-right: none; }
.seg-btn.active {
  background: var(--ink);
  color: #FFFFFF;
}

/* Document List (Editorial Ruled Ledger — clean, dense, zero nested-card clutter) */
.doc-ledger {
  background: var(--surface);
  border: var(--border-ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}

.doc-row {
  padding: 18px 20px;
  border-bottom: 1.5px solid var(--rule);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
  transition: background 120ms ease;
}
.doc-row:last-child { border-bottom: none; }
.doc-row:hover { background: #FCFBFA; }
.doc-row.unread { background: #F5FBF8; }
.doc-row.unread:hover { background: #EDF7F2; }

.doc-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
}

.doc-title {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink);
  margin: 0;
  max-width: 74ch;
}
.doc-row.read .doc-title {
  font-weight: 600;
  color: var(--ink-soft);
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-muted);
}
.doc-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.doc-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.doc-icon-row {
  display: flex;
  gap: 6px;
}

/* ==========================================================================
   Topic Chips & Tag Input
   ========================================================================== */
.chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border: 1.5px dashed var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all 120ms ease;
}
.preset-chip:hover {
  border-style: solid;
  background: var(--ku-tint);
  color: var(--ku-dark);
}

.topic-list {
  display: flex;
  flex-direction: column;
  border: var(--border-ink);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.topic-item {
  padding: 16px 18px;
  border-bottom: 1.5px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}
.topic-item:last-child { border-bottom: none; }
.topic-item.inactive {
  opacity: 0.6;
  background: var(--paper-warm);
}
.topic-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
}
.exclude-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  background: var(--signal-tint);
  color: #8E250E;
  border: 1px solid #E4A391;
  border-radius: 3px;
}

/* ==========================================================================
   Quota Bar & Data Tables (Admin)
   ========================================================================== */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: var(--border-ink);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}
.stat-cell {
  padding: 16px 18px;
  border-right: 1.5px solid var(--rule);
}
.stat-cell:last-child { border-right: none; }
.stat-num {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-lbl {
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 4px;
}

.quota-track {
  height: 14px;
  background: var(--paper-warm);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}
.quota-fill {
  height: 100%;
  background: var(--ku);
  transition: width 300ms ease;
}
.quota-fill.warn { background: var(--amber); }
.quota-fill.danger { background: var(--signal); }

.table-scroll {
  overflow-x: auto;
  border: var(--border-ink);
  border-radius: var(--radius);
  background: var(--surface);
}
table.ink-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.ink-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--paper-warm);
  border-bottom: var(--border-ink);
  font-weight: 700;
  white-space: nowrap;
}
table.ink-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}
table.ink-table tr:last-child td { border-bottom: none; }

/* Toggle Switch */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}
.switch-row:last-child { border-bottom: none; }
.switch-title { font-weight: 700; font-size: 14.5px; }
.switch-desc { font-size: 13px; color: var(--ink-muted); margin-top: 2px; }

.toggle {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--paper-warm);
  border: 2px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
  transition: background 150ms ease;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--ink);
  border-radius: 50%;
  transition: transform 150ms ease;
}
.toggle input:checked + .toggle-slider {
  background: var(--ku);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #FFFFFF;
}

/* Empty State & Skeleton */
.empty-manga {
  padding: 40px 24px;
  text-align: center;
  border: var(--border-ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
}
.empty-manga h3 {
  font-size: 21px;
  margin: 10px 0 8px;
}
.empty-manga p {
  max-width: 52ch;
  margin: 0 auto 18px;
  color: var(--ink-soft);
}

.skeleton-line {
  height: 16px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--paper-warm) 25%, #E7E2D4 50%, var(--paper-warm) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Toast Notifications */
.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.toast {
  padding: 12px 16px;
  border: var(--border-ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  background: var(--ink);
  color: #FFFFFF;
  font-size: 13.5px;
  font-weight: 600;
}
.toast.ok { background: var(--ku); }
.toast.err { background: var(--signal); }

/* Sub-tabs (Admin) */
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.subtab {
  padding: 8px 14px;
  border: var(--border-ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
}
.subtab.active {
  background: var(--ink);
  color: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

.secret-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
}
.secret-pill.ready { background: var(--ku-tint); color: var(--ku-dark); }
.secret-pill.missing { background: var(--signal-tint); color: #8A220A; }

/* Code Box */
.code-highlight {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 12px 18px;
  background: var(--paper-warm);
  border: var(--border-ink);
  display: inline-block;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Responsive (Mobile + Tablet)
   ========================================================================== */
@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-hero { border-right: none; border-bottom: var(--border-ink); padding: 36px 24px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-cell:nth-child(2) { border-right: none; }
  .stat-cell:nth-child(1), .stat-cell:nth-child(2) { border-bottom: 1.5px solid var(--rule); }
}

@media (max-width: 720px) {
  .topbar-inner {
    height: auto;
    padding: 10px 14px;
    flex-wrap: wrap;
  }
  .main-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-top: 6px;
    border-top: 1px solid var(--rule);
  }
  .user-pill .user-email-text { display: none; }
  .doc-row { grid-template-columns: 1fr; }
  .doc-actions {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }
  .page-wrap { padding: 18px 14px 48px; }
  .page-header h1 { font-size: 23px; }
}
