:root {
  --bg: #f4f6f1;
  --surface: #ffffff;
  --surface-2: #edf0ea;
  --ink: #18201b;
  --muted: #647067;
  --line: #d7ddd2;
  --accent: #1f6f5b;
  --accent-2: #9f4a38;
  --warn: #b98222;
  --shadow: 0 10px 28px rgba(24, 32, 27, 0.08);
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.94);
}

button.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  min-height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 241, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 800;
}

.topbar nav {
  display: flex;
  gap: 14px;
}

.page {
  width: min(1440px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-shell {
  width: min(420px, calc(100% - 32px));
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-shell h1 {
  margin: 0 0 22px;
}

.login-form,
.edit-form,
.note-form,
.terminal-form {
  display: grid;
  gap: 14px;
}

.error {
  margin: 0;
  color: var(--accent-2);
  font-weight: 700;
}

.command-band {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.capture-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.summary-grid {
  display: grid;
  grid-template-columns: 180px 180px minmax(260px, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.summary-panel {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-panel h2,
.quadrant h2,
.history h2,
.terminal-output h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.metric {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 800;
}

.recommendation {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

.mode-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.mode-filter a {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 12px;
  font-size: 0.9rem;
}

.mode-filter a.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.task-layout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.quadrant {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.task-card {
  display: grid;
  gap: 9px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.task-card p,
.summary-panel p,
.event p {
  margin: 0;
}

.task-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.task-head a {
  color: var(--ink);
  font-weight: 800;
}

.task-head span,
.task-meta span {
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 3px 8px;
  font-size: 0.78rem;
  font-weight: 700;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.empty {
  margin: 8px 0 0;
  color: var(--muted);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 20px;
}

.edit-form,
.history,
.terminal-form,
.terminal-output {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.actions,
.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.inline-form {
  margin-top: 12px;
}

.checkbox {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}

.checkbox input {
  width: auto;
}

.event {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.event span {
  color: var(--muted);
  font-size: 0.85rem;
}

.terminal-page,
.codex-chat-page {
  display: grid;
  gap: 16px;
}

.codex-chat-page {
  grid-template-rows: minmax(420px, calc(100vh - 230px)) auto;
}

.chat-log {
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.chat-message {
  display: grid;
  gap: 8px;
  max-width: 980px;
  margin: 0 0 14px;
}

.chat-message strong {
  color: var(--muted);
  font-size: 0.85rem;
}

.chat-message pre {
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101511;
  color: #e7f1e9;
  padding: 14px;
}

.run-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.run-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 8px 12px;
}

.chat-message .message-log {
  max-height: 360px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  background: #202820;
  color: #d9e4dc;
}

.chat-message.user {
  margin-left: auto;
}

.chat-message.user pre {
  background: #ffffff;
  color: var(--ink);
}

.chat-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.composer-actions {
  display: grid;
  gap: 8px;
}

.terminal-output pre {
  overflow: auto;
  max-height: 520px;
  margin: 0 0 12px;
  border-radius: 8px;
  background: #101511;
  color: #e7f1e9;
  padding: 14px;
}

.terminal-output pre.stderr {
  color: #ffd0c7;
}

@media (max-width: 1050px) {
  .task-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-column,
  .summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px 16px;
  }

  .capture-form,
  .chat-composer,
  .task-layout,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
