:root {
  --bg: #000;
  --panel: #0a0a0a;
  --raised: #111;
  --line: #1f1f1f;
  --line-2: #333;
  --text: #fff;
  --muted: #a1a1a1;
  --dim: #666;
  --accent: #b4f23c;
  --accent-soft: rgba(180, 242, 60, 0.12);
  --accent-line: rgba(180, 242, 60, 0.4);
  --accent-ink: #0c1400;
  --danger: #ff5d5d;
  --radius: 10px;
  --side: 272px;
  --rail: 64px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; }

html { color-scheme: dark; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

svg.i { width: 18px; height: 18px; flex: none; }

.app {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 0.25s ease;
}
.app.collapsed { grid-template-columns: var(--rail) minmax(0, 1fr); }

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

.side-head {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 20px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.logo { display: inline-flex; align-items: baseline; white-space: nowrap; }
.logo-word { font-size: 21px; font-weight: 500; letter-spacing: -0.045em; }
.logo-q { font-size: 21px; font-weight: 700; color: var(--accent); letter-spacing: -0.04em; margin-left: 1px; }

.side-nav { flex: 1; overflow-y: auto; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

.sec-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.sec-btn:hover { background: var(--raised); color: var(--text); }
.sec.active > .sec-btn { color: var(--text); }
.sec.active > .sec-btn .i:first-child { color: var(--accent); }
.sec-btn .lbl { flex: 1; }
.sec-btn .chev { display: flex; transition: transform 0.2s; color: var(--dim); }
.sec-btn .chev .i { width: 15px; height: 15px; }
.sec.open > .sec-btn .chev { transform: rotate(90deg); }

.sec-items { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.22s ease; }
.sec.open > .sec-items { grid-template-rows: 1fr; }
.sec-items > div { overflow: hidden; min-height: 0; margin-left: 21px; padding-left: 10px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 1px; }
.sec.open > .sec-items > div { margin-top: 2px; margin-bottom: 8px; }

.item {
  display: block;
  width: 100%;
  padding: 7px 12px;
  border: 0;
  background: none;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.item:hover { background: var(--raised); color: var(--text); }
.item.on { background: var(--raised); color: var(--text); font-weight: 500; box-shadow: inset 2px 0 0 var(--accent); }

.side-foot { flex: none; border-top: 1px solid var(--line); padding: 12px; }
.profile-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; transition: background 0.15s; min-width: 0; }
.profile-chip:hover { background: var(--raised); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; flex: none; }
.avatar.empty { background: var(--raised); color: var(--muted); border: 1px solid var(--line-2); }
.pc-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.pc-text b { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-text span { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app.collapsed .side-head { justify-content: center; padding: 0; }
.app.collapsed .logo,
.app.collapsed .sec-btn .lbl,
.app.collapsed .sec-btn .chev,
.app.collapsed .sec-items,
.app.collapsed .pc-text { display: none; }
.app.collapsed .sec-btn { justify-content: center; padding: 11px 0; }
.app.collapsed .profile-chip { justify-content: center; padding: 6px 0; }
.app.collapsed #collapseBtn .i { transform: scaleX(-1); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex: none;
}
.icon-btn:hover { background: var(--raised); color: var(--text); border-color: var(--line); }
.icon-btn.danger:hover { color: var(--danger); }

.main {
  min-width: 0;
  background: radial-gradient(60% 320px at 50% 0, rgba(180, 242, 60, 0.07), transparent 70%) no-repeat;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }

.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.crumbs a:hover { color: var(--text); }
.crumbs span { overflow: hidden; text-overflow: ellipsis; }
.crumbs span:last-child { color: var(--text); font-weight: 500; }
.crumbs i { font-style: normal; color: var(--dim); }

.top-actions { display: flex; align-items: center; gap: 10px; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 8px 0 12px;
  min-width: 220px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--dim);
  transition: border-color 0.15s, color 0.15s;
}
.search-trigger:hover { border-color: var(--accent-line); color: var(--muted); }
.search-trigger .st-text { flex: 1; text-align: left; font-size: 14px; }
.st-icon { display: flex; }

kbd { font: 500 11px var(--font); color: var(--muted); background: var(--raised); border: 1px solid var(--line-2); border-radius: 5px; padding: 2px 6px; }

.select {
  height: 34px;
  padding: 0 28px 0 12px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a1a1' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  appearance: none;
  font-size: 14px;
  color: var(--text);
}
.select:hover { border-color: #444; }
.select.sm { height: 30px; font-size: 13px; }

.view { padding: 40px 32px 96px; max-width: 1040px; margin: 0 auto; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 260px; }
.page-head h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 600; letter-spacing: -0.04em; line-height: 1.1; }
.page-head h1.h-doc { font-size: clamp(24px, 3.2vw, 32px); font-weight: 600; max-width: 640px; }
.page-head p { color: var(--muted); margin-top: 8px; max-width: 560px; font-weight: 300; font-size: 16px; }
.title-input { width: 100%; background: none; border: 0; border-bottom: 1px solid transparent; font-size: clamp(24px, 3.2vw, 32px); font-weight: 600; letter-spacing: -0.04em; padding: 0 0 4px; }
.title-input:hover { border-bottom-color: var(--line-2); }
.title-input:focus { outline: none; border-bottom-color: var(--accent); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.2s;
}
.btn:hover { background: var(--raised); border-color: #555; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #c6f65f; box-shadow: 0 0 0 4px var(--accent-soft), 0 0 28px rgba(180, 242, 60, 0.28); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #1a0000; font-weight: 600; }
.btn:disabled { opacity: 0.5; cursor: wait; }

.input, .field input, .field textarea, .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: var(--dim); }
.input:hover, .field input:hover, .field textarea:hover { border-color: #555; }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; line-height: 1.5; }

.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar .input { max-width: 300px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  background: none;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  transition: all 0.15s;
}
.chip:hover { color: var(--text); border-color: #555; }
.chip.on { background: var(--text); border-color: var(--text); color: #000; font-weight: 500; }
.chip small { font-size: 12px; opacity: 0.6; }

.group-title { font-size: 13px; font-weight: 500; color: var(--dim); margin: 28px 0 8px; }
.group-title:first-child { margin-top: 0; }

.list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg); }
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--panel); }
.row:hover .row-title { color: var(--accent); }
.row:hover > .i { color: var(--text); transform: translateX(2px); }
.row > .i { color: var(--dim); transition: transform 0.15s, color 0.15s; }
.row-title { flex: 1; font-weight: 500; transition: color 0.15s; min-width: 0; }
.row-meta { font-size: 13px; color: var(--dim); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--line-2); flex: none; }
.dot.on { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 10px rgba(180, 242, 60, 0.5); }

.empty { text-align: center; color: var(--muted); padding: 56px 24px; border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty h3 { color: var(--text); font-weight: 600; font-size: 18px; margin-bottom: 6px; }
.empty .btn { margin-top: 18px; }

.notice { padding: 12px 16px; border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: var(--radius); font-size: 14px; margin-bottom: 20px; }

.search-field { position: relative; margin-bottom: 8px; }
.search-field .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--dim); }
.search-field .input { padding-left: 38px; max-width: none; }
.count { font-size: 13px; color: var(--dim); margin-bottom: 20px; }

