/* Otto — dark "presence" aesthetic. Someone on the other side of the screen. */

:root {
  --bg: #0a0e14;
  --panel: #11161f;
  --panel-2: #161c28;
  --raised: #1c2431;
  --border: #232c3b;
  --text: #e6edf3;
  --dim: #8b97a7;
  --faint: #5a6675;
  --accent: #5ee0c2;        /* Otto's teal presence */
  --accent-dim: #2f7d6e;
  --rot: #e0a35e;           /* aging / quest rot */
  --stale: #e0685e;         /* stale */
  --danger: #e0685e;
  --radius: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', 'Cascadia Code', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.dim { color: var(--dim); }
.link-quiet { color: var(--dim); font-size: 13px; }
.link-quiet:hover { color: var(--accent); }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 14px;
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-word strong { display: block; font-size: 18px; letter-spacing: 0.5px; }
.brand-word small { color: var(--dim); font-size: 11px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--dim); font-weight: 500;
}
.nav-link:hover { background: var(--raised); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--raised); color: var(--accent); }
.nav-link .ico { width: 16px; text-align: center; opacity: 0.85; }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.who { font-size: 12px; color: var(--dim); margin-bottom: 4px; }
.logout { font-size: 12px; color: var(--faint); }

.main { overflow-y: auto; padding: 28px 32px; }

/* ---------- Presence orb ---------- */
.orb {
  display: block; width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent), var(--accent-dim) 70%);
  box-shadow: 0 0 12px 2px rgba(94, 224, 194, 0.45);
  animation: breathe 3.6s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.85; box-shadow: 0 0 10px 1px rgba(94,224,194,0.35); }
  50%      { transform: scale(1.12); opacity: 1;  box-shadow: 0 0 16px 4px rgba(94,224,194,0.55); }
}
.brand-glyph[data-state="working"] .orb { animation-duration: 1.1s; }
.brand-glyph[data-state="watching"] .orb {
  background: radial-gradient(circle at 35% 30%, var(--accent), var(--accent-dim) 70%);
}
.brand-glyph[data-state="needs-decision"] .orb {
  background: radial-gradient(circle at 35% 30%, var(--rot), #8a5a25 70%);
  box-shadow: 0 0 14px 3px rgba(224, 163, 94, 0.5);
  animation-duration: 1.8s;
}

/* ---------- Login ---------- */
.login-body { display: grid; place-items: center; height: 100vh; }
.login { text-align: center; max-width: 360px; }
.login-orb { display: grid; place-items: center; margin-bottom: 20px; }
.login-orb .orb { width: 56px; height: 56px; }
.login h1 { font-size: 40px; margin: 8px 0 4px; letter-spacing: 1px; }
.tagline { color: var(--dim); margin-bottom: 28px; }
.btn-signin {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--raised); border: 1px solid var(--border);
  padding: 12px 20px; border-radius: var(--radius); color: var(--text); font-weight: 500;
}
.btn-signin:hover { border-color: var(--accent); text-decoration: none; }
.ms-mark { width: 16px; height: 16px; background:
  linear-gradient(90deg, #f25022 50%, #7fba00 50%) top / 100% 50% no-repeat,
  linear-gradient(90deg, #00a4ef 50%, #ffb900 50%) bottom / 100% 50% no-repeat;
  display: inline-block; }
.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 18px; font-size: 13px; }
.notice.error { background: rgba(224,104,94,0.12); color: var(--stale); }

/* ---------- Panels ---------- */
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.panel-head h2 { margin: 0; font-size: 22px; }
.panel-head p { margin: 4px 0 0; }

/* ---------- Home split ---------- */
.home { display: grid; grid-template-columns: 1fr 380px; gap: 24px; height: calc(100vh - 56px); }
.chat-panel { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 28px; }
.chat-hello { max-width: 460px; margin: 40px auto; text-align: center; }
.hello-orb { display: grid; place-items: center; margin-bottom: 18px; }
.hello-orb .orb { width: 40px; height: 40px; }
.chat-hello p { line-height: 1.55; }
.chat-input { display: flex; gap: 8px; padding: 14px; border-top: 1px solid var(--border); }
.chat-input input { flex: 1; }
.chat-input input:disabled { opacity: 0.5; }

.queue-panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; overflow-y: auto; }
.queue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.queue-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; }
.q-score { font-family: var(--mono); font-size: 12px; color: var(--accent); min-width: 26px; text-align: center; }
.q-title { flex: 1; }

