:root {
  --teal-900: #102326;   /* primary dark (wayl.io) */
  --teal-800: #132327;
  --teal-700: #1d3a3d;
  --mint: #aceae1;        /* accent */
  --blue: #266ff2;        /* link / active accent */
  --ink: #102326;
  --muted: #86868b;
  --line: #eceef0;
  --bg: #ffffff;
  --soft: #f7f8f8;
  --ok: #0f766e;
  --warn: #b45309;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgba(16, 35, 38, 0.04), 0 10px 30px rgba(16, 35, 38, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.mono, .tiny, .pill, .panel-kicker, .card-label, .result-box, .activity, code, .nav-badge {
  font-family: "IBM Plex Mono", monospace;
}
.hidden { display: none !important; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  font-size: 24px; font-weight: 700; color: var(--mint);
  background: var(--teal-900);
}
.brand-name { margin: 0; font-weight: 700; font-size: 15px; }
.brand-sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- Login landing ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(172, 234, 225, 0.35), transparent 60%),
    #ffffff;
}
.login-card {
  width: min(420px, 100%); background: #fff; border: 1px solid var(--line);
  border-radius: 20px; padding: 34px 32px; box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login h1 { margin: 0 0 6px; font-size: 1.7rem; letter-spacing: -0.02em; }
.login-lede { margin: 0 0 22px; color: var(--muted); line-height: 1.55; font-size: 14px; }
.login .field { margin-bottom: 16px; }
.login-error { margin: 14px 0 0; color: var(--danger); font-size: 13px; }
.login-foot { margin: 20px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

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

.sidebar {
  background: var(--teal-900); color: #cfd8d6;
  display: flex; flex-direction: column; padding: 26px 18px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 2px 8px 26px; }
.sidebar .brand-name { color: #fff; }
.sidebar .brand-sub { color: #7e918e; }
.sidebar .brand-mark { background: rgba(172, 234, 225, 0.14); }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  border: 0; cursor: pointer; background: transparent; color: #b8c5c2;
  font: inherit; font-size: 14px; font-weight: 500; padding: 11px 12px; border-radius: 10px;
  transition: background 120ms ease, color 120ms ease;
}
.nav-item .nav-dot { width: 6px; height: 6px; border-radius: 50%; background: #3b5654; transition: background 120ms ease; }
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav-item.active { background: rgba(172, 234, 225, 0.12); color: #fff; }
.nav-item.active .nav-dot { background: var(--mint); }
.nav-badge { margin-left: auto; min-width: 20px; text-align: center; font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--mint); color: var(--teal-900); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid rgba(255,255,255,0.08); }
.tiny { font-size: 11px; color: #7e918e; margin: 6px 0 0; word-break: break-all; }

.main { display: flex; flex-direction: column; min-width: 0; background: #fff; }
.topbar {
  position: sticky; top: 0; z-index: 5; background: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 40px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.topbar-title { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.content { padding: 32px 40px 56px; }
.content-inner { max-width: 1080px; margin: 0 auto; }

.view { display: none; }
.view.active { display: block; animation: fade 160ms ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.activity {
  margin: 0 0 24px; padding: 12px 16px; border-radius: 10px; font-size: 12.5px; line-height: 1.5;
  background: var(--soft); color: var(--muted); border: 1px solid var(--line); white-space: pre-wrap;
}
.activity[data-tone="ok"] { background: rgba(15,118,110,0.07); color: #0b5f58; border-color: rgba(15,118,110,0.2); }
.activity[data-tone="warn"] { background: rgba(180,83,9,0.07); color: var(--warn); border-color: rgba(180,83,9,0.25); }
.activity[data-tone="error"] { background: rgba(192,57,43,0.06); color: var(--danger); border-color: rgba(192,57,43,0.25); }

/* ---------- Pills, panels, cards ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12px; }
.pill.muted { background: var(--soft); color: var(--muted); }
.pill.ok { background: rgba(15,118,110,0.1); color: var(--ok); }
.pill.warn { background: rgba(180,83,9,0.12); color: var(--warn); }
.pill.danger { background: rgba(192,57,43,0.1); color: var(--danger); }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 26px; box-shadow: var(--shadow); margin-bottom: 22px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-kicker { margin: 0 0 5px; text-transform: uppercase; letter-spacing: 0.12em; font-size: 11px; color: var(--ok); }
h2 { margin: 0; font-size: 1.25rem; letter-spacing: -0.01em; }
h3 { margin: 0 0 5px; font-size: 1rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
.card-label { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.card-value { margin: 0; font-size: 1.45rem; font-weight: 700; letter-spacing: -0.01em; word-break: break-word; }
.card-value.small-val { font-size: 0.95rem; }

/* ---------- Forms & buttons ---------- */
input, textarea, button { font: inherit; }
input, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  color: var(--ink); background: #fff; outline: none; transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:focus, textarea:focus { border-color: var(--teal-700); box-shadow: 0 0 0 3px rgba(172,234,225,0.4); }
button {
  border: 0; border-radius: 10px; padding: 10px 18px; font-weight: 600; cursor: pointer; color: #fff;
  background: var(--teal-900); transition: filter 120ms ease, transform 120ms ease, opacity 120ms ease; white-space: nowrap;
}
button:hover { filter: brightness(1.12); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: wait; }
button.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
button.ghost:hover { background: var(--soft); filter: none; }
button.block { width: 100%; padding: 12px; }
button.approve { background: var(--ok); }
button.reject { background: var(--danger); }

.field { display: grid; gap: 7px; }
.field span { font-size: 13px; font-weight: 500; color: var(--muted); }
.field.compact { min-width: 240px; flex: 1 1 300px; }

.actions { display: flex; align-items: center; gap: 10px; }
.actions.wrap { flex-wrap: wrap; }
.actions.between { justify-content: space-between; }
.small { margin: 0 0 16px; color: var(--muted); line-height: 1.6; font-size: 13px; }

/* Knowledge editor */
.editor-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }
#factsEditor { min-height: 480px; resize: vertical; font-family: "IBM Plex Mono", monospace; font-size: 13px; line-height: 1.65; margin-bottom: 16px; }

/* Learnings */
.learn-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { width: auto; }
.learn-list { display: flex; flex-direction: column; gap: 12px; }
.learn-card { display: flex; align-items: flex-start; gap: 14px; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; background: #fff; cursor: pointer; transition: border-color 120ms ease, background 120ms ease; }
.learn-card:hover { border-color: #d7dade; }
.learn-card:has(.learn-check:checked) { border-color: var(--ok); background: rgba(15,118,110,0.04); }
.learn-check { width: auto; margin-top: 3px; flex: none; }
.learn-body { flex: 1; min-width: 0; }
.learn-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.learn-text { font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.learn-meta { font-size: 12px; color: var(--muted); margin-top: 10px; }
.tag { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; padding: 3px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.tag.fact { background: rgba(15,118,110,0.12); color: var(--ok); }
.tag.instruction { background: rgba(38,111,242,0.12); color: var(--blue); }
.empty { color: var(--muted); padding: 32px 0; text-align: center; font-size: 13px; }
a { color: var(--blue); }

/* Operations */
.ops-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 18px; }
.ops-item { border: 1px solid var(--line); border-radius: 14px; padding: 18px; background: #fff; }
.ops-item .small { margin-bottom: 14px; }
.result-box { margin: 0; padding: 16px; border-radius: 12px; background: var(--teal-900); color: #c9e7e0; font-size: 12px; line-height: 1.55; overflow: auto; max-height: 240px; }

/* Chat */
.messages { display: flex; flex-direction: column; gap: 10px; min-height: 260px; max-height: 440px; overflow: auto; padding: 4px 2px 12px; }
.message { max-width: 84%; padding: 12px 15px; border-radius: 14px; white-space: pre-wrap; line-height: 1.55; font-size: 14px; }
.message.user { align-self: flex-end; color: #fff; background: var(--teal-900); border-bottom-right-radius: 4px; }
.message.bot { align-self: flex-start; background: var(--soft); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.message.meta { align-self: center; max-width: 100%; padding: 0; background: transparent; color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 12px; }
.composer { display: grid; gap: 12px; }

code { font-size: 0.92em; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item { width: auto; }
  .sidebar-foot { display: none; }
  .topbar { padding: 16px 20px; }
  .content { padding: 22px 20px 40px; }
}
