/* Hub — Vitally-inspired design system.
   Deep teal-black canvas, violet primary, teal accents, pill buttons, flat-2.0. */

:root {
  --bg: #0b1919;
  --bg-soft: #0f1f1f;
  --surface: #102424;
  --surface-2: #142a2a;
  --border: #1f2e2e;
  --border-strong: #2a3c3c;
  --text: #ffffff;
  --text-secondary: #d1d5db;
  --text-muted: #9aa8a8;
  --text-faint: #6b7d7d;
  --violet: #8b3dff;
  --violet-strong: #7a2ef0;
  --violet-soft: rgba(139, 61, 255, 0.14);
  --teal: #3dd6c3;
  --ok: #3dd6c3;
  --err: #ff6b6b;
  --err-soft: rgba(255, 107, 107, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.006em;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
button {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 18px;
  transition: background .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease;
}
button:hover { background: #1a3030; border-color: #3a4f4f; }
button:active { transform: translateY(0.5px); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
button.primary {
  background: var(--violet);
  border-color: var(--violet);
  color: #fff;
}
button.primary:hover { background: var(--violet-strong); border-color: var(--violet-strong); color: #fff; }
button.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
button.ghost:hover { background: var(--surface); color: var(--text); border-color: transparent; }
button.soft {
  background: var(--violet-soft);
  border-color: transparent;
  color: #b79bff;
}
button.soft:hover { background: rgba(139, 61, 255, 0.22); border-color: transparent; color: #cbb3ff; }
input, textarea {
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(139, 61, 255, 0.18);
}
::placeholder { color: var(--text-faint); }

.muted { color: var(--text-muted); font-size: 13px; }
.faint { color: var(--text-faint); font-size: 12px; }

/* ---------- login ---------- */
#login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(139, 61, 255, 0.10), transparent 60%),
              radial-gradient(1000px 500px at 90% 110%, rgba(61, 214, 195, 0.08), transparent 60%),
              var(--bg);
  padding: 24px;
}
#login {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px 38px 34px;
}
.brand-mark {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg, var(--teal), var(--violet));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 24px;
  margin-bottom: 22px;
}
#login h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
#login .sub { color: var(--text-muted); margin: 6px 0 26px; font-size: 14px; }
#login input { margin-bottom: 12px; }
#login .err, #login .note {
  min-height: 20px; font-size: 13px; border-radius: var(--radius-sm);
  padding: 9px 13px; margin-bottom: 12px;
}
#login .err { color: var(--err); background: var(--err-soft); }
#login .note { color: var(--teal); background: rgba(61, 214, 195, 0.12); }
#login button.primary { width: 100%; padding: 13px; font-size: 15px; font-weight: 700; }

/* ---------- app shell ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  height: 62px; padding: 0 26px;
  background: rgba(11, 25, 25, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; cursor: pointer; font-size: 16px; font-weight: 800; color: var(--text); letter-spacing: -0.015em; }
.brand .mark {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, var(--teal), var(--violet));
  color: #fff; font-size: 16px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.brand:hover { text-decoration: none; }
.topbar-book { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 14px; }
.topbar-book .crumb-sep { color: var(--text-faint); }
.topbar-book strong { color: var(--text-muted); font-weight: 600; }
#topbar .spacer { flex: 1; }

#layout { display: flex; min-height: calc(100vh - 62px); align-items: stretch; }

/* ---------- sidebar ---------- */
#sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
#sidebar h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-faint); font-weight: 600;
  margin: 18px 12px 8px;
}
#sidebar h3:first-child { margin-top: 4px; }
#sidebar .item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  cursor: pointer; font-size: 14px; color: var(--text-muted); font-weight: 500;
  transition: background .12s ease, color .12s ease;
  user-select: none;
}
#sidebar .item:hover { background: var(--surface); color: var(--text); }
#sidebar .item.active { background: var(--violet-soft); color: #cbb3ff; font-weight: 600; }
#sidebar .item .ico { width: 18px; height: 18px; flex-shrink: 0; }
#sidebar .item .count { margin-left: auto; font-size: 12px; color: var(--text-faint); }
#sidebar .capture-panel { margin-top: auto; padding: 10px 4px 18px; }
#sidebar .capture-panel input { margin-bottom: 8px; background: var(--bg); }
#sidebar .capture-panel button { width: 100%; }

/* ---------- main ---------- */
#main { flex: 1; padding: 30px 38px 50px; overflow-y: auto; min-width: 0; }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.page-head .sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.page-tools { display: flex; gap: 10px; }

