@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

html {
  /* ── Light Pastel ── */
  --brand-400: #5eead4;
  --brand-500: #2dd4bf;
  --brand-600: #14b8a6;
  --brand-700: #0d9488;

  --bg-base:    #f6f8fb;
  --bg-sidebar: #ffffff;
  --bg-surface: #ffffff;
  --bg-input:   #eef2f7;
  --bg-hover:   #e6edf5;

  --text-main:    #0f172a;
  --text-body:    #334155;
  --text-muted:   #64748b;
  --text-dim:     #94a3b8;

  --border:        rgba(15,23,42,0.08);
  --border-strong: rgba(15,23,42,0.14);
  --border-active: rgba(20,184,166,0.45);

  --green:  #10b981;
  --amber:  #f59e0b;
  --red:    #f43f5e;

  --sidebar-w: 260px;
  --header-h:  58px;
  --radius:    10px;
  --radius-lg: 12px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-theme="dark"] {
  /* ── Dark Pastel ── */
  --brand-400: #5eead4;
  --brand-500: #2dd4bf;
  --brand-600: #14b8a6;
  --brand-700: #0d9488;

  --bg-base:    #0b121f;
  --bg-sidebar: #0f172a;
  --bg-surface: #162032;
  --bg-input:   #0e1525;
  --bg-hover:   #1e293b;

  --text-main:    #e2e8f0;
  --text-body:    #94a3b8;
  --text-muted:   #64748b;
  --text-dim:     #475569;

  --border:        rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.14);
  --border-active: rgba(94,234,212,0.5);

  --green:  #6ee7b7;
  --amber:  #fcd34d;
  --red:    #fda4af;
}

/* Smooth theme switching */
html, body, aside, main, header, .mobile-header, .card, .cmd-block, .input-field, .btn, .nav-item,
.editor-sidebar, .editor-main, .editor-topbar, .modal, .snippet-card, .page-list-item,
.stat-card, .login-card, .cat-column, .cat-page-item {
  transition: background-color .35s ease, border-color .35s ease, color .25s ease, box-shadow .35s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  background-color: var(--bg-base);
  color: var(--text-body);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  height: 100vh;
  overflow: hidden;
  display: flex;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color-scheme: light dark;
}
body.editor-body { flex-direction: column; }

/* FIX: standalone pages (categories, etc.) use normal block flow */
body.page-standalone {
  display: block;
  height: auto;
  overflow-x: hidden;
}

::selection { background: var(--brand-600); color: #fff; }
:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

* { scrollbar-width: thin; scrollbar-color: var(--text-dim) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 10px; opacity: .5; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

h1, h2 { text-wrap: balance; }

/* ── Login ── */
#login-view { position: fixed; inset: 0; z-index: 100; background: var(--bg-base); display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--bg-surface); border: 1px solid var(--border-strong); padding: 2.5rem; border-radius: var(--radius-lg); width: 100%; max-width: 400px; margin: 1rem; text-align: center; }
.login-card h2 { font-size: 1.5rem; font-weight: 700; color: var(--text-main); margin-bottom: 0.25rem; }
.login-card p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

.input-field {
  width: 100%; padding: 0.75rem 1rem; border-radius: var(--radius);
  background: var(--bg-input); border: 1px solid var(--border-strong);
  color: var(--text-main); margin-bottom: 1rem; outline: none;
  font-family: inherit; font-size: 0.9375rem;
  transition: border-color .2s, box-shadow .2s;
}
.input-field:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 20%, transparent); }
.input-field option { background: var(--bg-input); color: var(--text-main); }
textarea::placeholder { color: var(--text-dim); opacity: .8; }

.btn-brand { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; background: var(--brand-600); color: #fff; padding: .7rem 1.25rem; border-radius: var(--radius); border: none; cursor: pointer; width: 100%; font-weight: 600; font-family: inherit; font-size: .9375rem; transition: all .15s; }
.btn-brand:hover { background: var(--brand-700); }
.btn-brand:active { transform: translateY(1px); }

/* ── Mobile Header ── */
.mobile-header { display: none; height: var(--header-h); background: var(--bg-surface); border-bottom: 1px solid var(--border-strong); align-items: center; justify-content: space-between; padding: 0 1rem; position: sticky; top: 0; z-index: 50; }
.menu-toggle { background: transparent; border: 1px solid var(--border-strong); color: var(--text-main); width: 36px; height: 36px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1.1rem; }
.menu-toggle:hover { background: var(--bg-hover); border-color: var(--border-active); }

.mobile-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 90; backdrop-filter: blur(2px); }
.mobile-overlay.active { display: block; }

