:root {
  color-scheme: light;
  --paper: #f5f7f4;
  --surface: #ffffff;
  --surface-soft: #eef3ef;
  --ink: #152e3a;
  --ink-soft: #42606b;
  --muted: #71848a;
  --line: #dce5e0;
  --line-strong: #c8d7d0;
  --sage: #648b78;
  --sage-dark: #3e6958;
  --sage-pale: #e6f0e9;
  --teal: #2e7779;
  --warning: #b76a35;
  --warning-pale: #fff3e7;
  --danger: #a84a4a;
  --danger-pale: #fff0ef;
  --shadow: 0 16px 46px rgb(26 55 64 / 8%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 50% -18rem, rgb(225 238 229 / 72%), transparent 43rem),
    var(--paper);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgb(46 119 121 / 48%);
  outline-offset: 3px;
}

a {
  color: inherit;
}

.auth-wrap {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.035em;
  text-decoration: none;
}

.brand-auth {
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 10px;
  background: var(--sage-dark);
  color: white;
  font-family: Georgia, serif;
  font-size: 19px;
  font-weight: 600;
  line-height: 1;
}

.auth-card {
  width: min(100%, 430px);
  padding: 40px 42px 36px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.eyebrow {
  color: var(--sage-dark);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.145em;
}

.auth-card h1,
.composer-section h1 {
  margin: 12px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 4vw, 38px);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.12;
}

.muted,
.intro-copy {
  color: var(--ink-soft);
  line-height: 1.65;
}

.muted {
  margin: 0 0 26px;
  font-size: 14px;
}

.form-stack {
  display: grid;
  gap: 11px;
}

.form-stack label,
.request-form label,
.preference-form label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

input[type="password"],
textarea,
.checklist-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fcfdfc;
  color: var(--ink);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

input[type="password"] {
  min-height: 48px;
  padding: 0 13px;
}

textarea {
  resize: vertical;
  padding: 12px 13px;
  line-height: 1.55;
}

input[type="password"]:focus,
textarea:focus,
.checklist-input:focus {
  border-color: var(--teal);
  background: white;
  box-shadow: 0 0 0 3px rgb(46 119 121 / 10%);
  outline: none;
}

textarea::placeholder,
input::placeholder {
  color: #91a09e;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease, color 120ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button-primary {
  background: var(--sage-dark);
  color: white;
}

.button-primary:hover:not(:disabled) {
  background: #335948;
}

.button-wide {
  width: 100%;
  min-height: 47px;
  margin-top: 11px;
}

.button-quiet {
  background: transparent;
  color: var(--ink-soft);
}

.button-quiet:hover:not(:disabled) {
  background: var(--surface-soft);
  color: var(--ink);
}

.button-outline {
  border-color: var(--line-strong);
  background: white;
  color: var(--ink-soft);
}

.button-outline:hover:not(:disabled) {
  border-color: var(--sage);
  color: var(--sage-dark);
}

.button-small {
  min-height: 33px;
  padding: 0 12px;
  font-size: 12px;
}

.field-hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.field-error {
  color: var(--danger) !important;
}

