/* Paws design tokens, FigCraft v11. Light mode first.
   Dark tokens are defined under [data-theme="dark"] for milestone 1.2;
   nothing in Phase 01 sets data-theme, so the app renders light. */

:root {
  --paper: #FAF7F2;
  --surface: #FFFFFF;
  --surface-warm: #F3EFE7;
  --border: #E7DFD2;
  --ink: #221D17;
  --ink-2: #57534A;
  --muted: #6E6759;
  --accent: #00D9FF;
  --accent-text: #0B7285;
  --mus: #0B7285;
  --meow: #C84870;
  --arya: #B45309;
  --success: #15803D;
  --hand: #9A3050;
  --info: #1D4ED8;
  --danger: #DC2626;
  --danger-text: #991B1B;
  --meow-soft: #FCE6EC;
  --danger-soft: #FEE2E2;
  --warning-soft: #FEF3C7;
  --success-soft: #DCFCE7;
  --info-soft: #DBEAFE;
  --sidebar-bg: #221D17;
  --sidebar-text: #EDE7DA;
  --sidebar-muted: #A39A87;
  --presence-online: #15803D;
  --presence-working: #B45309;
  --presence-away: #8A8375;
  --font-ui: "Inter", "Geist Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-editorial: Georgia, "Times New Roman", serif;
  --font-code: "JetBrains Mono", "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --radius-card: 8px;
  --radius-control: 6px;
  --radius-badge: 4px;
  --sidebar-width: 248px;
  --topbar-height: 56px;
  --content-margin: 24px;
  --content-gutter: 16px;
  /* Gerak tokens, FigCraft v13 (Design System panel Motion + Gerak):
     ease-out for all UI motion, press 100-160ms, popover 125-200ms. */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

/* Dark tokens from FigCraft v3. Text variants are the lightened ones
   (Arya #E8A15C, mus #6FC9DC, Meow #F08AA8, success #4ADE80,
   warning #F5B544, danger #F87171, info #7CB3F5, muted #A39A87),
   because the light member colors as text on dark fail WCAG AA. */
[data-theme="dark"] {
  --paper: #1E1A15;
  --surface: #2A251F;
  --surface-warm: #332C24;
  --border: #453B2F;
  --ink: #F3EFE7;
  --ink-2: #D8CFC0;
  --muted: #A39A87;
  --accent-text: #6FC9DC;
  --mus: #6FC9DC;
  --meow: #F08AA8;
  --arya: #E8A15C;
  --success: #4ADE80;
  --danger: #F87171;
  --danger-text: #F87171;
  --info: #7CB3F5;
  --sidebar-text: #F3EFE7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
}

a { color: var(--accent-text); text-decoration: none; }
h1, h2, h3 { margin: 0; }
p { margin: 0 0 8px; }
ul { margin: 0; padding-left: 16px; }
button { font-family: var(--font-ui); font-size: 13px; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.6; }
input, label { font-family: var(--font-ui); font-size: 13px; }
kbd {
  font-family: var(--font-code);
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-badge);
  padding: 0 4px;
  color: var(--muted);
}
.muted { color: var(--muted); }

/* Shell: sidebar 248px, topbar 56px, 8px grid, gutter 16, margin 24. */
.shell { display: flex; min-height: 100vh; }
.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content {
  flex: 1;
  padding: var(--content-margin);
  max-width: 1144px;
  width: 100%;
  margin: 0 auto;
}
.shell-footer {
  padding: 16px 24px 24px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* Sidebar, dark surface as the navigation identity. */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 16px 16px 8px; }
