:root {
  --bg: #f6f3ec;
  --panel: #ffffff;
  --ink: #2a2432;
  --muted: #7d7587;
  --accent: #5e4299;
  --accent-2: #8967d9;
  --wood: #a06832;
  --teal: #2a8a9a;
  --red: #c54d4d;
  --green: #3a9b5c;
  --border: #e4dfd3;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 6px 18px rgba(50, 36, 82, .08);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .8rem 1.2rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand-row { display: flex; gap: .75rem; align-items: center; }
.brand-row h1 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.brand-row h1 .muted { color: var(--muted); font-weight: 400; }
.brand-img { width: 48px; height: 48px; object-fit: contain; }
.brand-img.small { width: 36px; height: 36px; }

.top-actions { display: flex; align-items: center; gap: .6rem; }
.pill {
  background: #efeaf7;
  color: var(--accent);
  border-radius: 999px;
  padding: .18rem .75rem;
  font-size: .8rem;
  font-weight: 600;
}

button {
  font: inherit;
  background: var(--accent);
  color: white;
  border: 0;
  padding: .55rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .06s, background .12s;
}
button:hover:not(:disabled) { background: var(--accent-2); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
button.ghost:hover:not(:disabled) { background: #efeaf7; color: var(--accent); }

input, select {
  font: inherit;
  border: 1px solid var(--border);
  padding: .45rem .6rem;
  border-radius: 10px;
  background: white;
  color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }

.shell {
  max-width: 1100px;
  margin: 1.2rem auto;
  padding: 0 1.2rem 2rem;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  grid-column: span 12;
}
.panel h2 { margin: 0 0 .7rem; font-size: .95rem; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }

.row { display: flex; align-items: center; gap: .5rem; }
.row.gap { gap: .6rem; }
.row.wrap { flex-wrap: wrap; }
.inline { display: inline-flex; align-items: center; gap: .4rem; }
.inline input[type=checkbox] { transform: translateY(1px); }

.status-row {
  margin-top: .6rem;
  display: flex; align-items: center; gap: .5rem;
  color: var(--muted); font-size: .88rem;
}
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #c8c1d6;
  box-shadow: 0 0 0 2px #ece7f7;
}
.dot.ok { background: var(--green); box-shadow: 0 0 0 2px #d7f0df; }
.dot.warn { background: #d89a2f; box-shadow: 0 0 0 2px #f7ecd2; }
.dot.err { background: var(--red); box-shadow: 0 0 0 2px #f4d7d7; }

.sliders { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .75rem; }
.sliders label { display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); gap: .25rem; }
.sliders input[type=range] { width: 100%; }

.meter-row { display: flex; align-items: center; gap: .5rem; margin-top: .4rem; font-size: .85rem; color: var(--muted); }
.meter { flex: 1; height: 10px; background: #eee7d8; border-radius: 999px; overflow: hidden; }
.meter > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--accent)); transition: width 60ms linear; }

#typedInput { flex: 1; }
.hint { margin: .5rem 0 0; color: var(--muted); font-size: .85rem; }

.convo { min-height: 60px; display: flex; flex-direction: column; gap: .45rem; }
.bubble { border-radius: 14px; padding: .6rem .8rem; max-width: 80%; font-size: .93rem; line-height: 1.4; }
.bubble.user { background: #efeaf7; color: var(--ink); align-self: flex-end; }
.bubble.bot  { background: #fff4df; color: var(--ink); align-self: flex-start; border: 1px solid #f0e4c6; }

.logs {
  background: #1f1a28;
  color: #e6dcf1;
  border-radius: 12px;
  padding: .75rem .9rem;
  max-height: 240px;
  overflow: auto;
  font-size: .8rem;
  margin: 0;
}

/* ------ Login page ------ */
.login-body { display: grid; min-height: 100vh; place-items: center; }
.login-card {
  width: min(420px, calc(100vw - 2rem));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.6rem 1.4rem;
  box-shadow: var(--shadow);
}
.login-card .brand { display: flex; flex-direction: column; align-items: center; gap: .3rem; margin-bottom: 1.2rem; }
.login-card .brand-img { width: 80px; height: 80px; }
.login-card h1 { margin: 0; font-size: 1.4rem; }
.brand-sub { color: var(--muted); font-size: .9rem; margin: 0; }
.login-card form { display: flex; flex-direction: column; gap: .45rem; }
.login-card label { font-size: .85rem; color: var(--muted); }
.login-card button { margin-top: .6rem; }
.login-card .err { color: var(--red); font-size: .88rem; min-height: 1em; margin: .25rem 0 0; }
.login-footer { color: var(--muted); text-align: center; margin-top: .9rem; }