.auth-footnote {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.notice p {
  margin: 0;
}

.notice-neutral {
  background: var(--surface-soft);
  color: var(--ink-soft);
}

.notice-error {
  margin: 14px 0;
  border-color: #f0d1cb;
  background: var(--danger-pale);
  color: #793838;
}

.notice-warning {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  border-color: #ead8ba;
  background: var(--warning-pale);
  color: #744c28;
}

.notice-icon {
  display: grid;
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 750;
}

.message {
  min-height: 18px;
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.message-error {
  color: var(--danger);
}

.message-success {
  color: var(--sage-dark);
}

.app-view {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  height: 68px;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(18px, 3.2vw, 48px);
  border-bottom: 1px solid rgb(210 222 215 / 80%);
  background: rgb(250 252 249 / 92%);
  backdrop-filter: blur(14px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.brand-divider {
  width: 1px;
  height: 19px;
  margin: 0 2px 0 5px;
  background: var(--line-strong);
}

.brand-context {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}

.workspace {
  display: grid;
  min-height: calc(100vh - 68px);
  grid-template-columns: minmax(245px, 292px) minmax(0, 1fr);
}

.history-rail {
  padding: 27px 17px 32px 22px;
  border-right: 1px solid var(--line);
  background: rgb(248 250 247 / 72%);
}

.rail-heading,
.section-label-row,
.plan-topline,
.request-form-footer,
.preference-form-footer,
.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rail-heading h2 {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 18px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--line);
  background: white;
  color: var(--ink);
}

.small-icon {
  width: 30px;
  height: 30px;
  font-size: 19px;
}

.empty-hint {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.history-list {
  display: grid;
  gap: 5px;
  margin-top: 12px;
}

.history-item {
  display: grid;
  width: 100%;
  gap: 8px;
  padding: 11px 11px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background 120ms ease, border-color 120ms ease;
}

.history-item:hover {
  border-color: var(--line);
  background: rgb(255 255 255 / 72%);
}

.history-item.is-selected {
  border-color: #cbded1;
  background: var(--sage-pale);
}

.history-item-title {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.history-item-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a3b0ad;
}

.status-complete {
  background: var(--sage);
}

.status-running {
  background: var(--teal);
  box-shadow: 0 0 0 3px rgb(46 119 121 / 12%);
}

.status-failed {
  background: var(--danger);
}

.rail-divider {
  height: 1px;
  margin: 22px 2px 17px;
  background: var(--line);
}

.preferences-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 12px;
  font-weight: 680;
  list-style: none;
}

.preferences-panel > summary::-webkit-details-marker,
.sources-details > summary::-webkit-details-marker,
.preference-source > summary::-webkit-details-marker {
  display: none;
}

.preferences-panel > summary::before {
  width: 11px;
  color: var(--sage-dark);
  content: "+";
  font-size: 16px;
  line-height: 1;
}

.preferences-panel[open] > summary::before {
  content: "−";
}

.preferences-panel > summary > span:first-of-type {
  flex: 1;
}

.count-pill {
  padding: 3px 7px;
  border-radius: 99px;
  background: white;
  color: var(--muted);
  font-size: 10px;
}

.preferences-panel > .field-hint {
  margin: 12px 0 9px;
}

.preference-form textarea {
  min-height: 71px;
  font-size: 12px;
}

.preference-form-footer {
  margin-top: 7px;
}

.preference-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.preference-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.preference-text {
  display: block;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.preference-source {
  margin-top: 6px;
}

.preference-source summary,
.sources-details summary {
  color: var(--sage-dark);
  cursor: pointer;
  font-size: 10px;
  font-weight: 650;
}

.source-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.main-content {
  width: 100%;
  max-width: 1080px;
  justify-self: center;
  padding: 56px clamp(24px, 5vw, 76px) 90px;
}

.composer-section {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 0 0 58px;
  text-align: center;
}

.welcome-mark {
  display: flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0 auto 21px;
  border: 1px solid #d4e2d8;
  border-radius: 16px;
  background: linear-gradient(145deg, #f9fcf9, #e9f1eb);
  box-shadow: 0 5px 16px rgb(58 105 83 / 8%);
  transform: rotate(-5deg);
}

.welcome-mark span {
  width: 5px;
  border-radius: 10px;
  background: var(--sage);
}

.welcome-mark span:nth-child(1) {
  height: 13px;
}

.welcome-mark span:nth-child(2) {
  height: 21px;
  background: var(--teal);
}

.welcome-mark span:nth-child(3) {
  height: 16px;
}

.composer-section h1 {
  max-width: 650px;
  margin: 12px auto 10px;
  font-size: clamp(34px, 5vw, 48px);
}

.intro-copy {
  max-width: 520px;
  margin: 0 auto 27px;
  font-size: 14px;
}

.request-form {
  padding: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: white;
  box-shadow: 0 9px 28px rgb(29 59 65 / 6%);
  text-align: left;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.request-form:focus-within {
  border-color: #95b7a2;
  box-shadow: 0 0 0 4px rgb(100 139 120 / 10%), 0 9px 28px rgb(29 59 65 / 6%);
}

.request-form textarea {
  min-height: 112px;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 15px;
  resize: vertical;
}

.request-form textarea:focus {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.request-form-footer {
  padding: 6px 5px 4px 8px;
}

.button-arrow {
  font-size: 17px;
  font-weight: 400;
  line-height: 1;
}

.message-inline {
  text-align: left;
}

.privacy-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 17px;
  color: var(--muted);
  font-size: 11px;
}

.lock-glyph {
  display: inline-grid;
  width: 13px;
  height: 13px;
  place-items: center;
  border: 1px solid #9aac9e;
  border-radius: 4px;
  color: var(--sage-dark);
  font-size: 9px;
  line-height: 1;
}

.plan-section {
  width: min(100%, 760px);
  scroll-margin-top: 84px;
  margin: 3px auto 0;
  padding: 25px 27px 28px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 8px 25px rgb(29 59 65 / 4%);
}

.plan-topline {
  align-items: flex-start;
}

.plan-topline h2 {
  margin: 5px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.plan-request {
  margin: 17px 0 15px;
  padding: 12px 14px;
  border-left: 2px solid #a5c2ad;
  border-radius: 0 7px 7px 0;
  background: #f6f9f6;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.plan-status {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
}

.waiting-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 19px 16px;
  border: 1px solid #dce9df;
  border-radius: 11px;
  background: #f7faf7;
}

.waiting-card strong {
  color: var(--ink);
  font-size: 13px;
}

.waiting-card p {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}

.waiting-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgb(46 119 121 / 12%);
  animation: pulse 1.7s ease-in-out infinite;
}

@keyframes pulse {
  50% { box-shadow: 0 0 0 7px rgb(46 119 121 / 5%); }
}

.section-label-row {
  margin: 18px 0 9px;
}

.section-label-row h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.checklist {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.checklist-row {
  display: grid;
  min-height: 47px;
  grid-template-columns: 27px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 5px;
  padding: 5px 7px 5px 10px;
  border: 1px solid #e4ebe7;
  border-radius: 9px;
  background: #fff;
  transition: border-color 120ms ease, background 120ms ease;
}

.checklist-row:focus-within {
  border-color: #a8c4b0;
  background: #fcfefc;
}

.check-label {
  position: relative;
  display: grid;
  width: 26px;
  height: 28px;
  place-items: center;
  cursor: pointer;
}

.check-input {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  opacity: 0;
}

.check-visual {
  display: grid;
  width: 17px;
  height: 17px;
  place-items: center;
  border: 1.5px solid #a9bbb0;
  border-radius: 5px;
  background: white;
  pointer-events: none;
  transition: background 120ms ease, border-color 120ms ease;
}

.check-input:focus-visible + .check-visual {
  outline: 3px solid rgb(46 119 121 / 38%);
  outline-offset: 2px;
}

.check-input:checked + .check-visual {
  border-color: var(--sage-dark);
  background: var(--sage-dark);
}

.check-input:checked + .check-visual::after {
  width: 8px;
  height: 4px;
  border-bottom: 2px solid white;
  border-left: 2px solid white;
  content: "";
  transform: translateY(-1px) rotate(-45deg);
}

.checklist-input {
  min-width: 0;
  min-height: 38px;
  max-height: 220px;
  padding: 8px 7px;
  border-color: transparent;
  background: transparent;
  font-size: 13px;
  line-height: 1.5;
  field-sizing: content;
  overflow-wrap: anywhere;
  overflow-y: auto;
  resize: vertical;
}

.checklist-input:focus {
  border-color: var(--line-strong);
}

.remove-item {
  width: 31px;
  height: 31px;
  color: #81938a;
  font-size: 20px;
}

.remove-item:hover:not(:disabled) {
  border-color: #f0d1cb;
  background: var(--danger-pale);
  color: var(--danger);
}

.button-add {
  min-height: 35px;
  margin-top: 9px;
  padding: 0 10px;
  background: transparent;
  color: var(--sage-dark);
  font-size: 12px;
}

.button-add:hover:not(:disabled) {
  background: var(--sage-pale);
}

.editor-footer {
  align-items: flex-end;
  margin-top: 20px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.save-status {
  color: var(--muted);
  font-size: 11px;
}

.draft-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.sources-details {
  margin-top: 17px;
  padding-top: 12px;
  border-top: 1px solid #edf1ee;
}

.sources-details > summary::before {
  display: inline-block;
  width: 16px;
  content: "+";
  color: var(--sage-dark);
  font-size: 15px;
}

.sources-details[open] > summary::before {
  content: "−";
}

.sources-list {
  display: grid;
  gap: 10px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.source-row {
  padding: 10px 12px;
  border-radius: 8px;
  background: #f7f9f7;
}

.source-content {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  padding: 13px 16px;
  border: 1px solid #cbded1;
  border-radius: 10px;
  background: #f7fbf8;
  box-shadow: var(--shadow);
  color: var(--sage-dark);
  font-size: 13px;
}

.toast-error {
  border-color: #f0d1cb;
  background: var(--danger-pale);
  color: var(--danger);
}

.mobile-only {
  display: none;
}

.menu-glyph {
  display: grid;
  width: 17px;
  gap: 4px;
}

.menu-glyph i {
  height: 1.5px;
  border-radius: 3px;
  background: currentColor;
}

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

@media (max-width: 760px) {
  .topbar {
    height: 61px;
    padding: 0 13px;
  }

  .mobile-only {
    display: inline-grid;
  }

  .brand {
    gap: 8px;
    margin-right: auto;
    margin-left: 8px;
  }

  .brand-context,
  .brand-divider {
    display: none;
  }

  .topbar-actions {
    gap: 0;
  }

  .topbar-actions .button {
    min-height: 36px;
    padding: 0 9px;
    font-size: 11px;
  }

  .topbar-actions #new-request-button span {
    display: none;
  }

  .workspace {
    min-height: calc(100vh - 61px);
    grid-template-columns: minmax(0, 1fr);
  }

  .history-rail {
    display: none;
  }

  .workspace.history-rail-open::before {
    position: fixed;
    z-index: 11;
    inset: 61px 0 0;
    background: rgb(14 31 38 / 30%);
    content: "";
  }

  .workspace.history-rail-open .history-rail {
    position: fixed;
    z-index: 12;
    top: 61px;
    bottom: 0;
    left: 0;
    display: block;
    width: min(315px, calc(100vw - 52px));
    overflow-y: auto;
    border-right: 1px solid var(--line);
    background: #f8faf7;
    box-shadow: 12px 0 30px rgb(21 46 58 / 12%);
  }

  .main-content {
    padding: 40px 20px 65px;
  }

  .composer-section {
    padding-bottom: 42px;
  }

  .composer-section h1 {
    font-size: clamp(33px, 9vw, 43px);
  }

  .intro-copy {
    font-size: 13px;
  }

  .plan-section {
    padding: 21px 17px 22px;
  }
}

@media (max-width: 450px) {
  .auth-card {
    padding: 31px 24px 27px;
  }

  .topbar-actions #logout-button {
    padding: 0 7px;
  }

  .topbar-actions #new-request-button {
    padding: 0 8px;
  }

  .main-content {
    padding-right: 14px;
    padding-left: 14px;
  }

  .request-form textarea {
    min-height: 101px;
    font-size: 14px;
  }

  .request-form-footer .button {
    min-height: 39px;
    padding: 0 12px;
    font-size: 12px;
  }

  .plan-topline h2 {
    font-size: 21px;
  }

  .notice-warning {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
