/**
 * ==============================================================================
 * ALKAYS ADMIN - DESIGN SYSTEM
 * File: admin/assets/css/admin.css
 * ==============================================================================
 * 01 Tokens · 02 Base · 03 Shell (sidebar / topbar / main / preview)
 * 04 Buttons · 05 Cards & page header · 06 Form fields · 07 Language tabs
 * 08 Toggle / segmented / chips · 09 Repeater · 10 Save bar · 11 Lists & tables
 * 12 Dialogs · 13 Toasts · 14 Media · 15 Markdown · 16 Auth screens
 * 17 Dashboard · 18 Utilities · 19 Responsive
 */

/* ==========================================================================
   01. TOKENS
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg: #070a11;
  --bg-2: #0a0f19;
  --panel: #0d131f;
  --panel-2: #121a29;
  --panel-3: #18223a;
  --inset: #060910;

  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.15);

  --ink: #eef3fa;
  --ink-2: #b3c0d4;
  --ink-3: #8494ad;
  --ink-4: #5d6c84;

  --accent: #00e5ff;
  --accent-2: #38bdf8;
  --accent-ink: #04060a;
  --accent-soft: rgba(0, 229, 255, 0.1);
  --accent-line: rgba(0, 229, 255, 0.3);
  --grad: linear-gradient(135deg, #00e5ff 0%, #38bdf8 46%, #6366f1 100%);

  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.12);
  --danger-solid: #e11d48;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 14px 34px -14px rgba(0, 0, 0, 0.75);
  --shadow-3: 0 30px 70px -24px rgba(0, 0, 0, 0.9);

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", "Roboto Mono", Consolas, monospace;

  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 999px;

  --sidebar-w: 264px;
  --topbar-h: 60px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 130ms var(--ease);
  --t-base: 220ms var(--ease);
}

[data-theme="light"] {
  color-scheme: light;

  --bg: #eff3f9;
  --bg-2: #e8edf5;
  --panel: #ffffff;
  --panel-2: #f5f8fc;
  --panel-3: #eaf0f8;
  --inset: #f5f8fc;

  --line: rgba(13, 20, 33, 0.1);
  --line-2: rgba(13, 20, 33, 0.2);

  --ink: #0d1421;
  --ink-2: #3d4b61;
  --ink-3: #5b6b82;
  --ink-4: #66758c;

  --accent: #0e7490;
  --accent-2: #0369a1;
  --accent-ink: #ffffff;
  --accent-soft: rgba(14, 116, 144, 0.09);
  --accent-line: rgba(14, 116, 144, 0.32);
  --grad: linear-gradient(135deg, #0e7490 0%, #0369a1 52%, #4f46e5 100%);

  --ok: #047857;
  --ok-soft: rgba(4, 120, 87, 0.1);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.1);
  --danger: #be123c;
  --danger-soft: rgba(190, 18, 60, 0.08);
  --danger-solid: #be123c;

  --shadow-1: 0 1px 2px rgba(13, 20, 33, 0.07);
  --shadow-2: 0 12px 28px -14px rgba(13, 20, 33, 0.22);
  --shadow-3: 0 28px 60px -26px rgba(13, 20, 33, 0.32);
}

/* ==========================================================================
   02. BASE
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
  padding: 0;
}

ul,
ol {
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg,
canvas,
iframe {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

button:disabled {
  cursor: not-allowed;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

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

@supports (scrollbar-width: thin) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--line-2) transparent;
  }
}

.ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.ico-sm {
  width: 15px;
  height: 15px;
}

.ico-lg {
  width: 22px;
  height: 22px;
}

.mono {
  font-family: var(--mono);
}

.muted {
  color: var(--ink-3);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.spinner-lg {
  width: 34px;
  height: 34px;
  border-width: 3px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

/* ==========================================================================
   03. SHELL
   ========================================================================== */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  height: var(--topbar-h);
  padding: 0 1.1rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-sm);
}

.brand-name {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.15;
}

