:root {
  --ink: #1c1915;
  --muted: #6d645b;
  --paper: #f4efe6;
  --card: #fffdf8;
  --line: #e3d9cc;
  --aside: #1e2a24;
  --aside-text: #efe7da;
  --accent: #c65a2e;
  --accent-ink: #fff8f3;
  --ok: #1f6b45;
  --shadow: 0 18px 40px rgba(48, 32, 16, 0.08);
  font-family: Outfit, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

aside {
  background: var(--aside);
  color: var(--aside-text);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand > div { min-width: 0; }
.brand strong { display: block; font-family: Fraunces, Georgia, serif; font-size: 1.4rem; }
.brand small { color: #c8bfb2; display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#brand-user { color: #efe7da; }
.mark {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--accent); color: white;
  font-family: Fraunces, Georgia, serif; font-size: 1.4rem;
}

nav { display: flex; flex-direction: column; gap: 6px; }
.nav {
  text-align: left; border: 0; background: transparent; color: #d9d0c4;
  padding: 10px 12px; border-radius: 12px;
}
.nav.active, .nav:hover { background: rgba(255,255,255,0.08); color: white; }
.aside-note { margin-top: auto; color: #b7aea2; font-size: 0.85rem; line-height: 1.45; }

main { padding: 32px 40px 48px; max-width: 980px; }
.panel { display: none; }
.panel.visible { display: block; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 4px; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.72rem; color: var(--accent); }
h1 { margin: 0; font-family: Fraunces, Georgia, serif; font-weight: 520; font-size: 2.4rem; }

.ghost, button[type="submit"] {
  border: 0; border-radius: 999px; padding: 10px 16px;
}
.ghost { background: transparent; border: 1px solid var(--line); }
button[type="submit"] { background: var(--ink); color: var(--accent-ink); }

.thread {
  min-height: 420px; max-height: calc(100vh - 280px); overflow: auto;
  display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px;
}
.bubble {
  max-width: 72%; padding: 12px 14px; border-radius: 18px; line-height: 1.45;
  box-shadow: var(--shadow);
}
.bubble.user { margin-left: auto; background: #f3d2c3; }
.bubble.agent { background: var(--card); border: 1px solid var(--line); }
.bubble .who { display: block; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.bubble .plain { white-space: pre-wrap; }
.bubble .md { white-space: normal; }
.bubble .md p { margin: 0 0 0.65em; }
.bubble .md p:last-child,
.bubble .md ul:last-child,
.bubble .md ol:last-child,
.bubble .md pre:last-child { margin-bottom: 0; }
.bubble .md ul,
.bubble .md ol { margin: 0 0 0.65em; padding-left: 1.25em; }
.bubble .md li { margin: 0.15em 0; }
.bubble .md h1,
.bubble .md h2,
.bubble .md h3 {
  font-family: Fraunces, Georgia, serif;
  font-size: 1.05rem;
  font-weight: 650;
  margin: 0.2em 0 0.4em;
}
.bubble .md a { color: var(--accent); }
.bubble .md code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.88em;
  background: #f3eee6;
  padding: 0.1em 0.35em;
  border-radius: 6px;
}
.bubble .md pre {
  margin: 0 0 0.65em;
  background: #1e2a24;
  color: #f4efe6;
  padding: 10px 12px;
  border-radius: 12px;
  overflow: auto;
}
.bubble .md pre code { background: transparent; color: inherit; padding: 0; }

.composer { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
textarea, input, select {
  width: 100%; border: 1px solid var(--line); background: var(--card);
  border-radius: 14px; padding: 12px 14px;
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 18px; box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 0.86rem; color: var(--muted); }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.job {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px;
}
.job h3 { margin: 0; font-size: 1rem; }
.job p { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }
.job-detail {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.job-actions { display: flex; gap: 8px; align-items: center; }
.job-actions button { border-radius: 999px; border: 1px solid var(--line); background: white; padding: 8px 12px; }
.job.off { opacity: 0.62; }
.pill { font-size: 0.75rem; border-radius: 999px; padding: 3px 8px; background: #efe6da; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; }
.stat b { display: block; font-family: Fraunces, Georgia, serif; font-size: 1.7rem; font-weight: 520; }
.stat span { color: var(--muted); font-size: 0.82rem; }
.note { color: var(--muted); font-size: 0.85rem; }
.status { color: var(--ok); font-size: 0.9rem; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  aside { padding: 16px; }
  nav { flex-direction: row; flex-wrap: wrap; }
  .aside-note { display: none; }
  main { padding: 20px 16px 32px; }
  .form-grid, .stats { grid-template-columns: 1fr 1fr; }
  .bubble { max-width: 92%; }
  h1 { font-size: 1.8rem; }
}

.app[hidden], .gate[hidden] { display: none !important; }
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card { width: min(440px, 100%); display: grid; gap: 12px; justify-items: center; text-align: center; }
.login-card h1 { font-size: 2rem; }
.login-card .note { max-width: 36ch; }
.login-card a { color: var(--accent); }
.google-login { min-height: 48px; display: grid; place-items: center; }
.google-login iframe { color-scheme: light; }
#logout { margin-top: auto; }
.aside-note { margin-top: 12px; }