.brand-mark {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border-radius: var(--radius-control);
}
.brand-mark img { display: block; width: 32px; height: 32px; }
.brand-name { display: block; font-size: 16px; font-weight: 700; color: #FFFFFF; }
.brand-tagline { display: block; font-size: 11px; color: var(--sidebar-muted); }
.sidebar-search {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 16px 16px; padding: 6px 8px;
  border: 1px solid #453B2F; border-radius: var(--radius-control);
  color: var(--sidebar-muted);
}
.sidebar-search kbd { margin-left: auto; border-color: #453B2F; color: var(--sidebar-muted); }
.sidebar-nav { flex: 1; padding: 0 8px; }
.workspace-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; margin-top: 8px;
  font-size: 14px; font-weight: 700; color: #FFFFFF;
}
.workspace-row .icon { margin-left: auto; color: var(--sidebar-muted); }
.nav-section-label {
  margin: 24px 8px 8px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--sidebar-muted);
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: var(--radius-control);
  color: var(--sidebar-text);
}
.nav-item a {
  display: flex; align-items: center; gap: 8px;
  color: inherit; flex: 1; min-width: 0;
}
.nav-item a:hover { text-decoration: none; }
.nav-item.active { background: rgba(255, 255, 255, 0.12); color: #FFFFFF; }
.nav-item.disabled { color: var(--sidebar-muted); }
.nav-children { margin-left: 16px; }
.nav-badge {
  margin-left: auto;
  background: var(--danger); color: #FFFFFF;
  font-size: 9px; font-weight: 700;
  border-radius: 8px; padding: 1px 6px;
}
.nav-tag {
  margin-left: auto;
  font-size: 10px; color: var(--sidebar-muted);
  border: 1px solid #453B2F; border-radius: var(--radius-badge);
  padding: 0 4px;
}
.online-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; min-height: 32px; }
.online-name { color: var(--sidebar-text); }
.online-status { margin-left: auto; font-size: 11px; color: var(--sidebar-muted); }
.presence-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.presence-dot.online { background: var(--presence-online); }
.presence-dot.working { background: var(--presence-working); }
.presence-dot.away { background: var(--presence-away); }
.presence-dot.offline { background: #57534A; }
.sidebar-footer {
  display: flex; align-items: center; gap: 8px;
  margin: 16px; padding: 12px;
  border: 1px solid #453B2F; border-radius: var(--radius-card);
  color: var(--sidebar-muted); font-size: 12px;
}
.sidebar-footer strong { color: var(--sidebar-text); }
.sidebar-backdrop { display: none; }

/* Topbar, 56px. */
.topbar {
  height: var(--topbar-height);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: transparent; border: none; border-radius: var(--radius-control);
  color: var(--ink-2);
}
.hamburger { display: none; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  flex: 1; max-width: 480px;
  padding: 6px 8px;
  border: 1px solid var(--border); border-radius: var(--radius-control);
  background: var(--surface-warm); color: var(--muted);
}
.topbar-search input {
  flex: 1; min-width: 0;
  border: none; outline: none; background: transparent; color: var(--ink);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.bell { position: relative; }
.bell-badge {
  position: absolute; top: 2px; right: 2px;
  background: var(--danger); color: #FFFFFF;
  font-size: 9px; font-weight: 700; line-height: 1;
  border-radius: 8px; padding: 2px 4px;
}
.topbar-user { display: flex; align-items: center; gap: 8px; font-weight: 600; }

/* Shared bits. */
.icon { display: inline-flex; flex-shrink: 0; }
.icon svg { width: var(--icon-size, 16px); height: var(--icon-size, 16px); }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #FFFFFF; font-weight: 700; flex-shrink: 0;
}
.page { display: flex; flex-direction: column; gap: var(--content-gutter); }
.page-header { margin-bottom: 8px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { color: var(--muted); margin: 4px 0 0; }
.phase-note {
  background: var(--warning-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 8px 12px;
  color: var(--ink-2);
}
.panel-title { font-size: 15px; font-weight: 600; }
.panel-title-spaced { margin-top: 16px; }
.panel-subtitle { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); margin: 12px 0 4px; }
.panel-foot { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--content-gutter); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--content-gutter); }
.list-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row-title { flex: 1; min-width: 0; }
.list-row-title.done { text-decoration: line-through; color: var(--muted); }
.list-row-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.badge {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  border-radius: var(--radius-badge);
  padding: 1px 6px;
  background: var(--surface-warm); color: var(--ink-2);
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--arya); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.btn {
  padding: 6px 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--radius-control);
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.pill {
  padding: 6px 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 16px;
}
.pill-primary { background: var(--ink); color: #FFFFFF; border-color: var(--ink); font-weight: 600; }
.chip {
  display: inline-block;
  margin: 0 4px 4px 0; padding: 2px 8px;
  background: var(--surface-warm); border-radius: var(--radius-badge);
  font-size: 11px; color: var(--ink-2);
}
.progress {
  display: inline-block; vertical-align: middle;
  width: 96px; height: 6px;
  background: var(--surface-warm); border-radius: 4px;
  overflow: hidden; margin-right: 8px;
}
.progress-wide { display: block; width: 100%; margin: 8px 0; }
.progress-bar { display: block; height: 100%; background: var(--accent-text); border-radius: 4px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); }
.table th { font-size: 11px; color: var(--muted); }
.toggle-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }

/* Dashboard. */
.hero-eyebrow {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--accent-text);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 2px 10px; margin-bottom: 8px;
}
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.kpi-strip {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: var(--content-gutter);
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  display: flex; align-items: baseline; gap: 8px;
}
.kpi-value { font-size: 22px; font-weight: 700; }
.kpi-label { color: var(--muted); }
.kpi-delta { color: var(--success); font-size: 12px; font-weight: 600; }

/* Project page. */
.project-hero-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 8px; }
.resource-card { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.disabled-card { opacity: 0.7; }

/* Room. */
.room-layout { display: grid; grid-template-columns: 1fr 288px; gap: var(--content-gutter); align-items: start; }
.message { padding: 12px 0; border-bottom: 1px solid var(--border); }
.message-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.message-text { margin: 0 0 0 34px; }
.message-agent {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px;
  margin-bottom: 8px;
}
.message-agent .message-text { margin-left: 0; }
.work-card { border-left: 4px solid var(--meow); }
.composer { margin-top: 16px; display: flex; flex-direction: column; gap: 4px; }
.composer input {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-control);
  background: var(--surface); color: var(--ink);
}
.composer-hint { font-size: 11px; color: var(--muted); }
.room-context p { margin-bottom: 8px; }

/* Board. */
.board-toolbar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }
.view-switcher, .board-actions { display: flex; gap: 8px; }
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--content-gutter); align-items: start; }
.kanban-col {
  background: var(--surface-warm);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px;
}
.kanban-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.task-tag {
  display: inline-block; font-size: 11px;
  background: var(--info-soft); color: var(--info);
  border-radius: var(--radius-badge); padding: 1px 6px; margin-bottom: 8px;
}
.kanban-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }

/* Notes. */
.doc-breadcrumb { color: var(--muted); font-size: 12px; }
.doc-title { font-family: var(--font-editorial); font-size: 30px; font-weight: 700; }
.doc-props { color: var(--muted); font-size: 12px; }
.wiki-link { color: var(--accent-text); font-weight: 600; }
.doc-callout {
  background: var(--info-soft);
  border-left: 4px solid var(--info);
  border-radius: var(--radius-badge);
  padding: 8px 12px;
}

/* Agents. */
.org-strip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px 16px;
}
.agent-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--content-gutter); }
.agent-card { display: flex; flex-direction: column; gap: 4px; }
.agent-head { display: flex; gap: 12px; align-items: center; margin-bottom: 4px; }
.agent-list { margin: 0 0 4px; }

/* Aurora: empty state only, never a page background. Reserved for
   the Workspace Shell empty state in a later phase. */
.aurora { position: relative; overflow: hidden; }
.aurora::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 40% 30% at 30% 40%, rgba(200, 72, 112, 0.25), transparent),
    radial-gradient(ellipse 40% 30% at 70% 50%, rgba(180, 83, 9, 0.2), transparent),
    radial-gradient(ellipse 40% 30% at 50% 70%, rgba(0, 217, 255, 0.25), transparent);
  pointer-events: none;
}