/* ---------- Inputs ---------- */
input[type="text"], input[type="date"], select, textarea {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 9px 11px; border-radius: 8px; font-family: var(--font); font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-dim); }
button {
  background: var(--accent); color: #05221c; border: none; font-weight: 600;
  padding: 9px 16px; border-radius: 8px; cursor: pointer; font-family: var(--font);
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.45; cursor: default; }

/* ---------- Tasks ---------- */
.capture { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.capture input[type="text"] { flex: 1; min-width: 240px; }

.horizons { display: flex; flex-direction: column; gap: 22px; }
.horizon-head { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.horizon-head .count { background: var(--raised); color: var(--faint); font-size: 11px; padding: 1px 7px; border-radius: 10px; }
.horizon-group { display: flex; flex-direction: column; gap: 6px; }
.empty-mini { padding: 6px 2px; font-size: 13px; }

.task-row { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.task-row:hover { border-color: var(--accent-dim); }
.check { background: transparent; border: 1.5px solid var(--faint); color: transparent; width: 22px; height: 22px; border-radius: 50%; padding: 0; display: grid; place-items: center; font-size: 12px; }
.check:hover { border-color: var(--accent); color: var(--accent); }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 500; outline: none; border-radius: 4px; padding: 1px 2px; }
.task-title:focus { background: var(--panel-2); }
.task-meta { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; align-items: center; }
.chip { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--raised); color: var(--dim); }
.chip.waiting { color: var(--rot); } .chip.due { color: var(--accent); }
.task-actions { display: flex; align-items: center; gap: 6px; }
.horizon-select { padding: 4px 6px; font-size: 12px; }
.drop { background: transparent; color: var(--faint); padding: 4px 8px; }
.drop:hover { color: var(--danger); }

/* ---------- Aging badges ---------- */
.age { font-size: 11px; font-family: var(--mono); padding: 1px 6px; border-radius: 5px; }
.age-fresh { color: var(--faint); }
.age-aging { color: var(--rot); background: rgba(224,163,94,0.10); }
.age-stale { color: var(--stale); background: rgba(224,104,94,0.12); }

/* ---------- Boundaries ---------- */
.boundary-form { display: flex; gap: 8px; margin: 18px 0; flex-wrap: wrap; }
.boundary-form input[type="text"] { flex: 1; min-width: 160px; }
.boundary-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 32px; }
.boundary-row { display: grid; grid-template-columns: 90px 1fr 80px 2fr auto; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.boundary-row.disabled { opacity: 0.5; }
.rule-type { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; padding: 2px 6px; border-radius: 5px; text-align: center; }
.rule-read_deny { background: rgba(94,224,194,0.12); color: var(--accent); }
.rule-action_deny { background: rgba(224,104,94,0.12); color: var(--stale); }
.rule-disclosure_deny { background: rgba(224,163,94,0.12); color: var(--rot); }
.rule-pattern { font-family: var(--mono); font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.rule-scope { font-size: 12px; color: var(--dim); }
.rule-actions { display: flex; gap: 6px; }
.toggle { background: var(--raised); color: var(--dim); font-size: 12px; padding: 4px 12px; }
.boundary-row:not(.disabled) .toggle { color: var(--accent); }
.del { background: transparent; color: var(--faint); padding: 4px 8px; }
.del:hover { color: var(--danger); }

.blocks h3 { font-size: 14px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; }
.block-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.block-list li { display: flex; gap: 12px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.block-when { color: var(--faint); font-family: var(--mono); font-size: 12px; }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 30px 10px; color: var(--dim); }
.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 18px; border-radius: 8px; background: var(--raised); z-index: 50; }
.toast.error { background: rgba(224,104,94,0.15); color: var(--stale); border: 1px solid var(--stale); }
.error-page { max-width: 480px; margin: 60px auto; text-align: center; }

/* ---------- Mobile chrome (hidden on desktop) ---------- */
.topbar, .tabbar { display: none; }

.topbar {
  align-items: center; gap: 12px;
  padding: 10px 16px; background: rgba(17, 22, 31, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.topbar-glyph .orb { width: 18px; height: 18px; }
.topbar-glyph[data-state="needs-decision"] .orb {
  background: radial-gradient(circle at 35% 30%, var(--rot), #8a5a25 70%);
  box-shadow: 0 0 12px 3px rgba(224,163,94,0.5);
}
.topbar-word { flex: 1; min-width: 0; line-height: 1.1; }
.topbar-word strong { font-size: 17px; letter-spacing: 0.5px; }
.topbar-word small { display: block; color: var(--dim); font-size: 11px; }
.topbar-logout { color: var(--faint); font-size: 22px; text-decoration: none; padding: 6px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: rgba(17, 22, 31, 0.95); border-top: 1px solid var(--border);
  backdrop-filter: blur(8px);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 7px; color: var(--dim); text-decoration: none; font-size: 11px;
  min-height: 52px; justify-content: center;
}
.tab.active { color: var(--accent); }
.tab-ico { font-size: 20px; line-height: 1; }
.tab:active { background: var(--raised); }

/* ---------- Mobile layout ---------- */
@media (max-width: 768px) {
  .app { display: block; height: auto; }
  .sidebar { display: none; }
  .topbar { display: flex; }
  .tabbar { display: flex; }

  .main {
    padding: calc(58px + env(safe-area-inset-top)) 16px calc(70px + env(safe-area-inset-bottom));
    overflow: visible; height: auto;
  }

  /* Inputs at 16px so iOS doesn't zoom on focus; taller touch targets. */
  input[type="text"], input[type="date"], select, textarea { font-size: 16px; padding: 12px; }
  button { min-height: 44px; }

  .panel-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .panel-head h2 { font-size: 20px; }

  /* Home: stack chat + queue instead of side-by-side. */
  .home { display: flex; flex-direction: column; gap: 16px; height: auto; }
  .chat-panel { min-height: 260px; }
  .chat-hello { margin: 24px auto; }
  .queue-panel { overflow: visible; }

  /* Tasks: stacked capture form, roomier rows. */
  .capture { flex-direction: column; gap: 10px; }
  .capture input[type="text"], .capture select, .capture input[type="date"], .capture button { width: 100%; min-width: 0; }

  .horizons { gap: 26px; }
  .task-row { gap: 10px; padding: 12px; align-items: flex-start; }
  .check { width: 30px; height: 30px; font-size: 14px; flex-shrink: 0; }
  .task-title { font-size: 15px; }
  .task-actions { flex-direction: column; align-items: flex-end; gap: 8px; }
  .horizon-select { min-height: 36px; }
  .drop { font-size: 18px; padding: 6px 10px; }

  /* Boundaries: each rule becomes a stacked card. */
  .boundary-form { flex-direction: column; }
  .boundary-form input[type="text"], .boundary-form select, .boundary-form button { width: 100%; }
  .boundary-row { grid-template-columns: 1fr; gap: 6px; padding: 14px; }
  .rule-type { justify-self: start; }
  .rule-actions { justify-content: flex-end; }
  .block-list li { flex-direction: column; gap: 2px; }

  .toast { left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); text-align: center; }
}

/* Small phones */
@media (max-width: 380px) {
  .main { padding-left: 12px; padding-right: 12px; }
  .topbar-word strong { font-size: 16px; }
}