.brand-sub {
  display: block;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 0.6rem 0.65rem 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.nav-group {
  margin-top: 0.9rem;
}

.nav-group:first-child {
  margin-top: 0.2rem;
}

.nav-group-title {
  padding: 0.3rem 0.6rem;
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  transition: color var(--t-fast), background-color var(--t-fast);
}

.nav-item:hover {
  color: var(--ink);
  background: var(--panel-2);
}

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

.nav-item .ico {
  width: 17px;
  height: 17px;
  opacity: 0.9;
}

.nav-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-badge {
  min-width: 20px;
  padding: 0.05rem 0.4rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: var(--r-full);
}

.sidebar-foot {
  flex-shrink: 0;
  padding: 0.75rem 0.9rem;
  border-top: 1px solid var(--line);
  font-size: 0.74rem;
  color: var(--ink-4);
}

.sidebar-foot a {
  color: var(--ink-3);
}

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

.sidebar-overlay {
  display: none;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--topbar-h);
  padding: 0 1.25rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.topbar-menu {
  display: none;
}

.topbar-title {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.sync-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.6rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  white-space: nowrap;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

.sync-chip[data-state="offline"] .sync-dot {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.sync-chip[data-state="saving"] .sync-dot {
  background: var(--warn);
  box-shadow: 0 0 8px var(--warn);
}

.user-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 36px;
  padding: 0 0.5rem 0 0.3rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  transition: border-color var(--t-fast);
}

.user-btn:hover {
  border-color: var(--line-2);
}

.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--grad);
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-email {
  max-width: 180px;
  font-size: 0.8rem;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu {
  position: absolute;
  z-index: 60;
  min-width: 220px;
  padding: 0.3rem;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  animation: fadeIn 140ms var(--ease);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 0.875rem;
  color: var(--ink-2);
  border-radius: var(--r-xs);
  text-align: left;
}

.menu-item:hover {
  color: var(--ink);
  background: var(--panel-3);
}

.menu-item.danger {
  color: var(--danger);
}

.menu-sep {
  height: 1px;
  margin: 0.3rem 0;
  background: var(--line);
}

.menu-head {
  padding: 0.5rem 0.6rem 0.4rem;
  font-size: 0.78rem;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.stage.has-preview {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 44%);
}

.page {
  min-width: 0;
  padding: 1.5rem 1.5rem 6rem;
}

.page-inner {
  max-width: 980px;
  margin: 0 auto;
  animation: fadeIn 200ms var(--ease);
}

.page-inner.wide {
  max-width: 1240px;
}

/* Live preview panel */

.preview {
  position: sticky;
  top: var(--topbar-h);
  display: none;
  flex-direction: column;
  height: calc(100dvh - var(--topbar-h));
  background: var(--bg-2);
  border-left: 1px solid var(--line);
}

.stage.has-preview .preview {
  display: flex;
}

.preview-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.preview-title {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  padding: 0.75rem;
  overflow: hidden;
}

.preview-frame {
  width: 100%;
  height: 100%;
  background: #070a11;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
}

.preview-stage[data-device="tablet"] .preview-frame {
  max-width: 820px;
}

.preview-stage[data-device="mobile"] .preview-frame {
  max-width: 400px;
}

.preview-note {
  position: absolute;
  inset: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--ink-2);
  background: var(--panel);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
}

/* ==========================================================================
   04. BUTTONS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  height: 38px;
  padding: 0 0.95rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}

.btn:hover:not(:disabled) {
  background: var(--panel-3);
  border-color: var(--ink-4);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
}

.btn .ico {
  width: 16px;
  height: 16px;
}

.btn-primary {
  color: var(--accent-ink);
  background: var(--grad);
  border-color: transparent;
}

.btn-primary:hover:not(:disabled) {
  background: var(--grad);
  border-color: transparent;
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--ink);
  background: var(--panel-2);
  border-color: var(--line);
}

.btn-danger {
  color: #fff;
  background: var(--danger-solid);
  border-color: transparent;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-solid);
  border-color: transparent;
  filter: brightness(1.1);
}

.btn-danger-ghost {
  color: var(--danger);
  background: transparent;
  border-color: transparent;
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: transparent;
}

.btn-sm {
  height: 32px;
  padding: 0 0.7rem;
  font-size: 0.8rem;
}

.btn-lg {
  height: 46px;
  padding: 0 1.4rem;
  font-size: 0.95rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  flex-shrink: 0;
}

.btn-icon.btn-sm {
  width: 30px;
  height: 30px;
}

.btn.is-busy {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.is-busy > * {
  visibility: hidden;
}

.btn.is-busy::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--ink-3);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-primary.is-busy::after,
.btn-danger.is-busy::after {
  border-color: rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* ==========================================================================
   05. CARDS & PAGE HEADER
   ========================================================================== */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.page-head-text {
  min-width: 0;
}

.page-eyebrow {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.page-title {
  margin-top: 0.2rem;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.page-desc {
  margin-top: 0.35rem;
  max-width: 68ch;
  font-size: 0.9rem;
  color: var(--ink-3);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}

.card + .card {
  margin-top: 1rem;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.95rem 1.15rem;
  border-bottom: 1px solid var(--line);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.98rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card-title .ico {
  color: var(--accent);
}

.card-sub {
  width: 100%;
  margin-top: -0.2rem;
  font-size: 0.82rem;
  color: var(--ink-3);
}

.card-body {
  padding: 1.15rem;
}

.card-body.flush {
  padding: 0;
}

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

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem 1rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.row-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.spacer {
  flex: 1;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 0.9rem;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--ink-2);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-md);
}

.notice .ico {
  margin-top: 1px;
  color: var(--accent);
}

.notice.warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
}

.notice.warn .ico {
  color: var(--warn);
}

.notice.danger {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

.notice.danger .ico {
  color: var(--danger);
}

.notice.ok {
  background: var(--ok-soft);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
}

.notice.ok .ico {
  color: var(--ok);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2.75rem 1.5rem;
  text-align: center;
  color: var(--ink-3);
}

.empty .ico {
  width: 34px;
  height: 34px;
  color: var(--ink-4);
}

.empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.empty-text {
  max-width: 46ch;
  font-size: 0.88rem;
}

.loading-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 2.5rem 1rem;
  font-size: 0.88rem;
  color: var(--ink-3);
}

/* ==========================================================================
   06. FORM FIELDS
   ========================================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 22px;
}

.label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-2);
}

.label .req {
  color: var(--danger);
}

.hint {
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--ink-3);
}

.field-error {
  font-size: 0.78rem;
  color: var(--danger);
}

.counter {
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--ink-4);
}

.counter.over {
  color: var(--danger);
}

.input,
.textarea,
.select {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--ink);
  background: var(--inset);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--ink-4);
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--ink-4);
}

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

.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.input:disabled,
.textarea:disabled,
.select:disabled {
  opacity: 0.6;
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

.textarea.code,
.input.code {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.6;
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.input-group {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
}

.input-group .input {
  flex: 1;
}

.search {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search .ico {
  position: absolute;
  top: 50%;
  left: 0.65rem;
  width: 16px;
  height: 16px;
  color: var(--ink-4);
  transform: translateY(-50%);
  pointer-events: none;
}

.search .input {
  padding-left: 2.1rem;
}

/* ==========================================================================
   07. LANGUAGE TABS (localized inputs)
   ========================================================================== */

.loc {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.lang-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
}

.lang-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.12rem 0.45rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  border-radius: 4px;
  transition: color var(--t-fast), background-color var(--t-fast);
}