/* ── Sidebar ── */
aside { width: var(--sidebar-w); min-width: var(--sidebar-w); background: var(--bg-sidebar); border-right: 1px solid var(--border-strong); display: flex; flex-direction: column; overflow: hidden; }
.sidebar-header { height: var(--header-h); display: flex; align-items: center; padding: 0 1.25rem; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 1.05rem; color: var(--text-main); gap: .5rem; flex-shrink: 0; }
.nav-list { flex: 1; overflow-y: auto; padding: 1rem .625rem; display: flex; flex-direction: column; }
.nav-section-label { font-size: .6875rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1.5px; margin: 1.25rem 0 .5rem; padding-left: .75rem; font-weight: 600; }
.nav-section-label:first-child { margin-top: 0; }
.nav-item { display: flex; align-items: center; padding: .55rem .75rem; border-radius: var(--radius); color: var(--text-muted); text-decoration: none; margin-bottom: 2px; transition: all .12s; font-size: .9rem; font-weight: 500; gap: .6rem; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-body); }
.nav-item.active { background: var(--brand-600); color: #fff; font-weight: 600; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08); }

.nav-category { margin-bottom: .25rem; }
.nav-category-header { display: flex; align-items: center; gap: .5rem; padding: .4rem .75rem; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); margin-top: .5rem; user-select: none; }
.nav-item.sub-item { padding-left: 2.2rem; position: relative; }
.nav-item.sub-item::before { content: ""; position: absolute; left: 1.1rem; top: 50%; transform: translateY(-50%); width: 4px; height: 4px; border-radius: 50%; background: var(--text-dim); opacity: .6; }
.nav-item.sub-item.active::before { background: rgba(255,255,255,0.6); opacity: 1; }

/* ── Main ── */
main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; background: var(--bg-base); }
header.desktop-bar { height: var(--header-h); background: var(--bg-surface); border-bottom: 1px solid var(--border-strong); display: flex; align-items: center; justify-content: space-between; padding: 0 2rem; flex-shrink: 0; }
.content-area { flex: 1; overflow-y: auto; padding: 2rem; }
.page-container { max-width: 860px; margin: 0 auto; animation: fadeIn .35s var(--ease-out); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── Docs content ── */
h1 { font-size: 1.875rem; font-weight: 700; margin-bottom: .5rem; color: var(--text-main); letter-spacing: -.02em; line-height: 1.2; }
h2 { font-size: 1.375rem; font-weight: 600; margin-bottom: .75rem; color: var(--text-main); line-height: 1.3; }
h3 { font-size: 1.1rem; font-weight: 600; margin-top: 2rem; margin-bottom: .75rem; color: var(--brand-700); display: flex; align-items: center; gap: .5rem; }
.doc-desc { color: var(--text-body); font-size: 1rem; margin-bottom: 1.25rem; line-height: 1.65; }

.cmd-block { background: var(--bg-input); padding: .85rem 1rem; border-radius: var(--radius); border: 1px solid var(--border-strong); border-left: 3px solid var(--brand-500); font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace; margin: .75rem 0 1.25rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; overflow-x: auto; }
.cmd-text { color: var(--text-body); font-size: .8125rem; white-space: nowrap; line-height: 1.5; }
.btn-copy { background: transparent; color: var(--text-dim); border: 1px solid var(--border); padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: .6875rem; font-family: inherit; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; transition: all .12s; white-space: nowrap; flex-shrink: 0; }
.btn-copy:hover { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }
.btn-copy.copied { background: var(--green); color: #000; border-color: var(--green); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin: 1.5rem 0 2rem; }
.stat-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1rem; text-align: center; }
.stat-label { font-size: .6875rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin-bottom: .35rem; font-weight: 600; }
.stat-value { font-size: 1.15rem; font-weight: 700; color: var(--text-main); }

/* ── Alerts ── */
.alert-warning, .alert-info, .alert-error, .alert-success {
  border-radius: var(--radius); padding: .85rem 1rem; margin: 1rem 0; font-size: .92rem; font-weight: 500; border: 1px solid transparent; border-left-width: 3px;
}
.alert-warning { background: color-mix(in srgb, var(--amber) 8%, transparent); border-color: color-mix(in srgb, var(--amber) 22%, transparent); border-left-color: var(--amber); color: var(--amber); }
.alert-info    { background: color-mix(in srgb, var(--brand-500) 8%, transparent); border-color: color-mix(in srgb, var(--brand-500) 22%, transparent); border-left-color: var(--brand-500); color: var(--brand-700); }
.alert-error   { background: color-mix(in srgb, var(--red) 8%, transparent); border-color: color-mix(in srgb, var(--red) 22%, transparent); border-left-color: var(--red); color: var(--red); }
.alert-success { background: color-mix(in srgb, var(--green) 8%, transparent); border-color: color-mix(in srgb, var(--green) 22%, transparent); border-left-color: var(--green); color: var(--green); }
.alert-flat { margin: 0; border-radius: 0; border-left: none; border-right: none; }

.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; margin-top: 1.5rem; }
.card h3 { margin-top: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .45rem .9rem; border-radius: var(--radius); border: none; cursor: pointer; font-family: inherit; font-size: .8125rem; font-weight: 600; text-decoration: none; transition: all .12s; white-space: nowrap; }
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); }
.btn-secondary { background: transparent; color: var(--text-muted); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-body); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 30%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--red) 10%, transparent); }
.btn-success { background: transparent; color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 30%, transparent); }
.btn-success:hover { background: color-mix(in srgb, var(--green) 10%, transparent); }
.btn-sm { padding: .3rem .6rem; font-size: .75rem; }

