/* ============================================================
   Studio OS — Main Styles
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-weight: 400;
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: 0;
  position: relative;
}
/* faint grain, matching the source site's hero texture */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  opacity: 0.025; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}
::selection { background: var(--accent-soft-2); }
h1,h2,h3,h4 { margin: 0; font-weight: 400; letter-spacing: -0.01em; }
.serif { font-family: var(--font-serif); font-weight: 400; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select, button { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-4); background-clip: padding-box; }

/* ============================================================
   App shell
   ============================================================ */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--border);
  background: rgba(10,10,12,0.6);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}
.sidebar-scrim { display: none; }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 14px;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: var(--r); flex: 0 0 30px;
  background: linear-gradient(150deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #000));
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.25);
}
.brand-text { flex: 1; min-width: 0; overflow: hidden; }
.brand-name { font-family: var(--font-serif); font-weight: 400; font-size: 16px; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11px; color: var(--text-4); margin-top: -2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.collapse-btn { flex: 0 0 auto; transition: transform var(--t-fast); }
.collapse-btn .ico { transform: rotate(180deg); }

/* collapsed rail mode */
.sidebar.collapsed { width: 64px; flex: 0 0 64px; }
.sidebar.collapsed .brand-text, .sidebar.collapsed .nav-group-label, .sidebar.collapsed .nav-item .label, .sidebar.collapsed .nav-item .count { display: none; }
.sidebar.collapsed .brand { padding: 16px 0 14px; justify-content: center; }
.sidebar.collapsed .collapse-btn { position: absolute; right: -11px; top: 18px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 50%; }
.sidebar.collapsed .collapse-btn .ico { transform: rotate(0deg); }
.sidebar.collapsed .nav-item { justify-content: center; padding: 9px 0; }
.sidebar.collapsed .nav { padding: 10px 8px 14px; }
.sidebar.collapsed .nav-item.active::before { left: 0; }
.sidebar { position: sticky; transition: width var(--t) var(--ease); }

.nav { flex: 1; overflow-y: auto; padding: 6px 10px 14px; }
.nav-group-label {
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-4);
  padding: 16px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--r);
  color: var(--text-2); font-weight: 500;
  cursor: pointer; user-select: none;
  position: relative;
  transition: background var(--t-fast), color var(--t-fast);
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--active); color: var(--text); }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 17px; border-radius: 3px; background: var(--accent);
}
.nav-item .ico { width: 17px; height: 17px; flex: 0 0 17px; color: var(--text-3); transition: color var(--t-fast); }
.nav-item:hover .ico, .nav-item.active .ico { color: var(--text); }
.nav-item .label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .count {
  font-size: 11px; color: var(--text-4); font-variant-numeric: tabular-nums;
  background: var(--surface-2); padding: 1px 7px; border-radius: 20px;
}
.nav-item.active .count { background: var(--accent-soft); color: var(--accent-text); }

.sidebar-foot { padding: 10px; border-top: 1px solid var(--border); }

/* ============================================================
   Main column / topbar
   ============================================================ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  position: sticky; top: 0; z-index: 30;
  background: rgba(10,10,12,0.7); backdrop-filter: blur(12px);
}
.crumb { display: flex; align-items: center; gap: 9px; min-width: 0; }
.crumb .ico { width: 16px; height: 16px; color: var(--text-3); }
.crumb-title { font-family: var(--font-serif); font-weight: 400; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-sub { color: var(--text-4); font-size: 12.5px; }
.topbar-spacer { flex: 1; }
.menu-btn { display: none; }

.search-trigger {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-3); padding: 7px 11px; border-radius: var(--r);
  min-width: 240px; transition: border-color var(--t-fast), background var(--t-fast);
}
.search-trigger:hover { border-color: var(--border-strong); background: var(--surface-3); }
.search-trigger .ico { width: 15px; height: 15px; }
.search-trigger .ph { flex: 1; text-align: left; font-size: 13px; }
.kbd {
  font-family: var(--mono); font-size: 11px; color: var(--text-3);
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px; line-height: 1.5;
}

.view { flex: 1; min-height: 0; }
.page { max-width: var(--content-max); margin: 0 auto; padding: 26px 26px 80px; animation: viewIn var(--t-slow) var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Buttons / controls
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-weight: 500; font-size: 13px;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-fg); font-weight: 500; }
.btn-primary:hover { background: var(--text); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-icon { padding: 7px; }
.btn-danger { color: var(--c-red); border-color: var(--c-red-bg); background: var(--c-red-bg); }
.btn-danger:hover { background: rgba(240,97,109,0.2); }
.btn.sm { padding: 5px 9px; font-size: 12.5px; }

.input, .textarea, .select {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 9px 11px; color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
select.select { appearance: none; cursor: pointer;
  background-image: 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='%237d7d88' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px;
}

/* Search box (in-view) */
.field-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 6px 10px; min-width: 220px;
  transition: border-color var(--t-fast);
}
.field-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-search .ico { width: 15px; height: 15px; color: var(--text-3); }
.field-search input { background: none; border: none; outline: none; flex: 1; min-width: 0; padding: 0; font-size: 13px; }