.lang-tab:hover {
  color: var(--ink);
}

.lang-tab.active {
  color: var(--accent-ink);
  background: var(--accent);
}

.lang-tab::after {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ok);
}

.lang-tab.empty::after {
  background: var(--warn);
}

.lang-tab.active::after {
  background: currentColor;
  opacity: 0.55;
}

.loc-all {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.loc-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: start;
  gap: 0.45rem;
}

.loc-row-code {
  padding-top: 0.6rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

/* ==========================================================================
   08. TOGGLE / SEGMENTED / CHIPS
   ========================================================================== */

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.toggle-track {
  position: relative;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-full);
  transition: background-color var(--t-fast), border-color var(--t-fast);
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--ink-3);
  border-radius: 50%;
  transition: transform var(--t-fast), background-color var(--t-fast);
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle input:checked + .toggle-track::after {
  background: var(--accent-ink);
  transform: translateX(16px);
}

.toggle input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toggle input:disabled + .toggle-track {
  opacity: 0.5;
}

.toggle-text {
  font-size: 0.88rem;
  color: var(--ink);
}

.toggle-hint {
  display: block;
  font-size: 0.76rem;
  color: var(--ink-3);
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  background: var(--inset);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
}

.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-3);
  border-radius: 6px;
  transition: color var(--t-fast), background-color var(--t-fast);
}

