/* Component layer. Colors, radius, type, space, motion: tokens.css only. */
@import "./tokens.css";

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: var(--text-body);
  line-height: var(--leading);
  background: var(--bg);
  color: var(--fg);
  letter-spacing: var(--tracking);
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: var(--text-h1); }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h3); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.omni-shell {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  min-height: 100svh;
}
.omni-shell:has(.inbox-page),
.omni-shell.inbox-page {
  height: 100svh;
  overflow: hidden;
  grid-template-columns: var(--nav-w) 1fr;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px var(--space-2);
  border-right: 1px solid var(--pane-border);
  background: var(--card);
  overflow: auto;
}
.nav-brand {
  font-weight: 600;
  padding: 6px var(--space-2) 10px;
  font-size: 14px;
}
.nav-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: var(--space-2) var(--space-2) var(--space-1);
}
.nav-item {
  display: block;
  padding: 5px var(--space-2);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
}
.nav-item:hover { background: var(--hover-fill); text-decoration: none; }
.nav-item.active { background: var(--active-fill); font-weight: 600; }
.nav-sub {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 8px 10px;
}
.nav-sub .nav-item { font-size: 12px; padding: 3px var(--space-2); }
.nav-search { padding: 4px var(--space-2) 2px; }
.nav-search input { font-size: 12px; padding: 4px 6px; }
.nav-foot {
  margin-top: auto;
  padding: 10px var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.main { padding: 14px 18px 32px; overflow: auto; }
.main-head { margin-bottom: var(--space-3); }

.inbox {
  display: grid;
  grid-template-columns: minmax(220px, 28%) 1fr minmax(180px, 22%);
  min-height: 100svh;
  height: 100svh;
}
.pane {
  border-right: 1px solid var(--pane-border);
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.pane.rail { border-right: 0; padding: var(--space-3); }
.pane-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-2) 10px;
  border-bottom: 1px solid var(--pane-border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}
.list-pane { background: var(--card); }
.thread-item {
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: var(--space-2);
  padding: var(--space-2) 10px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.thread-item:hover { background: var(--hover-fill); text-decoration: none; }
.thread-item.sel { background: var(--sel-fill); }
.thread-item .dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  margin-top: 6px;
  background: var(--accent);
}
.snippet { font-size: 12px; max-height: 2.6em; overflow: hidden; }

.messages {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
  background: var(--chat-canvas);
}
.bubble {
  max-width: 72%;
  padding: var(--space-2) 11px;
  border-radius: var(--chat-bubble-radius);
  background: var(--chat-received);
}
.bubble.me { align-self: flex-end; background: var(--chat-sent); color: #fff; }
.bubble.them { align-self: flex-start; }
.bubble.me + .bubble.me {
  border-top-right-radius: var(--chat-bubble-cluster-radius);
}
.bubble.them + .bubble.them {
  border-top-left-radius: var(--chat-bubble-cluster-radius);
}
.bubble .who { font-size: var(--text-tiny); font-weight: 600; margin-bottom: 2px; }
.bubble .body { white-space: pre-wrap; word-break: break-word; }
.dump-page .bubble { max-width: 100%; }

.compose {
  padding: var(--space-2) 10px;
  border-top: 1px solid var(--pane-border);
  display: flex;
  gap: var(--space-2);
  align-items: center;
  background: var(--chat-compose);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--space-1) 9px;
  cursor: pointer;
  text-decoration: none;
  transition: filter var(--motion-fast) var(--ease);
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--danger); border-color: var(--danger); }

.chip {
  display: inline-flex;
  padding: 3px var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  text-decoration: none;
}
.chip.on { background: var(--fg); color: var(--bg); border-color: transparent; }
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.avatar { border-radius: var(--radius-pill); }
.badge.owe_them { background: color-mix(in oklch, var(--warn) 25%, transparent); }
.badge.owe_us { background: color-mix(in oklch, var(--ok) 25%, transparent); }
.badge.informational { background: color-mix(in oklch, var(--accent) 22%, transparent); }

.card {
  background: var(--card);
  border: 1px solid var(--pane-border);
  border-radius: var(--radius);
  padding: 10px var(--space-3);
  box-shadow: var(--shadow);
}
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.split { display: grid; grid-template-columns: 220px 1fr 220px; gap: var(--space-3); }
@media (max-width: 960px) {
  .inbox { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .omni-shell { grid-template-columns: 1fr; }
  .nav { flex-direction: row; flex-wrap: wrap; }
}

.muted { color: var(--muted); }
.tiny { font-size: var(--text-tiny); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }
.empty { padding: var(--space-5); color: var(--muted); }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert {
  padding: var(--space-2) 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: var(--space-2) 10px;
}
.alert.ok { border-color: var(--ok); }
.alert.warn { border-color: var(--warn); }
.alert.danger { border-color: var(--danger); }

label { display: flex; flex-direction: column; gap: var(--space-1); font-size: 12px; color: var(--muted); }
input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px var(--space-2);
  width: 100%;
}
.search { flex: 1; }
.search input { width: 100%; }
form.row input { width: auto; flex: 1; }