/* ============================================================
   Pills / tags
   ============================================================ */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500;
  white-space: nowrap; line-height: 1.6;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 7px; }
.pill.gray   { color: var(--c-gray);   background: var(--c-gray-bg); }
.pill.blue   { color: var(--c-blue);   background: var(--c-blue-bg); }
.pill.green  { color: var(--c-green);  background: var(--c-green-bg); }
.pill.yellow { color: var(--c-yellow); background: var(--c-yellow-bg); }
.pill.orange { color: var(--c-orange); background: var(--c-orange-bg); }
.pill.red    { color: var(--c-red);    background: var(--c-red-bg); }
.pill.purple { color: var(--c-purple); background: var(--c-purple-bg); }
.pill.pink   { color: var(--c-pink);   background: var(--c-pink-bg); }
.pill.teal   { color: var(--c-teal);   background: var(--c-teal-bg); }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 500;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border);
}
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; }

/* ============================================================
   Toolbar (collection header)
   ============================================================ */
.toolbar { display: flex; align-items: center; gap: 10px; margin: 18px 0 16px; flex-wrap: wrap; }
.toolbar-left { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; flex: 1; min-width: 0; }
.toolbar-right { display: flex; align-items: center; gap: 9px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 2px; }
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; color: var(--text-3);
  padding: 5px 10px; border-radius: 7px; font-weight: 500; font-size: 12.5px;
  transition: background var(--t-fast), color var(--t-fast);
}
.seg button .ico { width: 15px; height: 15px; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-sm); }

.filter-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 6px 10px; color: var(--text-2);
  font-size: 12.5px; font-weight: 500; position: relative;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.filter-chip:hover { color: var(--text); border-color: var(--border-strong); }
.filter-chip.has-value { color: var(--text); border-color: var(--accent-soft-2); background: var(--accent-soft); }
.filter-chip .ico { width: 14px; height: 14px; color: var(--text-3); }
.filter-chip .badge { background: var(--accent); color: #fff; border-radius: 20px; font-size: 10.5px; padding: 0 6px; font-weight: 600; }

.page-head { display: flex; align-items: flex-start; gap: 14px; }
.page-head .icon-wrap {
  width: 38px; height: 38px; border-radius: var(--r-md); flex: 0 0 38px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text);
  border: 1px solid var(--accent-soft-2);
}
.page-head .icon-wrap .ico { width: 20px; height: 20px; }
.page-title { font-family: var(--font-serif); font-size: 26px; font-weight: 400; letter-spacing: -0.005em; }
.page-desc { color: var(--text-3); font-size: 13px; font-weight: 300; line-height: 1.6; margin-top: 4px; max-width: 60ch; }

/* ============================================================
   Table
   ============================================================ */
.table-wrap {
  border: 1px solid var(--border); border-radius: var(--r-md);
  overflow: hidden; background: var(--surface);
}
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  text-align: left; font-weight: 500; font-size: 10.5px; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-4);
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap; user-select: none;
}
.tbl thead th.sortable { cursor: pointer; }
.tbl thead th.sortable:hover { color: var(--text-2); }
.tbl thead th .th-in { display: inline-flex; align-items: center; gap: 5px; }
.tbl thead th .sort-ind { width: 12px; height: 12px; opacity: 0; transition: opacity var(--t-fast); }
.tbl thead th.sorted .sort-ind { opacity: 1; color: var(--accent-text); }
.tbl tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border-faint); vertical-align: middle; }
.tbl tbody tr { transition: background var(--t-fast); cursor: pointer; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .cell-primary { font-weight: 500; color: var(--text); }
.tbl .cell-muted { color: var(--text-3); }
.cell-trunc { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity var(--t-fast); }
.tbl tbody tr:hover .row-actions { opacity: 1; }
.icon-btn {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 7px; background: transparent; border: none; color: var(--text-3);
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--hover-strong); color: var(--text); }
.icon-btn.danger:hover { color: var(--c-red); background: var(--c-red-bg); }
.icon-btn .ico { width: 15px; height: 15px; }