.segmented button:hover {
  color: var(--ink);
}

.segmented button[aria-pressed="true"] {
  color: var(--accent-ink);
  background: var(--accent);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  color: var(--ink-2);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
}

.chip.accent {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.chip.ok {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: color-mix(in srgb, var(--ok) 35%, transparent);
}

.chip.warn {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
}

.chip.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem;
  background: var(--inset);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
}

.tags:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.2rem 0.15rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink);
  background: var(--panel-3);
  border-radius: var(--r-xs);
}

.tag button {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: var(--ink-3);
  border-radius: 4px;
}

.tag button:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.tags-input {
  flex: 1;
  min-width: 120px;
  padding: 0.2rem 0.3rem;
  font-size: 0.86rem;
  background: transparent;
  border: 0;
  outline: none;
}

.icon-btn-pick {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 38px;
  padding: 0 0.7rem;
  font-size: 0.85rem;
  color: var(--ink-2);
  background: var(--inset);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
}

.icon-btn-pick:hover {
  border-color: var(--ink-4);
}

.icon-btn-pick .ico {
  color: var(--accent);
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 0.35rem;
}

.icon-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  color: var(--ink-2);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  transition: color var(--t-fast), border-color var(--t-fast), background-color var(--t-fast);
}

.icon-cell:hover {
  color: var(--accent);
  border-color: var(--accent-line);
}

.icon-cell[aria-pressed="true"] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.swatch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem 0.4rem 0.45rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--inset);
  border: 1px solid var(--line-2);
  border-radius: var(--r-full);
}

.swatch-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18);
}