/* Gerak (FigCraft v13): press scale 0.97, focus ring 2px #00D9FF,
   transform/opacity only, never transition: all. Hover only on
   devices that really hover. The Command Palette opens with NO
   animation (it is used 100+ times a day); its overlay and dialog
   carry no transition or animation rule anywhere in this file. */
button, .btn, .pill, .icon-button {
  transition: transform 100ms var(--ease-out), border-color 125ms var(--ease-out), background-color 125ms var(--ease-out);
}
button:active, .btn:active, .pill:active, .icon-button:active { transform: scale(0.97); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { border-color: var(--accent); }
  .pill:hover { border-color: var(--accent); }
  .icon-button:hover { background: var(--surface-warm); }
  .nav-item:hover { background: rgba(255, 255, 255, 0.08); }
  a:hover { text-decoration: underline; }
}

/* Stagger (FigCraft v13): list rows enter 30-80ms apart, opacity +
   translateY 8px, never blocking interaction. Applied with the
   .stagger class on Board/List, Agent Directory, Persetujuan, and
   Routines lists. */
.stagger > * { animation: paws-row-in 200ms var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 50ms; }
.stagger > *:nth-child(3) { animation-delay: 100ms; }
.stagger > *:nth-child(4) { animation-delay: 150ms; }
.stagger > *:nth-child(5) { animation-delay: 200ms; }
.stagger > *:nth-child(6) { animation-delay: 250ms; }
.stagger > *:nth-child(n+7) { animation-delay: 300ms; }
@keyframes paws-row-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* prefers-reduced-motion: movement off, opacity kept. */
@media (prefers-reduced-motion: reduce) {
  .stagger > * { animation: none; }
  button, .btn, .pill, .icon-button { transition: none; }
  .sidebar { transition: none; }
}

/* Phase 04: confirmation modal (audit v11 D2), undo toast, and the
   selected delegate-agent card. */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(34, 29, 23, 0.5);
}
.modal {
  width: min(480px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
}
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 110;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  max-width: min(560px, 92vw);
  background: var(--ink); color: var(--surface);
  border-radius: var(--radius-card);
  padding: 12px 16px;
}
.selected-agent { border-color: var(--accent) !important; }
.agent-card-link { color: inherit; display: block; }
.agent-card-link:hover { text-decoration: none; }
.agent-card-link .agent-card:hover { border-color: var(--accent); }
.kpi-value, .nav-badge, .bell-badge { font-variant-numeric: tabular-nums; }

/* Responsive: sidebar becomes a drawer, context becomes a sheet. */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .agent-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban { grid-template-columns: repeat(2, 1fr); }
  .room-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  /* D1/D4 (audit v11): drawer rows keep their 24px visual pitch,
     but each nav link gets an invisible >=44px hit area; buttons
     and pills get a 44px minimum height on touch layouts only. */
  .sidebar .nav-item a { position: relative; }
  .sidebar .nav-item a::after {
    content: "";
    position: absolute; left: 0; right: 0; top: -10px; bottom: -10px;
  }
  .btn, .pill { min-height: 44px; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.visible {
    display: block;
    position: fixed; inset: 0;
    background: rgba(34, 29, 23, 0.5);
    z-index: 35;
  }
  .hamburger { display: inline-flex; }
  .topbar { padding: 0 16px; gap: 8px; }
  .topbar-search { display: none; }
  .content { padding: 16px; }
  .grid-2, .grid-3, .agent-grid { grid-template-columns: 1fr; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .kanban { grid-template-columns: 1fr; }
}

/* Phase 05: auth pages and the SSE Live indicator. Same tokens as
   the shell: paper background, surface card, ink text, border. */
.auth-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--paper);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
}
.auth-label {
  display: block;
  margin-top: 16px;
  font-weight: 600;
}
.auth-input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}
.auth-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}
.auth-error {
  color: var(--danger-text);
  font-size: 13px;
  margin: 12px 0 0;
}
.auth-submit {
  margin-top: 16px;
  width: 100%;
}
.live-dot {
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  border: 1px solid var(--success);
  border-radius: 4px;
  padding: 2px 6px;
}