/* score bar */
.scorebar { display: inline-flex; align-items: center; gap: 8px; min-width: 110px; }
.scorebar .track { flex: 1; height: 5px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.scorebar .fill { height: 100%; border-radius: 5px; background: var(--accent); transition: width var(--t-slow) var(--ease); }
.scorebar .num { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text-2); min-width: 24px; text-align: right; }
.money { font-variant-numeric: tabular-nums; }
.linkcell { display: inline-flex; align-items: center; gap: 5px; max-width: 220px; }
.linkcell .ico { width: 13px; height: 13px; flex: 0 0 13px; }
.linkcell span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date-cell { font-variant-numeric: tabular-nums; color: var(--text-2); }
.date-cell.overdue { color: var(--c-red); }
.date-cell.soon { color: var(--c-yellow); }

/* ============================================================
   Cards grid
   ============================================================ */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.rec-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 15px; cursor: pointer; transition: border-color var(--t), transform var(--t), background var(--t);
  display: flex; flex-direction: column; gap: 10px; position: relative;
}
.rec-card:hover { border-color: var(--border-strong); background: var(--surface-2); transform: translateY(-2px); }
.rec-card .rc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.rec-card .rc-title { font-weight: 600; font-size: 14.5px; line-height: 1.35; }
.rec-card .rc-body { color: var(--text-3); font-size: 13px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rec-card .rc-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: auto; padding-top: 4px; }
.rec-card .rc-field { display: flex; flex-direction: column; gap: 2px; }
.rec-card .rc-field .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-4); }
.rec-card .rc-field .v { font-size: 13px; color: var(--text-2); }

/* ============================================================
   Kanban board
   ============================================================ */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; }
.board-col {
  flex: 0 0 280px; width: 280px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); display: flex; flex-direction: column; max-height: calc(100vh - 230px);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.board-col.drop-target { border-color: var(--accent); background: var(--accent-soft); }