.swatch[aria-pressed="true"] {
  color: var(--ink);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ==========================================================================
   09. REPEATER
   ========================================================================== */

.rep {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rep-item {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.rep-item.open {
  border-color: var(--line-2);
}

.rep-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.45rem 0.4rem 0.3rem;
}

.rep-toggle {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  padding: 0.3rem 0.4rem;
  text-align: left;
  border-radius: var(--r-xs);
}

.rep-toggle:hover {
  background: var(--panel-3);
}

.rep-caret {
  width: 14px;
  height: 14px;
  color: var(--ink-3);
  transition: transform var(--t-fast);
}

.rep-item.open .rep-caret {
  transform: rotate(90deg);
}

.rep-index {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
}

.rep-title {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rep-title.is-empty {
  font-weight: 500;
  font-style: italic;
  color: var(--ink-4);
}

.rep-actions {
  display: flex;
  align-items: center;
  gap: 1px;
}

.rep-actions .btn-icon {
  width: 28px;
  height: 28px;
  color: var(--ink-3);
  background: transparent;
  border-color: transparent;
}

.rep-actions .btn-icon:hover:not(:disabled) {
  color: var(--ink);
  background: var(--panel-3);
}

.rep-actions .btn-icon.del:hover:not(:disabled) {
  color: var(--danger);
  background: var(--danger-soft);
}

.rep-actions .ico {
  width: 15px;
  height: 15px;
}

.rep-body {
  padding: 0.35rem 0.9rem 0.95rem;
  border-top: 1px solid var(--line);
}

.rep-body > .stack {
  padding-top: 0.6rem;
}

.rep-add {
  align-self: flex-start;
}

.rep-empty {
  padding: 0.9rem;
  font-size: 0.85rem;
  text-align: center;
  color: var(--ink-3);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
}

/* Compact single-line repeater rows (e.g. bullet lists) */
.rep-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.35rem;
}

/* ==========================================================================
   10. SAVE BAR
   ========================================================================== */

.savebar {
  position: fixed;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  z-index: 35;
  display: flex;
  justify-content: center;
  padding: 0 1rem 1rem;
  pointer-events: none;
  transform: translateY(120%);
  transition: transform 260ms var(--ease);
}

.savebar.show {
  transform: translateY(0);
}

.savebar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  width: min(760px, 100%);
  padding: 0.6rem 0.65rem 0.6rem 1rem;
  background: var(--panel-3);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  pointer-events: auto;
}

.savebar-text {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.55rem;
  min-width: 160px;
  font-size: 0.88rem;
  font-weight: 600;
}

.savebar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 10px var(--warn);
}

/* ==========================================================================
   11. LISTS & TABLES
   ========================================================================== */

.list {
  display: flex;
  flex-direction: column;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 1.15rem;
  border-bottom: 1px solid var(--line);
  transition: background-color var(--t-fast);
}

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

.list-row.clickable {
  cursor: pointer;
}

.list-row.clickable:hover {
  background: var(--panel-2);
}

.list-row.unread {
  background: var(--accent-soft);
}

.list-thumb {
  display: grid;
  place-items: center;
  width: 54px;
  height: 40px;
  flex-shrink: 0;
  color: var(--ink-4);
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  overflow: hidden;
}

.list-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-main {
  flex: 1;
  min-width: 0;
}