.art { padding: 24px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 80px; }
.art.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 60% { background: var(--accent-soft); box-shadow: 0 0 0 12px var(--accent-soft); } 100% { background: transparent; box-shadow: 0 0 0 12px transparent; } }
.art header { display: flex; align-items: baseline; gap: 14px; margin-bottom: 10px; }
.art-n { font-size: 13px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.art h3 { flex: 1; font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.art-actions { opacity: 0; transition: opacity 0.15s; align-self: center; }
.art:hover .art-actions, .art-actions:focus-within { opacity: 1; }
.art-body { color: #d4d4d4; font-weight: 300; font-size: 16px; line-height: 1.7; max-width: 76ch; }
mark { background: var(--accent); color: var(--accent-ink); border-radius: 3px; padding: 0 2px; }
.more { margin: 24px auto 0; display: flex; }

.table { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.trow { display: grid; grid-template-columns: minmax(0, 1fr) 150px 140px 76px; gap: 16px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); transition: background 0.15s; }
.trow:last-child { border-bottom: 0; }
.trow:hover { background: var(--panel); }
.tcell-main { display: flex; flex-direction: column; min-width: 0; }
.tcell-main b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcell-main:hover b { color: var(--accent); }
.tcell-main span { font-size: 13px; color: var(--dim); }
.trow time { font-size: 13px; color: var(--muted); }
.row-actions { display: flex; justify-content: flex-end; }

.badge { display: inline-block; padding: 2px 10px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 12px; color: var(--muted); }
.badge.signed { color: var(--accent); border-color: var(--accent-line); }
.badge.review { color: var(--text); border-color: #777; }
.badge.rejected { color: var(--danger); border-color: rgba(255, 93, 93, 0.45); }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tpl { display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 20px; background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--radius); transition: border-color 0.15s, background 0.15s, box-shadow 0.2s; }
.tpl:hover { border-color: var(--accent-line); background: var(--panel); box-shadow: 0 0 32px rgba(180, 242, 60, 0.08); }
.tpl b { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.tpl span { color: var(--muted); font-size: 14px; font-weight: 300; }

.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }
.preview { position: sticky; top: 76px; }
.preview-head { font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.paper { background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 24px; min-height: 320px; font-size: 14.5px; line-height: 1.7; color: #e5e5e5; overflow-wrap: anywhere; }
.paper b { color: #fff; font-weight: 600; }
.paper .ctr { text-align: center; font-size: 16px; }
.save-state { font-size: 13px; color: var(--dim); }

.ask { display: flex; flex-direction: column; gap: 12px; margin-bottom: 28px; }
.result { padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); display: block; margin-bottom: 10px; transition: border-color 0.15s, background 0.15s; }
.result:hover { border-color: var(--accent-line); background: var(--panel); }
.result .r-top { display: flex; gap: 12px; align-items: baseline; margin-bottom: 4px; }
.result .r-doc { font-size: 13px; color: var(--dim); }
.result b { font-weight: 600; }
.result .r-n { color: var(--accent); font-size: 13px; font-weight: 600; white-space: nowrap; }
.result p { color: var(--muted); font-weight: 300; font-size: 14.5px; }

.note { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; background: var(--bg); }
.note[open] { border-color: var(--line-2); background: var(--panel); }
.note summary { display: flex; align-items: center; gap: 12px; padding: 14px 18px; cursor: pointer; list-style: none; }
.note summary::-webkit-details-marker { display: none; }
.note summary b { flex: 1; font-weight: 500; }
.note summary:hover b { color: var(--accent); }
.note .tags { font-size: 13px; color: var(--dim); }
.note-body { padding: 0 18px 18px; color: #d4d4d4; font-weight: 300; font-size: 16px; line-height: 1.7; }
.note-actions { display: flex; gap: 6px; padding: 0 18px 14px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; font-size: 14px; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.panel { max-width: 520px; display: flex; flex-direction: column; gap: 18px; }
.panel .hint { font-size: 13px; color: var(--dim); }
.panel h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.divider { height: 1px; background: var(--line); margin: 10px 0; }
.muted { color: var(--muted); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); margin: auto; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.8); }
dialog::backdrop { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(4px); }
.dlg-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.dlg-body h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.03em; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dlg-status { font-size: 13px; color: var(--muted); min-height: 20px; }
.dlg-status.err { color: var(--danger); }

#palette { width: min(600px, calc(100vw - 32px)); margin-top: 12vh; }
.pal input { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line-2); padding: 18px 20px; font-size: 17px; }
.pal input:focus { outline: none; border-bottom-color: var(--accent); }
.pal-list { max-height: 52vh; overflow-y: auto; padding: 8px; }
.pal-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; background: none; border-radius: 8px; text-align: left; }
.pal-item.sel { background: var(--raised); box-shadow: inset 2px 0 0 var(--accent); }
.pal-item .pi-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-item .pi-hint { font-size: 12px; color: var(--dim); white-space: nowrap; }
.pal-empty { padding: 28px; text-align: center; color: var(--dim); }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: var(--text); color: #000; padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; animation: toast-in 0.2s ease; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.scrim { display: none; }

@media (max-width: 960px) {
  .editor { grid-template-columns: 1fr; }
  .preview { position: static; }
  .search-trigger { min-width: 0; }
  .search-trigger .st-text, .search-trigger kbd { display: none; }
  .search-trigger { padding: 0 10px; }
}

@media (max-width: 760px) {
  .app, .app.collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-100%); transition: transform 0.25s ease; }
  .app.drawer .sidebar { transform: none; }
  .app.drawer .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); z-index: 35; }
  .app.collapsed .logo, .app.collapsed .sec-btn .lbl, .app.collapsed .sec-btn .chev, .app.collapsed .pc-text { display: revert; }
  .app.collapsed .sec-items { display: grid; }
  .app.collapsed .side-head { justify-content: space-between; padding: 0 14px 0 20px; }
  .app.collapsed .sec-btn { justify-content: flex-start; padding: 9px 12px; }
  .app.collapsed .profile-chip { justify-content: flex-start; padding: 8px; }
  #collapseBtn { display: none; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 14px; }
  .view { padding: 28px 16px 80px; }
  .trow { grid-template-columns: minmax(0, 1fr) auto; }
  .trow time { display: none; }
  .trow .status-sel { grid-column: 1; justify-self: start; }
  .trow .row-actions { grid-row: 1; grid-column: 2; }
  .art-actions { opacity: 1; }
  .top-actions .select { max-width: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.view > * { animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.view > *:nth-child(2) { animation-delay: 0.06s; }
.view > *:nth-child(3) { animation-delay: 0.12s; }
.view > *:nth-child(4) { animation-delay: 0.18s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.row, .trow, .result, .note, .tpl, .art { animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.list .row:nth-child(2), .table .trow:nth-child(2) { animation-delay: 0.04s; }
.list .row:nth-child(3), .table .trow:nth-child(3) { animation-delay: 0.08s; }
.list .row:nth-child(4), .table .trow:nth-child(4) { animation-delay: 0.12s; }
.list .row:nth-child(n+5), .table .trow:nth-child(n+5) { animation-delay: 0.16s; }
.tpl:nth-child(2) { animation-delay: 0.05s; } .tpl:nth-child(3) { animation-delay: 0.1s; } .tpl:nth-child(4) { animation-delay: 0.15s; } .tpl:nth-child(5) { animation-delay: 0.2s; }
.main { animation: aurora 9s ease-in-out infinite alternate; }
@keyframes aurora { from { background-position: 35% 0; } to { background-position: 65% 0; } }
.logo-q { display: inline-block; animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }
.btn:active, .chip:active, .icon-btn:active { transform: scale(0.96); }
.btn:hover, .chip:hover { transform: translateY(-1px); }
.tpl { transition: transform 0.2s, border-color 0.15s, background 0.15s, box-shadow 0.2s; }
.tpl:hover { transform: translateY(-4px); }
.sec-btn .i:first-child { transition: transform 0.25s; }
.sec-btn:hover .i:first-child { transform: scale(1.14) rotate(-5deg); }
.item { transition: background 0.15s, color 0.15s, padding-left 0.2s; }
.item:hover { padding-left: 16px; }
.badge, .dot { transition: all 0.2s; }
.side-foot { display: flex; align-items: center; gap: 4px; }
.profile-chip { flex: 1; }
.app.collapsed .side-foot .icon-btn { display: none; }

.guest { grid-template-columns: minmax(0, 1fr) !important; }
.guest .sidebar, .guest .menu-btn, .guest .search-trigger, .guest #serverSelect { display: none; }
.login { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 20px; }
.login-logo { font-size: clamp(44px, 9vw, 84px); font-weight: 600; letter-spacing: -0.055em; line-height: 1; }
.login-logo b { color: var(--accent); display: inline-block; animation: bob 3.2s ease-in-out infinite; }
.login p { color: var(--muted); font-weight: 300; font-size: 17px; max-width: 420px; }
.btn.big { height: 46px; padding: 0 26px; font-size: 16px; border-radius: 10px; }

.view.wide { max-width: none; padding: 0; }
.board { position: relative; height: calc(100vh - 56px); overflow: hidden; touch-action: none; cursor: grab; background-image: radial-gradient(#242424 1px, transparent 1px); background-size: 22px 22px; }
.board:active { cursor: grabbing; }
.board-inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.threads { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.threads path { fill: none; stroke: #444; stroke-width: 1.3; stroke-dasharray: 4 5; animation: dash 1.4s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -18; } }
.node { position: absolute; width: 190px; height: 40px; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 0 10px; background: #1b1c1f; border: 1px solid #2a2a2a; border-radius: 10px; font-size: 12.5px; line-height: 1.15; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; animation: pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.3) both; transition: transform 0.15s, border-color 0.15s, box-shadow 0.2s; }
.node small { font-size: 9px; color: var(--dim); letter-spacing: 0.04em; text-transform: uppercase; }
.node:hover { transform: translateY(-2px) scale(1.04); border-color: var(--accent-line); box-shadow: 0 0 24px rgba(180, 242, 60, 0.18); z-index: 2; }
@keyframes pop { from { opacity: 0; transform: scale(0.6); } }
.node.root { border-color: var(--accent); box-shadow: 0 0 28px rgba(180, 242, 60, 0.22); font-weight: 600; }
.node.grp, .node.doc.signed { background: #14200f; border-color: #25401a; }
.node.doc.rejected { background: #261316; border-color: #4a2026; }
.node.doc.review { background: #261d10; border-color: #4a3818; }

.board-bar { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; gap: 10px; cursor: default; animation: rise 0.6s 0.3s both; }
.bar-group { display: flex; gap: 6px; padding: 6px; background: rgba(20, 20, 22, 0.85); backdrop-filter: blur(10px); border: 1px solid var(--line-2); border-radius: 999px; }
.bar-btn { width: 40px; height: 40px; display: grid; place-items: center; background: #26272b; border: 0; border-radius: 50%; color: var(--text); font-size: 20px; transition: background 0.15s, transform 0.15s, color 0.15s; }
.bar-btn:hover { background: var(--accent); color: var(--accent-ink); transform: scale(1.08); }

.sheet { background: #000; border: 1px solid var(--line-2); border-radius: 14px; padding: 28px 26px 18px; min-height: 540px; display: flex; flex-direction: column; text-align: center; transition: box-shadow 0.35s; }
.sheet.tick { box-shadow: 0 0 0 1px var(--accent-line), 0 0 44px rgba(180, 242, 60, 0.16); }
.sheet-logo { font-size: 28px; font-weight: 600; letter-spacing: -0.05em; }
.sheet-logo b { color: var(--accent); }
.sheet-kind { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; margin-top: 16px; }
.sheet-title { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; overflow-wrap: anywhere; }
.sheet-id { font-size: 12px; color: var(--muted); margin: 3px 0 16px; }
.sheet-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.sheet .paper { flex: 1; background: none; border: 0; padding: 0; min-height: 0; text-align: center; font-size: 14px; }
.sheet-foot { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 24px; }
.stamp { width: 74px; height: 74px; color: #d0d0d0; opacity: 0.9; }
.sign { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; color: var(--muted); }
.sign i { font: 600 30px "Caveat", cursive; color: #fff; transform: rotate(-4deg); }
.sheet-code { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 10px; }

.thread { position: relative; display: flex; flex-direction: column; gap: 14px; padding-left: 46px; }
.thread:empty { display: none; }
.thread::before { content: ""; position: absolute; left: 15px; top: 14px; bottom: 14px; width: 2px; background: var(--line-2); border-radius: 2px; }
.tsec { position: relative; display: flex; flex-direction: column; gap: 6px; animation: rise 0.35s both; }
.tnum { position: absolute; left: -46px; top: 0; width: 32px; height: 32px; border-radius: 50%; background: var(--raised); border: 1px solid var(--line-2); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.tsec input, .tsec textarea { background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 12px; transition: border-color 0.15s, box-shadow 0.15s; }
.tsec input:focus, .tsec textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.link-btn { align-self: flex-end; background: none; border: 0; color: var(--muted); font-size: 13px; }
.link-btn:hover { color: var(--danger); }

.rtb { display: flex; gap: 4px; flex-wrap: wrap; }
.rtb button { width: 34px; height: 30px; background: var(--raised); border: 1px solid var(--line-2); border-radius: 7px; color: var(--muted); font-weight: 600; transition: all 0.15s; }
.rtb button:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); transform: translateY(-1px); }
.rt { min-height: 96px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; line-height: 1.55; transition: border-color 0.15s, box-shadow 0.15s; }
.rt:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rt:empty::before { content: attr(data-ph); color: var(--dim); }
.rt ul, .rt ol, .paper ul, .paper ol { padding-left: 22px; text-align: left; }
.chap { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; margin: 36px 0 -8px; padding-bottom: 10px; border-bottom: 1px solid var(--line-2); animation: rise 0.4s both; }
.stars { color: var(--accent); font-size: 12px; letter-spacing: 1px; white-space: nowrap; text-shadow: 0 0 10px rgba(180, 242, 60, 0.5); }
.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.notice.err { border-color: rgba(255, 93, 93, 0.5); background: rgba(255, 93, 93, 0.1); max-width: 460px; }

.node.note { width: 220px; height: 84px; align-items: flex-start; justify-content: flex-start; padding: 8px 12px; white-space: pre-wrap; text-align: left; font-size: 12px; line-height: 1.4; background: #1d1c14; border-color: #3a3820; }
.node.pick { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), 0 0 24px rgba(180, 242, 60, 0.3); }
.threads .hit { stroke: transparent; stroke-width: 16; animation: none; pointer-events: stroke; cursor: pointer; }
.threads .hit:hover + path { stroke: var(--accent); }
.board-bar { max-width: 96vw; }
.bar-group.wrap { flex-wrap: wrap; justify-content: center; border-radius: 22px; }
.bar-group .btn { height: 36px; }
.bar-note { padding: 8px 16px; font-size: 13px; color: var(--muted); }
.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; }
.chk input { accent-color: var(--accent); width: 16px; height: 16px; }
dialog.dlg-wide { width: min(1000px, 96vw); max-height: 92vh; overflow: auto; }
.fill { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 760px) { .fill { grid-template-columns: 1fr; } }

.fld { background: rgba(180, 242, 60, 0.16); color: var(--accent); border-radius: 5px; padding: 0 4px; font-weight: 500; }
.set { display: flex; flex-direction: column; gap: 16px; max-width: 640px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; animation: rise 0.45s both; }
.card h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.card .hint { font-size: 13px; color: var(--dim); }
.card input[type="color"] { height: 40px; padding: 2px; }
.node.group { width: 220px; height: 44px; background: #101a14; border-color: #25401a; font-weight: 600; }
.sheet { border-top: 3px solid var(--brand, var(--accent)); }
.sheet-logo b, .sheet .stamp { color: var(--brand, var(--accent)); }
.sheet-img { max-height: 48px; max-width: 70%; object-fit: contain; }
.signs { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.sgn { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sgn input { background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font-size: 14px; min-width: 0; }

.lpage { width: 560px; aspect-ratio: 210 / 297; display: flex; flex-direction: column; gap: 10px; font-family: var(--font); line-height: 1.45; overflow-wrap: anywhere; border-radius: 6px; box-sizing: border-box; --brand: var(--accent); }
.lpage mark { background: none; color: inherit; }
.lpage .lb { display: flex; width: 100%; }
.lpage .lt, .lpage .lc { width: 100%; }
.lpage .ll { width: 100%; display: flex; justify-content: center; }
.lpage .li { max-width: 100%; object-fit: contain; }
.lpage .ls { margin-top: auto; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.lpage .stamp { width: 70px; height: 70px; color: var(--brand); }
.lpage .sign { color: inherit; opacity: 0.9; }
.lpage .sign i { color: inherit; }
.sec-t { text-transform: uppercase; font-weight: 600; text-align: center; margin: 10px 0 4px; }
.ph { border: 1px dashed #666; padding: 10px; font-size: 12px; color: #888; text-align: center; width: 100%; border-radius: 4px; }
.lpage.edit [data-bid] { cursor: pointer; }
.lpage.edit [data-bid]:hover { outline: 1px dashed #7c8cf0; }
.lpage.edit .sel { outline: 2px solid #7c8cf0 !important; }
.nosel .lpage [data-bid] { outline: none !important; }
.ted { display: grid; grid-template-columns: 240px minmax(0, 1fr) 280px; grid-template-rows: 56px minmax(0, 1fr); height: calc(100vh - 56px); }
.ted-bar { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.ted-bar .grow { flex: 1; }
.ted-l, .ted-r { overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; border-right: 1px solid var(--line); }
.ted-r { border-right: 0; border-left: 1px solid var(--line); gap: 12px; }
.ted h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 8px 0 4px; }
.ted-c { overflow: auto; padding: 28px; display: flex; justify-content: center; align-items: flex-start; background-image: radial-gradient(#242424 1px, transparent 1px); background-size: 22px 22px; }
.lyrs { display: flex; flex-direction: column; gap: 1px; }
.lyr { text-align: left; background: none; border: 0; padding: 6px 10px; border-radius: 6px; color: var(--muted); font-size: 13px; transition: background 0.15s, color 0.15s; }
.lyr:hover { background: var(--raised); color: var(--text); }
.lyr.on { background: var(--raised); color: var(--text); box-shadow: inset 2px 0 var(--accent); }
.cmp { text-align: left; background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 12px; font-size: 14px; transition: all 0.15s; }
.cmp:hover { border-color: var(--accent-line); transform: translateX(3px); }
.gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.gcard { background: none; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; text-align: left; font-size: 14px; transition: border-color 0.15s, transform 0.2s, box-shadow 0.2s; animation: rise 0.4s both; }
.gcard:hover { border-color: var(--accent-line); transform: translateY(-3px); box-shadow: 0 0 28px rgba(180, 242, 60, 0.1); }
.thumb { width: 123px; height: 174px; overflow: hidden; border-radius: 4px; margin: 0 auto; pointer-events: none; }
.thumb-in { zoom: 0.22; }
.docwrap { padding: 28px 32px 80px; }
.docgrid { display: grid; grid-template-columns: minmax(0, 1fr) 580px; gap: 28px; align-items: start; }
.docform { display: flex; flex-direction: column; gap: 16px; }
.docprev { position: sticky; top: 76px; overflow: auto; max-height: calc(100vh - 100px); }
.dtitle { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 1100px) { .docgrid { grid-template-columns: 1fr; } .docprev { position: static; max-height: none; } }
@media (max-width: 900px) { .ted { grid-template-columns: 1fr; grid-template-rows: auto; height: auto; } .ted-l, .ted-r { border: 0; } .ted-c { padding: 14px; } }
@media (max-width: 700px) { .lpage { zoom: 0.62; } .docwrap { padding: 20px 14px 80px; } .grid3 { grid-template-columns: 1fr; } }
.lpage img.stamp { object-fit: contain; }
img.avatar { object-fit: cover; display: block; }

.up { display: flex; gap: 12px; align-items: center; }
.up-prev { width: 96px; height: 96px; border: 1px dashed var(--line-2); border-radius: 10px; display: grid; place-items: center; overflow: hidden; background: #111; font-size: 12px; color: var(--dim); flex: none; }
.up-prev img { max-width: 100%; max-height: 100%; object-fit: contain; }
.up .actions { flex-direction: column; align-items: flex-start; }
label.btn { cursor: pointer; }

.pform { max-width: 640px; margin: 0 auto; }
.pform .card h2 { display: flex; align-items: center; font-size: 17px; }
.tnum2 { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--raised); border: 1px solid var(--line-2); font-size: 12px; margin-right: 10px; flex: none; }
.ans-img { max-width: 100%; max-height: 260px; border-radius: 8px; margin-top: 6px; }