.board-col-head { display: flex; align-items: center; gap: 8px; padding: 12px 13px 10px; }
.board-col-head .ttl { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 7px; }
.board-col-head .cnt { margin-left: auto; font-size: 11.5px; color: var(--text-4); background: var(--surface-2); border-radius: 20px; padding: 1px 8px; font-variant-numeric: tabular-nums; }
.board-col-head .col-dot { width: 8px; height: 8px; border-radius: 50%; }
.board-col-body { padding: 0 9px 9px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kard {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 11px 12px; cursor: grab; transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  display: flex; flex-direction: column; gap: 8px;
}
.kard:hover { border-color: var(--border-strong); }
.kard.dragging { opacity: 0.4; cursor: grabbing; }
.kard .kt { font-weight: 500; font-size: 13.5px; line-height: 1.35; }
.kard .ksub { color: var(--text-3); font-size: 12px; }
.kard .kmeta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.board-add { margin: 2px 9px 10px; }
.board-add .btn { width: 100%; justify-content: center; color: var(--text-3); background: transparent; border-style: dashed; }
.board-add .btn:hover { color: var(--text); }

/* ============================================================
   Empty / states
   ============================================================ */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 64px 20px; color: var(--text-3); gap: 12px;
  border: 1px dashed var(--border); border-radius: var(--r-md); background: var(--surface);
}
.empty .e-ico { width: 46px; height: 46px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.empty .e-ico .ico { width: 22px; height: 22px; }
.empty h3 { font-family: var(--font-serif); font-size: 17px; font-weight: 400; color: var(--text-2); }
.empty p { font-size: 13px; max-width: 38ch; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(4px);
  animation: fade var(--t) var(--ease);
  padding: 24px;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 560px; max-height: 88vh; overflow: hidden;
  background: var(--elevated); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; animation: pop var(--t-slow) var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head .icon-wrap { width: 32px; height: 32px; border-radius: var(--r); flex: 0 0 32px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.modal-head .icon-wrap .ico { width: 17px; height: 17px; }
.modal-head h2 { font-family: var(--font-serif); font-size: 17px; font-weight: 400; }
.modal-head .sub { font-size: 12px; color: var(--text-4); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }
.modal-foot .spacer { flex: 1; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.form-field .hint { font-size: 11px; color: var(--text-4); }

/* tag input */
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 6px 8px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.tag-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tag-input input { background: none; border: none; outline: none; flex: 1; min-width: 80px; padding: 3px; }
.tag-input .tag { cursor: default; }
.tag-input .tag .x { cursor: pointer; color: var(--text-4); display: inline-flex; }
.tag-input .tag .x:hover { color: var(--c-red); }
.rel-chip { cursor: pointer; transition: border-color var(--t-fast), color var(--t-fast); }
.rel-chip:hover { border-color: var(--accent-soft-2); color: var(--accent-text); }
.relation-input .rel-menu { max-height: 220px; overflow-y: auto; }

/* score input */
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input[type=range] { flex: 1; accent-color: var(--accent); }
.range-row .rv { font-variant-numeric: tabular-nums; min-width: 28px; text-align: right; font-weight: 600; }

/* ============================================================
   Command palette
   ============================================================ */
.palette-overlay {
  position: fixed; inset: 0; z-index: 200; display: flex; justify-content: center;
  align-items: flex-start; padding-top: 12vh; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(5px); animation: fade var(--t-fast) var(--ease);
}
.palette {
  width: 100%; max-width: 620px; background: var(--elevated);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); overflow: hidden; animation: pop var(--t) var(--ease);
}
.palette-input { display: flex; align-items: center; gap: 11px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.palette-input .ico { width: 18px; height: 18px; color: var(--text-3); }
.palette-input input { flex: 1; background: none; border: none; outline: none; font-size: 16px; color: var(--text); }
.palette-input input::placeholder { color: var(--text-4); }
.palette-results { max-height: 52vh; overflow-y: auto; padding: 8px; }
.palette-group { padding: 10px 12px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-4); }
.palette-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--r);
  cursor: pointer; color: var(--text-2);
}
.palette-item .ico { width: 16px; height: 16px; color: var(--text-3); flex: 0 0 16px; }
.palette-item .pi-main { flex: 1; min-width: 0; }
.palette-item .pi-title { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .pi-sub { font-size: 11.5px; color: var(--text-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .pi-hint { font-size: 11px; color: var(--text-4); }
.palette-item.active { background: var(--accent-soft); color: var(--text); }
.palette-item.active .ico { color: var(--accent-text); }
.palette-empty { padding: 30px; text-align: center; color: var(--text-4); font-size: 13px; }
.palette-foot { display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-4); }
.palette-foot span { display: inline-flex; align-items: center; gap: 6px; }

/* dropdown (filter menu) */
.dropdown {
  position: absolute; z-index: 120; margin-top: 6px; min-width: 200px;
  background: var(--elevated); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg); padding: 6px; animation: pop var(--t-fast) var(--ease);
}
.dropdown .dd-item { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: var(--r-sm); cursor: pointer; font-size: 13px; }
.dropdown .dd-item:hover { background: var(--hover); }
.dropdown .dd-check { width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; flex: 0 0 15px; }
.dropdown .dd-item.on .dd-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.dropdown .dd-item .dd-check .ico { width: 11px; height: 11px; opacity: 0; }
.dropdown .dd-item.on .dd-check .ico { opacity: 1; }
.dropdown .dd-foot { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }

/* ============================================================
   Toast
   ============================================================ */
.toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  background: var(--elevated); border: 1px solid var(--border-strong); border-radius: var(--r);
  box-shadow: var(--shadow-lg); color: var(--text); font-size: 13px; max-width: 340px;
  animation: toastIn var(--t-slow) var(--ease);
}
.toast.out { animation: toastOut var(--t) var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }
.toast .ico { width: 16px; height: 16px; }
.toast.success .ico { color: var(--c-green); }
.toast.error .ico { color: var(--c-red); }
.toast .undo { margin-left: 6px; color: var(--accent-text); font-weight: 500; cursor: pointer; }

/* ============================================================
   Dashboard
   ============================================================ */
.dash-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
  transition: border-color var(--t), transform var(--t);
}
.stat:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.stat .s-top { display: flex; align-items: center; justify-content: space-between; }
.stat .s-label { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.stat .s-ico { width: 30px; height: 30px; border-radius: var(--r); display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.stat .s-ico .ico { width: 16px; height: 16px; }
.stat .s-value { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat .s-sub { font-size: 12px; color: var(--text-4); }
.stat .s-trend { font-size: 12px; font-weight: 500; }
.stat .s-trend.up { color: var(--c-green); }
.stat .s-trend.down { color: var(--c-red); }

.dash-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-top: 14px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 9px; padding: 14px 16px 12px; }
.panel-head .ico { width: 16px; height: 16px; color: var(--text-3); }
.panel-head h3 { font-family: var(--font-serif); font-size: 15.5px; font-weight: 400; }
.panel-head .ph-action { margin-left: auto; }
.panel-body { padding: 4px 16px 16px; }

.health-ring { display: flex; align-items: center; gap: 18px; }
.ring { position: relative; width: 96px; height: 96px; flex: 0 0 96px; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 23px; font-weight: 600; font-variant-numeric: tabular-nums; }
.health-break { flex: 1; display: flex; flex-direction: column; gap: 9px; }
.hb-item { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.hb-item .hb-label { width: 92px; color: var(--text-3); }
.hb-item .track { flex: 1; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.hb-item .fill { height: 100%; border-radius: 6px; }
.hb-item .hb-val { width: 34px; text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }

.pipe-row { display: flex; flex-direction: column; gap: 12px; }
.pipe-stage { display: flex; align-items: center; gap: 10px; }
.pipe-stage .ps-label { width: 110px; font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 7px; }
.pipe-stage .ps-bar { flex: 1; height: 22px; border-radius: 6px; background: var(--surface-2); overflow: hidden; position: relative; }
.pipe-stage .ps-fill { height: 100%; border-radius: 6px; min-width: 2px; transition: width var(--t-slow) var(--ease); }
.pipe-stage .ps-num { width: 26px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13px; }

.task-list { display: flex; flex-direction: column; }
.task-row { display: flex; align-items: center; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--border-faint); cursor: pointer; }
.task-row:last-child { border-bottom: none; }
.task-row:hover .tr-title { color: var(--accent-text); }
.checkbox { width: 17px; height: 17px; border-radius: 5px; border: 1.6px solid var(--border-strong); flex: 0 0 17px; display: grid; place-items: center; transition: all var(--t-fast); }
.checkbox:hover { border-color: var(--accent); }
.checkbox.done { background: var(--accent); border-color: var(--accent); color: #fff; }
.checkbox .ico { width: 12px; height: 12px; opacity: 0; }
.checkbox.done .ico { opacity: 1; }
.task-row .tr-main { flex: 1; min-width: 0; }
.task-row .tr-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color var(--t-fast); }
.task-row.is-done .tr-title { color: var(--text-4); text-decoration: line-through; }
.task-row .tr-meta { font-size: 11.5px; color: var(--text-4); }

.goal-row { display: flex; align-items: center; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--border-faint); }
.goal-row:last-child { border-bottom: none; }
.goal-row .g-text { flex: 1; }
.goal-row.done .g-text { color: var(--text-4); text-decoration: line-through; }
.goal-row .g-del { opacity: 0; }
.goal-row:hover .g-del { opacity: 1; }
.goal-add { display: flex; gap: 8px; margin-top: 12px; }

.section-title {
  font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-4); margin: 30px 0 14px; display: flex; align-items: center; gap: 10px;
}
.section-title::before { content: ""; width: 22px; height: 1px; background: var(--text-4); display: block; }

/* settings */
.settings-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 18px; margin-bottom: 14px; }
.settings-card h3 { font-family: var(--font-serif); font-size: 16.5px; font-weight: 400; margin-bottom: 4px; }
.settings-card .sc-desc { color: var(--text-3); font-size: 13px; margin-bottom: 16px; }
.setting-row { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-top: 1px solid var(--border-faint); }
.setting-row:first-of-type { border-top: none; }
.setting-row .sr-main { flex: 1; }
.setting-row .sr-title { font-weight: 500; font-size: 13.5px; }
.setting-row .sr-sub { color: var(--text-4); font-size: 12px; margin-top: 1px; }
.swatches { display: flex; gap: 9px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: var(--r); cursor: pointer; border: 2px solid transparent; transition: transform var(--t-fast); position: relative; }
.swatch:hover { transform: scale(1.08); }
.swatch.active { border-color: var(--text); }
.swatch.active::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-sm); border: 2px solid var(--bg); }
.stat-mini { display: flex; gap: 22px; flex-wrap: wrap; }
.stat-mini .sm { display: flex; flex-direction: column; }
.stat-mini .sm .n { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-mini .sm .l { font-size: 12px; color: var(--text-4); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-row { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  :root { --sidebar-w: 248px; }
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform var(--t) var(--ease); box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,0.5); }
  .menu-btn { display: inline-grid; }
  .search-trigger { min-width: 0; }
  .search-trigger .ph, .search-trigger .kbd { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .page { padding: 18px 16px 80px; }
  .topbar { padding: 0 14px; }
}
@media (max-width: 560px) {
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .stat .s-value { font-size: 23px; }
  .crumb-sub { display: none; }
}
