/* Beast Organizer — UI */
:root {
  --bg: #0d0f14;
  --bg-2: #12151c;
  --bg-3: #181c26;
  --bg-4: #1f2431;
  --fg: #e9ecf3;
  --fg-2: #a3abbd;
  --fg-3: #6b7387;
  --border: #242a38;
  --border-2: #2f3647;
  --accent: #8b7cff;
  --accent-2: #5fd4ff;
  --accent-soft: rgba(139, 124, 255, .14);
  --success: #2fbf7f;
  --warning: #e3a33b;
  --danger: #ef5b5b;
  --info: #5fa8ff;
  --shadow: 0 12px 40px rgba(0,0,0,.45);
  --radius: 14px;
  --radius-sm: 9px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sidebar: 236px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6fa; --bg-2: #ffffff; --bg-3: #f0f2f7; --bg-4: #e7eaf2;
    --fg: #121420; --fg-2: #5b6274; --fg-3: #8a91a3;
    --border: #e3e6ee; --border-2: #d3d8e4;
    --accent: #6a5bf0; --accent-soft: rgba(106, 91, 240, .12);
    --shadow: 0 12px 40px rgba(20, 24, 40, .10);
  }
}
[data-theme="light"] {
  --bg: #f5f6fa; --bg-2: #ffffff; --bg-3: #f0f2f7; --bg-4: #e7eaf2;
  --fg: #121420; --fg-2: #5b6274; --fg-3: #8a91a3;
  --border: #e3e6ee; --border-2: #d3d8e4;
  --accent: #6a5bf0; --accent-soft: rgba(106, 91, 240, .12);
  --shadow: 0 12px 40px rgba(20, 24, 40, .10);
}
[data-theme="dark"] {
  --bg: #0d0f14; --bg-2: #12151c; --bg-3: #181c26; --bg-4: #1f2431;
  --fg: #e9ecf3; --fg-2: #a3abbd; --fg-3: #6b7387;
  --border: #242a38; --border-2: #2f3647;
  --accent: #8b7cff; --accent-soft: rgba(139, 124, 255, .14);
  --shadow: 0 12px 40px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--fg); background: var(--bg);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.015em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; color: var(--fg-2); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--fg-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  background: var(--bg-2); border-right: 1px solid var(--border);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand__mark {
  width: 30px; height: 30px; border-radius: 10px;
  background: conic-gradient(from 200deg, #7a5cff, #4fd1ff, #ff6fb1, #7a5cff);
  box-shadow: 0 6px 18px rgba(122, 92, 255, .35);
  position: relative;
}
.brand__mark::after { content: ""; position: absolute; inset: 7px; border-radius: 6px; background: var(--bg-2); }
.brand__name { font-weight: 750; letter-spacing: -.02em; font-size: 15px; }
.brand__sub { font-size: 11px; color: var(--fg-3); margin-top: -2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
  color: var(--fg-2); font-weight: 530; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--bg-3); color: var(--fg); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--fg); }
.nav a svg { width: 18px; height: 18px; opacity: .8; }
.nav .badge { margin-left: auto; }
.nav__section { font-size: 11px; color: var(--fg-3); text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px 4px; }
.sidebar__foot { margin-top: auto; padding: 10px 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--fg-3); font-size: 12px; }

.main { min-width: 0; padding: 26px 32px 60px; max-width: 1360px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--fg-2); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Components ---------- */
.card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px;
}
.card + .card { margin-top: 16px; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--side { grid-template-columns: minmax(0, 1fr) 340px; }
.stack { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-content: start; }
.stack > *, .grid > * { min-width: 0; }

.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.stat__label { font-size: 12px; color: var(--fg-2); font-weight: 550; }
.stat__value { font-size: 26px; font-weight: 750; letter-spacing: -.03em; line-height: 1.1; }
.stat__hint { font-size: 12px; color: var(--fg-3); }
.stat--accent::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: linear-gradient(var(--accent), var(--accent-2)); }
.stat--warn .stat__value { color: var(--warning); }
.stat--danger .stat__value { color: var(--danger); }
.stat--ok .stat__value { color: var(--success); }
a.stat { color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--border-2); }