.list-title {
  font-size: 0.92rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-sub {
  margin-top: 0.1rem;
  font-size: 0.8rem;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-meta {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.4rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.table th {
  padding: 0.6rem 0.8rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-align: left;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 0.6rem 0.8rem;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.table tr:last-child td {
  border-bottom: 0;
}

.tabs {
  display: flex;
  gap: 0.2rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  position: relative;
  padding: 0.6rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--ink-3);
}

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

.tab[aria-selected="true"] {
  color: var(--accent);
}

.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: auto 0.5rem -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

/* ==========================================================================
   12. DIALOGS
   ========================================================================== */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(3, 5, 9, 0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fadeIn 140ms var(--ease);
}

.dialog {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  max-height: calc(100dvh - 2rem);
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
}

.dialog.md {
  max-width: 680px;
}

.dialog.lg {
  max-width: 920px;
}

.dialog.xl {
  max-width: 1120px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1.15rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.dialog-title {
  font-size: 1.02rem;
  font-weight: 650;
}

.dialog-body {
  flex: 1;
  min-height: 0;
  padding: 1.15rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dialog-body p {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink-2);
}

.dialog-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.85rem 1.15rem;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

/* ==========================================================================
   13. TOASTS
   ========================================================================== */

.toasts {
  position: fixed;
  top: 0.9rem;
  right: 0.9rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(380px, calc(100vw - 1.8rem));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--ink);
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  pointer-events: auto;
  animation: fadeIn 180ms var(--ease);
}

.toast.ok {
  border-left-color: var(--ok);
}

.toast.ok .ico {
  color: var(--ok);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.error .ico {
  color: var(--danger);
}

.toast.warn {
  border-left-color: var(--warn);
}

.toast.warn .ico {
  color: var(--warn);
}

.toast .ico {
  margin-top: 1px;
  color: var(--accent);
}

.toast-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast.leaving {
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}

/* ==========================================================================
   14. MEDIA
   ========================================================================== */

.image-field {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.image-preview {
  display: grid;
  place-items: center;
  width: 132px;
  height: 92px;
  color: var(--ink-4);
  background:
    linear-gradient(45deg, var(--panel-3) 25%, transparent 25%, transparent 75%, var(--panel-3) 75%) 0 0 / 14px 14px,
    linear-gradient(45deg, var(--panel-3) 25%, transparent 25%, transparent 75%, var(--panel-3) 75%) 7px 7px / 14px 14px,
    var(--inset);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}

.media-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  text-align: left;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

button.media-card:hover,
.media-card.selectable:hover {
  border-color: var(--accent-line);
}

.media-card[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.media-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background: var(--inset);
  overflow: hidden;
}

.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-info {
  padding: 0.5rem 0.6rem;
}

.media-name {
  font-size: 0.8rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-meta {
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--ink-3);
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 1.6rem 1rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--ink-3);
  background: var(--inset);
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-md);
  transition: border-color var(--t-fast), background-color var(--t-fast);
}

.dropzone.over {
  color: var(--ink);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.dropzone .ico {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

/* ==========================================================================
   15. MARKDOWN PREVIEW
   ========================================================================== */

.md {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--ink-2);
}

.md > * + * {
  margin-top: 0.75rem;
}

.md h3 {
  font-size: 1.1rem;
  color: var(--ink);
}

.md h4 {
  font-size: 0.98rem;
  color: var(--ink);
}

.md strong {
  font-weight: 650;
  color: var(--ink);
}

.md a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.md ul,
.md ol {
  padding-left: 1.25rem;
}

.md ul {
  list-style: disc;
}

.md ol {
  list-style: decimal;
}

.md blockquote {
  padding: 0.5rem 0.9rem;
  border-left: 3px solid var(--accent-line);
  background: var(--panel-2);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.md code {
  padding: 0.1rem 0.35rem;
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--panel-3);
  border-radius: 4px;
}

.md-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.75rem;
}

.md-pane {
  min-height: 160px;
  max-height: 460px;
  padding: 0.7rem 0.85rem;
  overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

.md-help {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-4);
}

/* ==========================================================================
   16. AUTH / BOOT SCREENS
   ========================================================================== */

.center-screen {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 1.5rem;
  overflow: hidden;
}

.center-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, #000 20%, transparent 100%);
  mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, #000 20%, transparent 100%);
  opacity: 0.6;
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 2rem 1.75rem 1.6rem;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  box-shadow: var(--shadow-3);
  animation: fadeIn 260ms var(--ease);
}

.auth-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 1rem;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 14px;
}

.auth-mark .ico {
  width: 26px;
  height: 26px;
}

.auth-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-sub {
  margin-top: 0.4rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-3);
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.4rem;
}

.auth-foot {
  margin-top: 1.25rem;
  font-size: 0.76rem;
  color: var(--ink-4);
}