.login-body {
  min-height: 100svh;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.login-card {
  width: min(420px, 92vw);
  background: var(--card);
  border: 1px solid var(--pane-border);
  border-radius: var(--radius);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.cal-month { margin-bottom: var(--space-4); }
.cal-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal-table th {
  font-size: var(--text-tiny);
  color: var(--muted);
  font-weight: 600;
  padding: var(--space-1);
  text-align: left;
}
.cal-td { padding: 0; border: 1px solid var(--border); }
.cal-td.out { opacity: 0.45; }
.cal-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 72px;
  height: 72px;
  padding: var(--space-1);
  background: var(--card);
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius);
}
.cal-cell.out { background: color-mix(in oklch, var(--muted) 8%, var(--card)); }
.cal-cell.today { outline: 1px solid var(--accent); outline-offset: -1px; }
.cal-cell.sel { background: color-mix(in oklch, var(--accent) 12%, var(--card)); }
.cal-cell .d { font-size: var(--text-tiny); color: var(--muted); }
.cal-count {
  font-size: var(--text-tiny);
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: var(--radius);
  background: color-mix(in oklch, var(--accent) 18%, transparent);
}
.area-chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.area-chips .chip { align-items: center; gap: 6px; color: inherit; }
.cal-day-bar { margin-bottom: var(--space-2); }
.cal-legend { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-2); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { display: inline-block; width: 8px; height: 8px; border-radius: var(--radius); }
.lg.open { background: #22c55e; }
.lg.booked { background: #2563eb; }
.lg.planned { background: #f97316; }
.cal-allday {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.cal-block.static { position: static; left: auto; right: auto; height: auto; }
.cal-day-split {
  display: flex;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
}
.cal-timeline { flex: 1; min-width: 0; overflow: auto; border-right: 1px solid var(--border); }
.cal-grid { position: relative; }
.cal-slot {
  position: absolute;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  border-bottom: 1px solid color-mix(in oklch, var(--border) 70%, transparent);
}
.cal-slot.open { background: color-mix(in oklch, #22c55e 10%, transparent); }
.cal-slot.booked, .cal-slot.planned { background: color-mix(in oklch, var(--muted) 8%, transparent); }
.cal-slot-time {
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
}
.cal-slot-hint { padding: 2px 8px; font-size: 11px; color: #166534; }
.cal-block {
  position: absolute;
  left: 4.5rem;
  right: 8px;
  z-index: 1;
  overflow: hidden;
  padding: 2px 6px;
  border-radius: var(--radius);
  font-size: 11px;
  line-height: 1.25;
  box-shadow: 0 1px 2px color-mix(in oklch, #000 12%, transparent);
}
.cal-block strong, .cal-block span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-block.booked { background: #2563eb; color: #fff; }
.cal-block.planned { background: #f97316; color: #fff; }
.cal-now {
  position: absolute;
  left: 4.5rem;
  right: 0;
  z-index: 2;
  height: 1px;
  background: var(--danger);
  pointer-events: none;
}
.cal-rail {
  width: 20rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cal-rail-head { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); }
.cal-rail-head h3 { display: flex; align-items: baseline; gap: 6px; }
.cal-rail-empty { padding: var(--space-3); }
.cal-rail-group { border-bottom: 1px solid var(--border); padding: var(--space-2); display: flex; flex-direction: column; gap: var(--space-2); }
.cal-rail-group h4 {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.cal-task {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2);
  background: var(--bg);
}
.cal-task.dragging { opacity: 0.4; }
.cal-task-body { min-width: 0; flex: 1; }
.cal-grip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 28px;
  border-radius: var(--radius);
  background: var(--hover-fill);
  color: var(--fg);
  cursor: grab;
  touch-action: none;
}
.cal-grip:active { cursor: grabbing; }
.cal-grip-icon { display: block; fill: currentColor; }
@media (max-width: 800px) {
  .cal-day-split { flex-direction: column; }
  .cal-timeline { border-right: 0; border-bottom: 1px solid var(--border); }
  .cal-rail { width: 100%; }
}

.dump-chat {
  display: flex;
  flex-direction: column;
  min-height: min(70svh, 640px);
  padding: 0;
  overflow: hidden;
}
.dump-stream {
  flex: 1;
  overflow: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--chat-canvas);
}
.dump-compose { position: sticky; bottom: 0; }
.dump-process { padding: var(--space-2) 10px; border-top: 1px solid var(--pane-border); }
.dump-older { padding: var(--space-2) 0; text-align: center; }

.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
  align-items: start;
}
.kanban-col { min-height: 160px; }
.kanban-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.kanban-cards { display: flex; flex-direction: column; gap: var(--space-2); min-height: 48px; }
.kanban-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2);
  background: var(--bg);
  cursor: grab;
}
.kanban-card:active { cursor: grabbing; }

.data-table { width: 100%; border-collapse: collapse; margin-top: var(--space-3); }
.data-table th, .data-table td {
  text-align: left;
  padding: 6px var(--space-2);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.th-sort {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.th-sort:hover { text-decoration: underline; }

.lang-switch { display: flex; gap: var(--space-1); }
.swatch-btn {
  width: 18px;
  height: 18px;
  border: 1px solid var(--pane-border);
  border-radius: var(--radius);
  padding: 0;
  cursor: pointer;
}
.swatch-btn.on { outline: 2px solid var(--focus); outline-offset: 1px; }

code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--hover-fill);
  padding: 2px var(--space-1);
  border-radius: var(--radius);
}
.eve-result { padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius); }

.swatch {
  height: 48px;
  border: 1px solid var(--pane-border);
  border-radius: var(--radius);
}
.token-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-2);
}
.demo-frame {
  border: 1px dashed var(--pane-border);
  border-radius: var(--radius);
  padding: var(--space-3);
  background: var(--bg);
}
.dont { outline: 1px solid var(--danger); }