.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 8px 14px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; cursor: pointer;
  transition: filter .15s, transform .08s, background .15s; text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--ghost { background: transparent; color: var(--fg); border-color: var(--border-2); }
.btn--ghost:hover { background: var(--bg-3); filter: none; }
.btn--soft { background: var(--accent-soft); color: var(--accent); }
.btn--danger { background: var(--danger); }
.btn--success { background: var(--success); }
.btn--sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn--xs { padding: 3px 8px; font-size: 11.5px; border-radius: 6px; }
.btn[disabled], .btn.is-loading { opacity: .55; pointer-events: none; }
.btn svg { width: 15px; height: 15px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; background: var(--bg-4); color: var(--fg-2); line-height: 1.5;
}
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge--ok { background: rgba(47,191,127,.15); color: var(--success); }
.badge--warn { background: rgba(227,163,59,.16); color: var(--warning); }
.badge--danger { background: rgba(239,91,91,.16); color: var(--danger); }
.badge--info { background: rgba(95,168,255,.16); color: var(--info); }

.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  background: var(--bg-3); border: 1px solid var(--border); color: var(--fg-2); font-size: 12px; font-weight: 520;
}
a.tag:hover { border-color: var(--accent); color: var(--fg); text-decoration: none; }
.tag--new { border-style: dashed; color: var(--accent); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.flash { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid; font-weight: 520; display: flex; gap: 10px; align-items: flex-start; }
.flash--success { background: rgba(47,191,127,.1); border-color: rgba(47,191,127,.35); }
.flash--error { background: rgba(239,91,91,.1); border-color: rgba(239,91,91,.35); }
.flash--info { background: var(--accent-soft); border-color: rgba(139,124,255,.4); }

/* Forms */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label, .field > span { font-size: 12.5px; font-weight: 600; color: var(--fg-2); }
.field .help { font-size: 12px; color: var(--fg-3); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row--3 { grid-template-columns: 1fr 1fr 1fr; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--border-2); background: var(--bg-3); color: var(--fg);
  border-radius: var(--radius-sm); padding: 9px 11px; font: inherit; font-size: 13.5px; outline: 0;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=file] { font-size: 13px; color: var(--fg-2); }
textarea { resize: vertical; min-height: 90px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.form__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline-form { display: inline; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-3); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--bg-3); }
td.actions { white-space: nowrap; text-align: right; }

/* Toolbar / filters */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar select, .toolbar input { width: auto; }
.toolbar form { flex-wrap: nowrap; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-2);
  color: var(--fg-2); font-size: 12.5px; font-weight: 550; cursor: pointer; text-decoration: none;
}
.pill:hover { border-color: var(--border-2); color: var(--fg); text-decoration: none; }
.pill.active { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.pill .n { opacity: .7; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* Notes list */
.note-row__title { font-weight: 600; color: var(--fg); }
.note-row__title.is-untitled { color: var(--fg-3); font-style: italic; font-weight: 500; }
.note-row__preview { color: var(--fg-3); font-size: 12.5px; margin-top: 2px; max-width: 640px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Proposal rows */
.prop { display: grid; grid-template-columns: 28px 120px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 14px 4px; border-bottom: 1px solid var(--border); }
.prop:last-child { border-bottom: 0; }
.prop__kind { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding-top: 3px; }
.prop__kind--rename { color: var(--info); } .prop__kind--add_tag, .prop__kind--remove_tag { color: var(--accent); }
.prop__kind--archive, .prop__kind--unarchive { color: var(--warning); } .prop__kind--trash { color: var(--danger); } .prop__kind--pin { color: var(--success); }
.prop__note { font-weight: 600; }
.prop__change { margin-top: 3px; font-size: 13.5px; }
.prop__change .from { color: var(--fg-3); text-decoration: line-through; margin-right: 6px; }
.prop__change .to { color: var(--fg); font-weight: 600; }
.prop__reason { color: var(--fg-3); font-size: 12.5px; margin-top: 4px; }
.prop__meta { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.conf { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--fg-3); font-variant-numeric: tabular-nums; }
.conf i { display: inline-block; width: 46px; height: 5px; border-radius: 3px; background: var(--bg-4); position: relative; overflow: hidden; }
.conf i::after { content: ""; position: absolute; inset: 0; width: var(--w, 50%); background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.bulkbar { position: sticky; bottom: 14px; display: none; gap: 10px; align-items: center; background: var(--bg-4); border: 1px solid var(--border-2); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); margin-top: 14px; }
.bulkbar.show { display: flex; }

/* Note page */
.note-view { white-space: pre-wrap; font-size: 14.5px; line-height: 1.7; max-height: 70vh; overflow: auto; padding: 4px 2px; font-family: var(--font); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--fg-3); } .kv dd { margin: 0; }

/* Progress */
.progress { height: 8px; background: var(--bg-4); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s; }

/* Mini chart */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 70px; }
.bars span { flex: 1; background: var(--accent-soft); border-radius: 3px 3px 0 0; position: relative; min-height: 2px; }
.bars span::after { content: attr(data-l); position: absolute; top: 100%; left: 0; right: 0; text-align: center; font-size: 9.5px; color: var(--fg-3); margin-top: 4px; }
.bars span b { position: absolute; inset: auto 0 0 0; height: var(--h); background: linear-gradient(var(--accent), var(--accent-2)); border-radius: 3px 3px 0 0; }

/* Empty state */
.empty { text-align: center; padding: 40px 20px; color: var(--fg-3); }
.empty h2 { color: var(--fg); margin-bottom: 6px; }

/* Auth */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, rgba(122,92,255,.18), transparent), radial-gradient(900px 500px at 110% 110%, rgba(79,209,255,.12), transparent), var(--bg); }
.auth__card { width: min(420px, 100%); }
.auth__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }

/* Activity */
.log { font-size: 13px; }
.log .lvl { font-size: 10.5px; font-weight: 700; text-transform: uppercase; }
.log .lvl--info { color: var(--info); } .log .lvl--warn { color: var(--warning); } .log .lvl--error { color: var(--danger); }

.theme-toggle { border: 1px solid var(--border); background: transparent; color: var(--fg-2); border-radius: 8px; padding: 4px 8px; cursor: pointer; font-size: 12px; }

/* Responsive */
@media (max-width: 1100px) { .grid--4 { grid-template-columns: repeat(2, 1fr); } .grid--3 { grid-template-columns: repeat(2, 1fr); } .grid--side { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 4px 8px; width: 100%; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a { padding: 6px 9px; font-size: 13px; }
  .nav a svg { display: none; }
  .nav__section, .sidebar__foot { display: none; }
  .main { padding: 18px 16px 40px; }
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .row, .row--3 { grid-template-columns: 1fr; }
  .prop { grid-template-columns: 24px 1fr; }
  .prop__kind { grid-column: 2; }
  .prop__meta { grid-column: 1 / -1; justify-content: flex-start; }
}

.copyline { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; padding: 8px 10px; border: 1px dashed var(--border-2); border-radius: var(--radius-sm); background: var(--bg-3); }
.copyline code { flex: 1; word-break: break-all; }

/* Folder icons */
.fi { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 8px; background: var(--bg-3); border: 1px solid var(--border); font-size: 17px; line-height: 1; }
.fi--sn { font-size: 11px; font-family: var(--mono); color: var(--fg-2); }
.fi--preview:empty { display: none; }
.icon-input { display: flex; gap: 8px; align-items: center; }
.icon-input input { font-size: 15px; }
table.folders tr.has-suggestion td { background: color-mix(in srgb, var(--accent) 5%, transparent); }

/* Titles page */
.trow { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; padding: 14px 4px; border-bottom: 1px solid var(--border); }
.trow:last-child { border-bottom: 0; }
.trow.has-suggestion { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.trow__current { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.trow__current a { font-weight: 600; color: var(--fg); }
.trow__current a.is-untitled { color: var(--fg-3); font-style: italic; font-weight: 500; }
.trow__preview { color: var(--fg-3); font-size: 12.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow__new { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.trow__new .arrow { color: var(--accent); font-weight: 700; }
.trow__new input { flex: 1; font-size: 14.5px; font-weight: 600; }
.trow__alts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0 22px; }
.trow__alts .alt { border: 1px dashed var(--border-2); background: transparent; color: var(--fg-2); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; }
.trow__alts .alt:hover { border-color: var(--accent); color: var(--fg); }