/* ---------- cards (generic) ---------- */
#grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin-top: 8px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
  position: relative;
}
.card:hover { border-color: var(--violet); background: var(--surface-2); transform: translateY(-1px); }
.card .book-cover {
  width: 52px; height: 68px; border-radius: 8px;
  background: linear-gradient(150deg, var(--teal), var(--violet));
  box-shadow: 0 4px 14px rgba(139, 61, 255, 0.3);
  margin-bottom: 14px;
  display: flex; align-items: flex-end; justify-content: center;
  color: #fff; font-size: 18px; font-weight: 800; letter-spacing: .02em;
  padding-bottom: 8px;
}
.card .title { font-size: 16px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.01em; }
.card .meta { color: var(--text-muted); font-size: 13px; }
.card .open-arrow {
  position: absolute; top: 22px; right: 18px;
  color: var(--text-faint); font-size: 18px;
  transition: color .15s ease, transform .15s ease;
}
.card:hover .open-arrow { color: var(--teal); transform: translateX(2px); }

/* ---------- file lists ---------- */
.filelist { display: grid; gap: 6px; margin-top: 8px; }
.file {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 16px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.file:hover { border-color: var(--violet); background: var(--surface-2); }
.file .f-ico {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.file .f-ico.char { background: rgba(139, 61, 255, 0.15); }
.file .f-ico.loc { background: rgba(61, 214, 195, 0.14); }
.file .f-ico.thm { background: rgba(255, 200, 87, 0.14); }
.file .f-ico.chap { background: rgba(139, 61, 255, 0.18); }
.file .f-ico.idea { background: rgba(255, 107, 107, 0.14); }
.file .f-ico.plot { background: rgba(61, 214, 195, 0.12); }
.file .f-ico.note { background: var(--surface-2); }
.file .f-main { flex: 1; min-width: 0; }
.file .f-title { font-weight: 600; font-size: 14px; }
.file .f-meta { color: var(--text-faint); font-size: 12px; margin-top: 2px; }
.file .f-arrow { color: var(--text-faint); font-size: 16px; transition: color .15s ease, transform .15s ease; }
.file:hover .f-arrow { color: var(--teal); transform: translateX(2px); }
.filelist-note { color: var(--text-faint); font-size: 13px; margin: 4px 2px 14px; display: flex; gap: 6px; align-items: center; }

/* ---------- corkboard ---------- */
#cork {
  display: flex; flex-wrap: wrap; gap: 16px;
  padding: 8px 0 20px;
}
.note {
  width: 216px; min-height: 150px;
  background: linear-gradient(180deg, #1a2b2b, #152626);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 16px 16px 12px;
  cursor: grab;
  position: relative;
  transition: border-color .15s ease, transform .15s ease;
}
.note.dragging { opacity: .45; cursor: grabbing; transform: rotate(1deg); }
.note:hover { border-color: var(--teal); }
.note .nt { font-weight: 700; font-size: 14px; margin: 8px 0 6px; color: #bfe9e2; }
.note .nn { color: var(--text-muted); font-size: 12.5px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.note .nd { margin-top: 10px; font-size: 11px; color: var(--text-faint); }

/* ---------- editor ---------- */
#editor { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 420px; }
#editor .etitle { font-size: 18px; font-weight: 700; margin-bottom: 10px; word-break: break-word; }
#editor textarea {
  flex: 1;
  resize: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 30px;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
}
#editor .ebar { display: flex; align-items: center; gap: 12px; padding: 12px 2px 0; }

/* ---------- capture ---------- */
.capture-card {
  margin-top: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.capture-card .cap-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
#capturebar { display: flex; gap: 10px; align-items: stretch; }
#capturebar input { flex: 1; background: var(--bg-soft); min-height: 46px; }
#capturebar button { min-height: 46px; padding: 0 24px; white-space: nowrap; }
.cap-hint { color: var(--text-faint); font-size: 12.5px; margin-top: 10px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 99;
  padding: 12px 24px;
  border-radius: 999px;
  background: #1a3030;
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-size: 14px;
  display: none;
  max-width: 480px;
  text-align: center;
}
#toast.show { display: block; animation: toastin .18s ease; }
#toast.err { background: var(--err-soft); border-color: var(--err); color: var(--err); }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- empty states ---------- */
.empty {
  color: var(--text-muted);
  padding: 60px 20px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  margin-top: 8px;
}
.empty .e-ico { font-size: 34px; margin-bottom: 10px; opacity: .6; }
.empty .e-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; color: var(--text-secondary); }
.empty .e-sub { font-size: 13px; color: var(--text-faint); }

.hidden { display: none; }

/* ---------- home dashboard (Vitally-style) ---------- */
.dash-head { display: flex; align-items: flex-end; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.dash-title { font-size: 28px; font-weight: 800; letter-spacing: -0.025em; }
.dash-capture { flex: 1; display: flex; gap: 10px; min-width: 340px; }
.dash-capture input { flex: 1; min-height: 46px; background: var(--bg-soft); }
.dash-capture button { min-height: 46px; padding: 0 24px; white-space: nowrap; }
.dash-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 28px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px 22px;
}
.tile-n {
  font-size: 32px; font-weight: 800; letter-spacing: -0.02em;
  background: linear-gradient(120deg, #fff, #b79bff);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.tile-l { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.dash-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1150px) { .dash-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 780px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.widget {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px 22px;
}
.widget-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.widget-head h2 { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.book-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.bcard { cursor: pointer; border-radius: 12px; padding: 10px; border: 1px solid transparent; transition: border-color .15s, background .15s; }
.bcard:hover { border-color: var(--violet); background: var(--surface-2); }
.bcover {
  width: 100%; aspect-ratio: 3 / 4.2; border-radius: 10px; margin-bottom: 10px;
  background: linear-gradient(150deg, var(--teal), var(--violet));
  color: #fff; font-size: 34px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(139, 61, 255, 0.25);
  overflow: hidden;
}
.bcover.img { background: var(--bg-soft); }
.bcover img { width: 100%; height: 100%; object-fit: cover; }
.btitle { font-weight: 600; font-size: 13.5px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.pcard {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.pcard:hover { border-color: var(--violet); background: var(--surface-2); }
.pname { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.task-list { display: flex; flex-direction: column; gap: 2px; }
.task-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 8px; border-radius: 10px;
  cursor: pointer; transition: background .12s;
}
.task-row:hover { background: var(--surface-2); }
.task-row.done .task-action { text-decoration: line-through; color: var(--text-faint); }
.tcheck {
  width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%;
  border: 2px solid var(--border-strong); background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff; cursor: pointer; padding: 0; margin-top: 1px;
  transition: background .12s, border-color .12s;
}
.tcheck:hover { border-color: var(--teal); }
.tcheck.checked { background: var(--teal); border-color: var(--teal); color: #062020; }
.task-text { min-width: 0; }
.task-action { font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.done-head { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 12px 8px 2px; color: var(--text-faint); }
.meet-list { display: flex; flex-direction: column; gap: 2px; }
.meet-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 10px;
  cursor: pointer; transition: background .12s;
}
.meet-row:hover { background: var(--surface-2); }
.meet-date { width: 54px; flex-shrink: 0; font-size: 12px; }
.meet-body { flex: 1; min-width: 0; }
.meet-title { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.daily-list { display: flex; flex-direction: column; gap: 2px; }

/* ---------- chapters outline ---------- */
.chap-row { cursor: grab; }
.chap-row.dragging { opacity: .5; border-color: var(--violet); }
.chap-num {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--violet-soft); color: #b79bff;
  font-weight: 800; font-size: 14px;
}
.chap-grip { color: var(--text-faint); font-size: 16px; padding: 0 6px; cursor: grab; user-select: none; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 10, 10, 0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadein .15s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%; max-width: 440px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 28px 28px 22px;
  animation: popin .16s ease;
}
@keyframes popin { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-card h3 { font-size: 19px; font-weight: 800; margin-bottom: 6px; }
.modal-card .muted { margin-bottom: 16px; }
.modal-card input[type=text], .modal-card .m-file { margin-bottom: 10px; }
.m-file {
  position: relative;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  transition: border-color .15s ease, color .15s ease;
}
.m-file:hover { border-color: var(--teal); color: var(--teal); }
.m-file input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.m-err { color: var(--err); font-size: 13px; min-height: 18px; margin-top: 6px; }
.m-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

/* ---------- publish view ---------- */
.pub-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .pub-grid { grid-template-columns: 1fr; } }
.pub-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 16px;
}
.pub-card h2 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.pub-card .muted { margin-bottom: 14px; }
.pub-field { margin-bottom: 12px; }
.pub-field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.pub-field textarea { min-height: 130px; resize: vertical; font: inherit; }
.pub-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pub-cover { display: flex; gap: 16px; align-items: center; margin-top: 8px; }
.pub-cover-frame {
  width: 130px; height: 180px; flex-shrink: 0;
  border: 1px solid var(--border-strong); border-radius: 10px;
  overflow: hidden; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.pub-cover-frame img { width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder { color: var(--text-faint); font-size: 12px; }
.pub-cover-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.pub-actions { display: flex; gap: 12px; margin-top: 6px; }
.pub-status { margin-top: 14px; font-size: 13.5px; min-height: 20px; }
.pub-status.ok { color: var(--ok); }
.pub-status.err { color: var(--err); }