:root {
  --bg: #fafaf8;
  --paper: #fff;
  --ink: #252d29;
  --muted: #65716a;
  --line: #e1e6e0;
  --accent: #25644e;
  --soft: #edf4ee;
  font:
    15px/1.6 system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
body.workspace-active {
  height: 100dvh;
  overflow: hidden;
}
button,
textarea,
input {
  font: inherit;
}
button {
  cursor: pointer;
  color: inherit;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid #628e79;
  outline-offset: 4px;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
[hidden] {
  display: none !important;
}
.app-header {
  height: 68px;
  padding: 0 clamp(16px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.6px;
  font-size: 21px;
  font-weight: 650;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border: 1px solid #c7d6c9;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent);
  font:
    26px Georgia,
    serif;
}
.badge {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0;
  font-weight: 400;
}
.quiet {
  background: none;
  border: 0;
  padding: 10px 13px;
  border-radius: 9px;
  color: var(--muted);
}
.quiet:hover {
  background: var(--soft);
  color: var(--ink);
}
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.primary {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
  border-radius: 9px;
  padding: 9px 19px;
  font-weight: 550;
}
.primary:hover {
  background: #194a38;
}
.secondary {
  background: white;
  border: 1px solid #cdd7cc;
  border-radius: 9px;
  padding: 9px 15px;
}
.login {
  width: min(440px, 100%);
  margin: 10vh auto;
  padding: 24px;
}
.login h1 {
  font-weight: 450;
}
.login p,
.login small {
  color: var(--muted);
}
.login form {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
}
.login input {
  width: 100%;
  padding: 12px;
  border: 1px solid #b4c7b8;
  border-radius: 8px;
}
main {
  flex: 1;
  min-height: 0;
}
.welcome {
  max-width: 780px;
  margin: clamp(48px, 15vh, 150px) auto 0;
  padding: 0 24px;
}
.eyebrow {
  font-size: 13px;
  letter-spacing: 0;
  color: var(--muted);
  margin-bottom: 14px;
}
.welcome h1 {
  font-weight: 450;
  font-size: clamp(29px, 4vw, 40px);
  line-height: 1.3;
  letter-spacing: -1.2px;
  margin: 0 0 12px;
}
.welcome > p {
  color: var(--muted);
  margin: 0 0 32px;
}
.availability {
  font-size: 12px;
  margin-top: 18px !important;
}
.composer {
  background: var(--paper);
  border: 1px solid #ccd7cd;
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 4px 25px #223c2810;
}
.composer:focus-within {
  border-color: #6c947b;
  box-shadow: 0 0 0 2px #3874530c;
}
.composer textarea {
  width: 100%;
  min-height: 75px;
  max-height: min(270px, 28dvh);
  resize: vertical;
  border: 0;
  outline: 0;
  background: none;
  line-height: 1.7;
  color: var(--ink);
  padding: 0 4px;
}
.composer textarea::placeholder {
  color: #89958c;
}
.composer textarea:focus-visible {
  outline: 0;
}
.composer-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.attach {
  background: none;
  border: 0;
  padding: 8px;
  color: var(--muted);
}
.hint {
  font-size: 11px;
  color: var(--muted);
  margin: 8px 0 0;
}
.workspace {
  max-width: 860px;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  padding: 18px 28px;
  display: flex;
  flex-direction: column;
}
.workspace-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}
.workspace-heading h1 {
  font-size: 18px;
  font-weight: 550;
  letter-spacing: -0.4px;
  margin: 0;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.workspace-heading > .quiet {
  white-space: nowrap;
}
.activity {
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8b978e;
  flex: none;
}
.activity .quiet {
  margin-left: auto;
  white-space: nowrap;
  padding: 5px;
}
.timeline {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overflow-wrap: anywhere;
  padding-right: 6px;
}
.workspace .composer {
  flex-shrink: 0;
}
.workspace .composer textarea {
  min-height: 50px;
}
.message {
  margin: 12px 0 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 15px 18px;
}
.message p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
}
.message small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}
.empty {
  color: var(--muted);
  font-size: 14px;
  padding: 25px 0;
}
.footnote {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin: 12px 0 0;
  flex-shrink: 0;
}
.status {
  font-size: 13px;
  color: #536b5c;
  max-width: 800px;
  margin: 8px auto;
  padding: 0 24px;
  min-height: 22px;
  overflow-wrap: anywhere;
}
.status:empty {
  display: none;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
dialog {
  border: 1px solid var(--line);
  padding: 0;
  box-shadow: 0 14px 65px #152d2620;
  background: var(--paper);
  color: var(--ink);
}
dialog::backdrop {
  background: #16251d35;
}
.panel {
  position: fixed;
  top: 0;
  right: 0;
  left: auto;
  margin: 0;
  width: 620px;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
}
.drawer {
  position: fixed;
  left: 0;
  top: 0;
  margin: 0;
  width: 330px;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}
.panel-header h2 {
  font-size: 18px;
  margin: 0;
  font-weight: 550;
}
.panel-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
}
.panel-tabs button {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 7px;
}
.panel-tabs button[aria-pressed="true"],
.source-views button[aria-pressed="true"] {
  background: var(--soft);
  color: var(--accent);
}
.panel-body {
  padding: 24px;
  overflow-wrap: anywhere;
}
.panel-body h3 {
  font-size: 12px;
  color: var(--muted);
  font-weight: 550;
  margin: 22px 0 8px;
}
.panel-body h3:first-child {
  margin-top: 0;
}
.panel-body p {
  font-size: 14px;
}
.program-button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: var(--soft);
  padding: 14px;
  border-radius: 10px;
  font-size: 14px;
  margin: 10px 0;
  overflow-wrap: anywhere;
}
.panel-body pre {
  font-size: 11px;
  white-space: pre-wrap;
  background: var(--soft);
  padding: 10px;
  max-height: 300px;
  overflow: auto;
}
.panel-body details {
  padding: 10px 0;
}
#older {
  width: 100%;
  font-size: 12px;
}
@media (max-width: 650px) {
  .app-header {
    height: 72px;
    padding: 0 16px;
    gap: 8px;
  }
  .brand {
    font-size: 18px;
    gap: 6px;
  }
  .brand-mark {
    width: 24px;
    height: 24px;
  }
  .header-actions {
    gap: 0;
  }
  .header-actions .quiet {
    font-size: 11px;
    padding: 8px;
  }
  .badge {
    display: none;
  }
  .welcome {
    margin-top: 65px;
    padding: 0 20px;
  }
  .welcome h1 {
    font-size: 31px;
    max-width: 300px;
  }
  .welcome p {
    font-size: 14px;
  }
  .workspace {
    padding: 10px 16px max(10px, env(safe-area-inset-bottom));
  }
  .workspace-heading {
    align-items: flex-start;
    gap: 8px;
  }
  .workspace-heading h1 {
    font-size: 16px;
  }
  .workspace-heading .quiet {
    white-space: normal;
    max-width: 110px;
    padding: 2px 0 4px 8px;
    font-size: 13px;
  }
  .activity {
    font-size: 11px;
    margin-bottom: 14px;
  }
  .message {
    margin-left: 0;
    font-size: 14px;
  }
  .composer {
    padding: 13px;
  }
  .composer textarea {
    min-height: 60px;
  }
  .composer-controls .hint {
    font-size: 10px;
  }
  .footnote {
    font-size: 10px;
  }
  .panel {
    width: 100%;
  }
  .panel-header {
    padding: 20px;
  }
  .status {
    padding: 0 18px;
    font-size: 12px;
  }
}
@media (max-height: 600px) {
  .footnote,
  .continuation,
  #input-help {
    display: none;
  }
  .activity {
    margin-bottom: 6px;
    padding: 5px 0;
  }
  .composer textarea {
    min-height: 35px;
  }
  .workspace {
    padding-top: 5px;
  }
  .app-header {
    height: 56px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

.knowledge-card { border-top: 1px solid var(--line, #ddd); padding: 1rem 0; overflow-wrap: anywhere; }
.panel-body label { display: block; margin-top: 0.8rem; }
.panel-body textarea { box-sizing: border-box; width: 100%; font: inherit; padding: 0.6rem; margin: 0.4rem 0; }
.knowledge-card p { white-space: pre-wrap; }

.finding { border-left: 2px solid var(--line); padding-left: 0.8rem; margin: 1rem 0; }
.panel-body input, .panel-body select { box-sizing: border-box; max-width: 100%; width: 100%; font: inherit; margin: 0.4rem 0; }
#program-list input { width: 100%; font: inherit; }
.source-preview { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 20rem; overflow: auto; }
#source-section { margin-block: 1rem; }
#source-section input[type=file] { max-width: 100%; }
.parsed-source { margin-block: 1rem; }
.parsed-part { border-top: 1px solid var(--line, #ddd); padding-block: .75rem; overflow-wrap: anywhere; }
.parsed-part img { max-width: 100%; height: auto; }

.source-views { display: flex; flex-wrap: wrap; gap: .5rem; margin-block: .75rem; }

.continuation {
  color: var(--muted);
  font-size: 12px;
  padding: 8px 4px 12px;
}
.continuation strong {
  color: var(--ink);
  font-weight: 550;
}
.continuation p { margin: 3px 0 0; }
.panel-tabs {
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 1;
}
.panel-body button:not(.quiet) {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 4px 6px 4px 0;
}
.panel-body button:not(.quiet):hover { background: var(--soft); }
.panel-body summary {
  cursor: pointer;
  font-size: 14px;
  padding-block: 6px;
}
.panel-body h4 {
  margin: 4px 0 12px;
  font-size: 15px;
  font-weight: 600;
}
.panel-body input, .panel-body textarea, .panel-body select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--paper);
  color: var(--ink);
}
.source-identity { font-size: 11px; color: var(--muted); }
.source-identity summary { font-size: 12px; }
.parser-limits {
  background: #faf8ef;
  border-radius: 8px;
  padding: 8px 12px !important;
}
.parser-limits p { font-size: 12px; }
#note-editor {
  margin-block: 12px;
  padding: 12px;
  background: var(--soft);
  border-radius: 10px;
}
#program-search {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 18px;
}

.message p.condensed {
  max-height: 12rem;
  overflow: hidden;
  mask-image: linear-gradient(black 75%, transparent);
}
.message-toggle { padding: 8px 0 0; font-size: 12px; }