.auth-foot a {
  color: var(--ink-3);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.google-g {
  width: 18px;
  height: 18px;
}

.boot-text {
  margin-top: 0.9rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ==========================================================================
   17. DASHBOARD
   ========================================================================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1rem 1.05rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  transition: border-color var(--t-fast), transform var(--t-fast);
}

a.stat-card:hover {
  border-color: var(--accent-line);
  transform: translateY(-1px);
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.stat-top .ico {
  color: var(--accent);
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-note {
  font-size: 0.78rem;
  color: var(--ink-3);
}

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.dash-grid > .card + .card {
  margin-top: 0;
}

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

.quick {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: color var(--t-fast), border-color var(--t-fast);
}

.quick:hover {
  color: var(--ink);
  border-color: var(--accent-line);
}

.quick .ico {
  color: var(--accent);
}

.timeline {
  display: flex;
  flex-direction: column;
}

.timeline-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.65rem 1.15rem;
  border-bottom: 1px solid var(--line);
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-dot {
  width: 8px;
  height: 8px;
  margin-top: 0.42rem;
  border-radius: 50%;
  background: var(--accent);
}

.timeline-text {
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.timeline-meta {
  margin-top: 0.1rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-3);
}

/* ==========================================================================
   18. UTILITIES
   ========================================================================== */

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: 1 / -1; }
.text-sm { font-size: 0.84rem; }
.text-xs { font-size: 0.76rem; }
.text-accent { color: var(--accent); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-danger { color: var(--danger); }

/* ==========================================================================
   19. RESPONSIVE
   ========================================================================== */

@media (max-width: 1280px) {
  .stage.has-preview {
    grid-template-columns: minmax(0, 1fr);
  }

  .stage.has-preview .preview {
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    z-index: 45;
    height: auto;
    border-left: 0;
  }
}

@media (max-width: 1100px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dash-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 960px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 300px);
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform 260ms var(--ease), visibility 260ms var(--ease);
    box-shadow: var(--shadow-3);
  }

  .shell.nav-open .sidebar {
    transform: translateX(0);
    visibility: visible;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 39;
    display: block;
    background: rgba(3, 5, 9, 0.6);
    opacity: 0;
    visibility: hidden;
    transition: opacity 220ms var(--ease), visibility 220ms var(--ease);
  }

  .shell.nav-open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
  }

  .topbar-menu {
    display: inline-flex;
  }

  .savebar {
    left: 0;
  }

  .user-email,
  .sync-chip span {
    display: none;
  }
}

@media (max-width: 720px) {
  .page {
    padding: 1.1rem 0.9rem 6.5rem;
  }

  .topbar {
    padding: 0 0.8rem;
    gap: 0.5rem;
  }

  .page-title {
    font-size: 1.3rem;
  }

  .grid-2,
  .grid-3,
  .md-editor,
  .quick-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .col-span-2 {
    grid-column: auto;
  }

  .card-body {
    padding: 0.95rem;
  }

  .card-head,
  .list-row {
    padding-inline: 0.95rem;
  }

  .image-field {
    grid-template-columns: minmax(0, 1fr);
  }

  .list-row {
    flex-wrap: wrap;
  }

  .list-meta {
    width: 100%;
    justify-content: flex-end;
  }

  .hide-sm {
    display: none !important;
  }
}

@media (max-width: 460px) {
  .stat-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .savebar-inner {
    padding: 0.6rem;
  }

  .savebar-text {
    min-width: 100%;
  }

  .savebar-inner .btn {
    flex: 1;
  }
}

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

.boot-spinner {
  display: inline-block;
}

.lang-hint {
  margin-left: auto;
}

.topbar-title {
  min-width: 140px;
}

@media (max-width: 1180px) {
  .topbar-actions > .hide-sm:first-child {
    display: none;
  }
}

.field-top {
  flex-wrap: wrap;
}

/* Touch devices: comfortable hit areas for small icon buttons (WCAG 2.5.8). */
@media (pointer: coarse) {
  .btn-sm,
  .btn-icon.btn-sm,
  .rep-actions .btn,
  .segmented button,
  .lang-tab,
  .tag button {
    min-height: 40px;
    min-width: 40px;
  }
  .lang-tab { padding-inline: 0.7rem; }
}

/* ---------------------------------------------------------- login form */
.auth-or {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.1rem 0;
  color: var(--ink-3);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.auth-or::before,
.auth-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-2);
}
.login-form {
  display: grid;
  gap: 0.85rem;
  text-align: left;
}
.login-form .field-error { margin: 0; }
.pass-wrap { position: relative; }
.pass-wrap .input { padding-right: 2.75rem; }
.pass-toggle {
  position: absolute;
  top: 50%;
  right: 0.3rem;
  transform: translateY(-50%);
}
.theme-toggle { flex: none; }

/* Keep the last fields reachable above the floating publish bar. */
.has-savebar .page-inner { padding-bottom: calc(6.5rem + env(safe-area-inset-bottom, 0px)); }
