:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #203330;
  background: #f4f6f3;
  line-height: 1.5;
  --ink: #203330;
  --muted: #526660;
  --edge: #d9e3dc;
  --green: #1b6555;
  --green-hover: #144d41;
  --white: #fff;
  --header: #172e2b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .58; }
button, a, input, textarea, summary, [tabindex]:focus-visible { outline-offset: 3px; }
:focus-visible { outline: 2px solid #368d77; }
h1, h2, h3, p, pre, ol, ul { margin: 0; }
ol, ul { padding: 0; }
textarea { resize: vertical; min-width: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.masthead { background: var(--header); color: #f2f9f7; }
.masthead-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 4.25rem;
  max-width: 112rem;
  margin-inline: auto;
  padding: .75rem clamp(1rem, 3vw, 2.5rem);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  color: inherit;
  text-decoration: none;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -.025em;
}
.brand-mark, .empty-mark {
  position: relative;
  display: inline-block;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid #98cbbb;
  border-radius: 7px;
}
.brand-mark::before, .empty-mark::before {
  content: "";
  position: absolute;
  inset: 25%;
  border: 1px solid currentColor;
  transform: rotate(-12deg);
  border-radius: 2px;
}
.brand-mark { color: #dbf1e7; }
.masthead-actions, .actions, .sidebar-tools {
  display: flex;
  gap: .7rem;
  align-items: center;
}
.header-button {
  background: transparent;
  color: #f2f9f7;
  border: 1px solid #709089;
  border-radius: 7px;
  padding: .46rem .78rem;
  font-size: .875rem;
}
.header-button:hover { background: #2b4842; }
#project-toggle { display: none; }

.button {
  display: inline-flex;
  min-height: 2.65rem;
  align-items: center;
  justify-content: center;
  gap: .28rem;
  padding: .53rem .95rem;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: .9rem;
  font-weight: 650;
  white-space: nowrap;
}
.button.primary { background: var(--green); color: var(--white); }
.button.primary:hover:not(:disabled) { background: var(--green-hover); }
.button.secondary { background: var(--white); color: var(--ink); border-color: #bdcdc3; }
.button.secondary:hover:not(:disabled) { background: #eef5f0; }
.button.small { min-height: 2.2rem; padding: .34rem .7rem; }
.muted { color: var(--muted); }
.notice {
  padding: .65rem .8rem;
  border: 1px solid;
  border-radius: 8px;
  font-size: .9rem;
  overflow-wrap: anywhere;
}
.notice.error { color: #862f37; background: #fff6f5; border-color: #e6c3c5; }
.field { display: grid; gap: .42rem; min-width: 0; }
.field > span { font-weight: 650; font-size: .925rem; }
.field input, .field textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: .62rem .75rem;
  color: var(--ink);
  background: #fcfdfa;
  border: 1px solid #becdc5;
  border-radius: 7px;
}
.field input::placeholder, .field textarea::placeholder { color: #687971; opacity: 1; }
.field input:read-only, .field textarea:read-only { background: #f2f5f0; }
textarea.markdown-area {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9rem;
  line-height: 1.66;
  tab-size: 2;
}

.login-layout {
  min-height: calc(100dvh - 4.25rem);
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.login-card {
  width: min(100%, 27rem);
  padding: clamp(1.5rem, 6vw, 2.6rem);
  border: 1px solid var(--edge);
  border-radius: 13px;
  background: var(--white);
  box-shadow: 0 12px 26px #243a3310;
}
.login-card h1, .project-heading h1, .overview-state h1 {
  font-size: clamp(1.55rem, 3.3vw, 2.3rem);
  line-height: 1.11;
  letter-spacing: -.045em;
  text-wrap: balance;
}
.login-card form, .create-form, .status-form { display: grid; gap: .95rem; }
.login-card h1 + p, .login-card h1 + p + form { margin-top: 1.15rem; }
.login-card .primary { justify-self: start; }

.workspace {
  display: grid;
  grid-template-columns: minmax(13.7rem, 16%) minmax(0, 1fr);
  max-width: 112rem;
  min-height: calc(100dvh - 4.25rem);
  margin-inline: auto;
}
.sidebar {
  min-width: 0;
  background: #e9eeea;
  border-inline-end: 1px solid #d5dfd8;
  padding: 1.35rem 1rem;
}
.sidebar-tools { justify-content: space-between; }
.sidebar h2 { font-size: 1rem; letter-spacing: -.015em; }
.sidebar-add { padding-inline: .65rem; min-height: 2.25rem; }
.sidebar-note { margin-top: .8rem; color: var(--muted); font-size: .9rem; }
.sidebar-note:empty { display: none; }
.project-list { display: grid; gap: .28rem; margin-top: .95rem; list-style: none; }
.project-link {
  display: grid;
  gap: .17rem;
  width: 100%;
  text-align: start;
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 7px;
  padding: .55rem .65rem;
}
.project-link:hover { background: #e0e9e1; }
.project-link[aria-current="page"] { color: #124635; background: #d4e8dc; border-color: #bfdccb; }
.project-link-name { min-width: 0; overflow-wrap: anywhere; font-size: .94rem; font-weight: 650; line-height: 1.35; }
.project-link-date { color: #4e675c; font-size: .8125rem; }
.project-main { min-width: 0; padding: clamp(1rem, 2.4vw, 2rem) clamp(1rem, 3vw, 2.5rem) 2.5rem; }
.project-main > .notice { margin-bottom: 1rem; }
.project-heading { margin-bottom: 1.2rem; min-width: 0; overflow-wrap: anywhere; }
.project-heading .updated { font-size: .88rem; margin-top: .45rem; }
.page-status { margin-top: 1rem; color: var(--muted); }
.overview-state {
  display: grid;
  place-items: start;
  align-content: center;
  gap: .8rem;
  padding: clamp(1.5rem, 8vw, 7rem);
  min-height: 60dvh;
}
.overview-state p { max-width: 38ch; color: var(--muted); }
.empty-mark { width: 2.5rem; height: 2.5rem; color: var(--green); background: #e4f0e8; }
.overview-state .button { margin-top: .4rem; }
.create-view { max-width: 45rem; }
.create-form { padding: clamp(1rem, 4vw, 1.8rem); }

.project-panels {
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
  align-items: start;
  gap: clamp(.8rem, 1.7vw, 1.5rem);
}
.panel { background: var(--white); border: 1px solid var(--edge); border-radius: 11px; }
.project-panel { min-width: 0; }
.panel-heading {
  min-height: 3.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .65rem 1rem;
  border-block-end: 1px solid #e3eae5;
}
.panel-heading h2 { font-size: 1.03rem; letter-spacing: -.025em; }
.status-content, .status-form { padding: 1rem; }
.markdown, .message-text, .event-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.markdown {
  font: .9rem/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  max-height: min(62dvh, 54rem);
  overflow: auto;
}
.save-feedback { padding: 0 1rem 1rem; color: #235847; font-size: .9rem; }
.mobile-switch { display: none; }

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(14rem, 1fr) auto;
  min-height: 30rem;
  height: min(72dvh, 58rem);
}
.run-indicator {
  font-size: .86rem;
  color: var(--muted);
  line-height: 1.25;
  text-align: end;
  white-space: normal;
}
.run-indicator[data-state="running"] { color: #15614c; font-weight: 650; }
.run-indicator[data-state="failed"] { color: #8b3039; }
.transcript {
  padding: .95rem 1rem;
  overflow: auto;
  overscroll-behavior-y: contain;
}
.chat-empty { margin: 1.2rem 0; }
.chat-empty h3 { font-size: 1.06rem; margin-bottom: .35rem; }
.chat-empty p { color: var(--muted); }
.messages, .events { list-style: none; }
.messages { display: grid; gap: .75rem; }
.message-item {
  border: 1px solid #dfebe2;
  border-radius: 8px;
  max-width: 100%;
  padding: .66rem .8rem;
  background: #f6f9f6;
}
.message-item[data-role="user"] {
  background: #e8f1ec;
  border-color: #d8e8de;
  margin-inline-start: clamp(0rem, 4vw, 1.6rem);
}
.message-author, .event-label { display: block; font-size: .875rem; font-weight: 650; color: #325247; margin-bottom: .22rem; }
.run-details { border: 1px solid #dbe5de; border-radius: 8px; margin-top: .8rem; background: #fbfdfb; }
.run-details summary { padding: .62rem .73rem; color: #31594b; cursor: pointer; font-size: .9rem; }
.events { padding: .05rem .7rem .7rem; }
.event-item { border-top: 1px solid #e2eae4; padding: .56rem .02rem .42rem; }
.event-text { color: #435851; font-size: .9rem; }
.composer {
  display: grid;
  gap: .45rem;
  padding: .8rem 1rem;
  border-block-start: 1px solid #e3eae5;
}
.composer-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .52rem; align-items: end; }
.composer textarea { min-height: 2.85rem; max-height: 13rem; line-height: 1.42; }
.composer .send { min-height: 2.85rem; }
.keyboard-hint { color: var(--muted); font-size: .78rem; }

@media (max-width: 70rem) {
  .project-panels { grid-template-columns: minmax(0, 1fr); }
  .mobile-switch { display: inline-flex; gap: .25rem; border: 1px solid #ccd9d0; border-radius: 9px; padding: .24rem; margin-bottom: .9rem; }
  .switch-button { color: #3c544a; padding: .42rem .75rem; border: 0; background: transparent; border-radius: 6px; font-size: .875rem; }
  .switch-button[aria-pressed="true"] { background: #d7eadf; color: #124635; font-weight: 650; }
  .project-view[data-mobile-view="status"] .chat-panel,
  .project-view[data-mobile-view="chat"] .status-panel { display: none; }
}

@media (max-width: 47rem) {
  .masthead-inner { min-height: 3.75rem; }
  #project-toggle { display: block; }
  .workspace { grid-template-columns: minmax(0, 1fr); min-height: calc(100dvh - 3.75rem); }
  .sidebar { display: none; border: 0; border-block-end: 1px solid #d5dfd8; max-height: 45dvh; overflow: auto; }
  .workspace[data-sidebar-open="true"] .sidebar { display: block; }
  .chat-panel { height: 68dvh; min-height: 24rem; }
  .overview-state { min-height: 52dvh; padding: 2rem 1rem; }
  .keyboard-hint { display: none; }
}

@media (max-width: 26rem) {
  .masthead-inner { padding-inline: .75rem; gap: .55rem; }
  .masthead-actions { gap: .38rem; }
  .header-button { padding-inline: .55rem; }
  .brand { gap: .45rem; font-size: .975rem; }
  .brand-mark { width: 1.4rem; height: 1.4rem; }
  .panel-heading, .composer, .transcript { padding-inline: .65rem; }
  .composer .send { padding-inline: .63rem; }
}