.page-list { display: flex; flex-direction: column; gap: .35rem; }
.page-list-item { display: flex; align-items: center; justify-content: space-between; padding: .6rem .875rem; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); }
.page-list-item .page-name { color: var(--text-main); font-size: .9rem; font-weight: 500; text-decoration: none; }
.page-list-item .page-actions { display: flex; gap: .35rem; }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border-strong); margin-bottom: 1.5rem; }
.tab { padding: .6rem 1.25rem; color: var(--text-muted); cursor: pointer; font-size: .9rem; font-weight: 500; border-bottom: 2px solid transparent; transition: all .12s; text-decoration: none; font-family: inherit; background: none; border-top: none; border-left: none; border-right: none; margin-bottom: -1px; }
.tab:hover { color: var(--text-body); background: var(--bg-hover); }
.tab.active { color: var(--brand-700); border-bottom-color: var(--brand-500); font-weight: 600; }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.active { display: flex; }
.modal { background: var(--bg-surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); padding: 1.5rem; width: 100%; max-width: 440px; }
.modal h3 { margin-top: 0; }

/* ── Editor Layout ── */
.editor-layout { display: flex; flex: 1; overflow: hidden; }
.editor-topbar { display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; height: 56px; border-bottom: 1px solid var(--border); background: var(--bg-surface); flex-shrink: 0; }
.editor-topbar h1 { font-size: 1rem; font-weight: 700; margin: 0; display: flex; align-items: center; gap: .5rem; }
.editor-sidebar { width: 260px; min-width: 260px; background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.editor-sidebar-header { padding: 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.editor-sidebar-list { flex: 1; overflow-y: auto; padding: .5rem; }
.editor-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.editor-form-wrapper { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.editor-toolbar { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.5rem; border-bottom: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; }
.editor-workspace { display: flex; flex: 1; overflow: hidden; }
.editor-form-area { flex: 1; overflow-y: auto; }
.editor-textarea { width: 100%; height: 100%; min-height: 100%; border: none; border-radius: 0; background: var(--bg-input); color: var(--text-body); padding: 1rem; font-family: 'JetBrains Mono', monospace; font-size: 13px; resize: none; outline: none; line-height: 1.6; tab-size: 4; }
.editor-textarea:focus { border-color: var(--brand-500); }

.snippets-panel { display: none; background: var(--bg-sidebar); border-left: 1px solid var(--border); width: 320px; min-width: 320px; overflow-y: auto; padding: 1rem; }
.snippets-panel.active { display: block; }
.snippet-card { background: var(--bg-base); border: 1px solid var(--border); border-radius: .5rem; padding: .75rem; margin-bottom: .5rem; cursor: pointer; transition: all .15s; }
.snippet-card:hover { border-color: var(--brand-500); background: color-mix(in srgb, var(--brand-500) 5%, transparent); }
.snippet-title { font-size: 13px; font-weight: 600; color: var(--text-main); margin-bottom: .25rem; }
.snippet-desc { font-size: 11px; color: var(--text-dim); line-height: 1.4; }
.snippet-card code { display: block; margin-top: .5rem; font-size: 11px; color: var(--text-muted); background: rgba(0,0,0,0.06); padding: .4rem .5rem; border-radius: 4px; white-space: pre-wrap; font-family: 'JetBrains Mono', monospace; max-height: 80px; overflow: hidden; }
html[data-theme="dark"] .snippet-card code { background: rgba(0,0,0,0.25); }

/* ── Categories (kanban) ── */
.cat-container { max-width: 1200px; margin: 0 auto; padding: 2rem 1rem 4rem; }
.cat-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.cat-header h1 { margin: 0; font-size: 1.4rem; color: var(--text-main); }

.cat-board { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }

.cat-column {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 280px; min-width: 280px;
  max-height: 70vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.cat-column-header {
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.cat-column-header strong { color: var(--text-main); font-size: .95rem; }
.cat-column-header small { color: var(--text-dim); font-size: 11px; margin-left: 6px; }
.cat-column-body {
  flex: 1;
  overflow-y: auto;
  padding: .5rem;
  min-height: 120px;
}
.cat-page-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem .8rem;
  margin-bottom: .4rem;
  cursor: grab;
  display: flex; align-items: center; gap: .5rem;
  font-size: .85rem; color: var(--text-body);
}
.cat-page-item:hover { border-color: var(--brand-500); background: var(--bg-hover); }
.cat-page-item:active { cursor: grabbing; }
.cat-page-item.dragging { opacity: .5; transform: scale(.98); }

.cat-placeholder {
  border: 2px dashed var(--brand-500);
  border-radius: 8px; height: 40px;
  margin-bottom: .4rem;
  background: color-mix(in srgb, var(--brand-500) 5%, transparent);
}

.cat-unassigned { background: color-mix(in srgb, var(--text-dim) 3%, transparent); }

.add-cat-form { display: flex; gap: .5rem; margin-bottom: 1.5rem; }
.add-cat-form input { margin: 0; flex: 1; max-width: 300px; }

.ghost-btn { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 1rem; padding: 2px 4px; }
.ghost-btn:hover { color: var(--red); }

.actions-footer { display: flex; justify-content: center; gap: 1rem; margin-top: 2rem; }
.hint { color: var(--text-dim); font-size: .85rem; text-align: center; margin-bottom: 1rem; }

/* ── Theme toggle helpers ── */
.theme-toggle { font-size: 1.1rem; background: transparent; border: 1px solid var(--border-strong); border-radius: var(--radius); width: 34px; height: 34px; cursor: pointer; color: var(--text-main); display: inline-flex; align-items: center; justify-content: center; }
.theme-toggle:hover { background: var(--bg-hover); border-color: var(--border-active); }

/* ── Responsive ── */
@media (max-width: 768px) {
  body { flex-direction: column; height: auto; overflow-x: hidden; }
  .mobile-header { display: flex; }
  header.desktop-bar { display: none; }

  aside { position: fixed; left: 0; top: 0; bottom: 0; z-index: 100; transform: translateX(-100%); transition: transform .3s var(--ease-out); border-right: none; box-shadow: 10px 0 40px rgba(0,0,0,0.25); display: flex; width: 260px; }
  aside.open { transform: translateX(0); }

  main { height: auto; min-height: 100vh; }
  .content-area { padding: 1.25rem 1rem; }
  h1 { font-size: 1.5rem; }

  .editor-layout { flex-direction: column !important; }
  .editor-sidebar { width: 100%; min-width: auto; height: auto; max-height: 220px; border-right: none; border-bottom: 1px solid var(--border-strong); }
  .snippets-panel { position: fixed; right: 0; top: 0; bottom: 0; width: 280px; z-index: 110; transform: translateX(100%); transition: transform .3s var(--ease-out); }
  .snippets-panel.active { transform: translateX(0); }

  .cat-board { flex-direction: column; align-items: stretch; }
  .cat-column { width: 100%; min-width: auto; max-height: none; }
  .actions-footer { padding-bottom: 2rem; }
}