:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #17211f;
  --muted: #65706d;
  --line: #dfe5df;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warn: #b45309;
  --done: #2563eb;
  --shadow: 0 18px 50px rgba(28, 42, 38, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0.7rem 1rem;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button.ghost {
  background: #eef4f2;
  color: var(--accent-dark);
}

button.full {
  width: 100%;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 6px;
  background: #eef4f2;
  color: var(--accent-dark);
  padding: 0.7rem 1rem;
  font-weight: 700;
  text-decoration: none;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0.7rem 0.8rem;
}

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

.rail {
  background: #17211f;
  color: #eef6f4;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.brand img {
  width: 42px;
  height: 42px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #a6b8b4;
  font-size: 0.85rem;
}

.rail-btn {
  background: transparent;
  color: #d7e4e1;
  text-align: left;
}

.rail-btn:hover,
.rail-btn.active {
  background: #243431;
}

.rail-status {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #c2d1ce;
  font-size: 0.9rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ef4444;
}

.dot.connected {
  background: #22c55e;
}

main {
  padding: 1.2rem;
  overflow: hidden;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.85rem;
}

h2 {
  margin-bottom: 0.25rem;
  font-size: 1.1rem;
}

.muted,
.field-hint,
.status-line {
  color: var(--muted);
}

.field-hint {
  font-size: 0.82rem;
  font-weight: 500;
}

.status-line {
  font-weight: 700;
}

.top-actions {
  display: flex;
  gap: 0.5rem;
}

.notice {
  border: 1px solid #f5d08a;
  background: #fff7e6;
  color: #6f4705;
  border-radius: 6px;
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.chat-layout,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
}

.chat-panel,
.side-panel,
.settings-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.chat-panel {
  display: grid;
  grid-template-rows: minmax(420px, calc(100vh - 205px)) auto;
}

.chat-log {
  padding: 1rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bubble {
  max-width: 78%;
  border-radius: 8px;
  padding: 0.8rem 0.95rem;
  white-space: pre-wrap;
  line-height: 1.45;
}

.bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.bubble.assistant {
  align-self: flex-start;
  background: #eef3f1;
}

.composer,
.searchbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  padding: 0.9rem;
  border-top: 1px solid var(--line);
}

.searchbar {
  grid-template-columns: minmax(0, 1fr) 150px auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.side-panel {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.metric span,
.task-meta,
.message-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.metric strong {
  display: block;
  font-size: 2rem;
  margin-top: 0.2rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.toolbar p {
  color: var(--muted);
  margin-bottom: 0;
}

.task-list,
.message-list {
  display: grid;
  gap: 0.75rem;
}

.task,
.message {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.95rem;
  box-shadow: 0 8px 24px rgba(28, 42, 38, 0.06);
}

.task.completed {
  opacity: 0.62;
}

.task-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.task h3,
.message h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.task p,
.message p {
  margin-bottom: 0.45rem;
  color: #35413e;
  line-height: 1.45;
}

.task-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.task-actions button {
  padding: 0.45rem 0.65rem;
}

.settings-panel {
  padding: 1rem;
}

.settings-panel label {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.9rem;
  color: var(--muted);
  font-weight: 700;
}

.settings-panel label input {
  color: var(--ink);
  font-weight: 500;
}

.toggle {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.toggle input {
  width: auto;
}

.settings-panel button {
  margin-top: 1rem;
}

.admin-auth {
  margin-top: 0.75rem;
}

.admin-settings {
  margin-top: 1rem;
}

.secret-saved {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  border-radius: 8px;
  padding: 0.85rem;
  margin-top: 0.9rem;
}

.secret-saved strong,
.secret-saved span {
  display: block;
}

.secret-saved span {
  color: #166534;
  font-size: 0.86rem;
}

.checkmark {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #16a34a;
  color: #fff !important;
  font-weight: 900;
}

.secret-saved button {
  margin-top: 0;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  max-width: min(420px, calc(100vw - 2rem));
  background: #17211f;
  color: #fff;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .shell,
  .chat-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .rail {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .brand {
    margin-bottom: 0;
  }

  .rail-status {
    margin-top: 0;
    margin-left: auto;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .searchbar {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    grid-template-rows: minmax(360px, 55vh) auto;
  }

  .bubble {
    max-width: 95%;
  }
}
