:root {
  --ink: #17201c;
  --ink-soft: #3f4b45;
  --paper: #f6f1e7;
  --paper-deep: #ece3d2;
  --cream: #fffaf0;
  --green: #123c35;
  --green-bright: #1f7a66;
  --teal: #0f766e;
  --orange: #e2602f;
  --yellow: #f4b942;
  --line: rgba(23, 32, 28, 0.16);
  --shadow: 0 10px 30px rgba(23, 32, 28, 0.12);
  --radius: 18px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Trebuchet MS", "Avenir Next", Verdana, sans-serif;
  --mono: "Cascadia Code", Consolas, "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 4%, rgba(244, 185, 66, 0.24), transparent 24rem),
    radial-gradient(circle at 92% 16%, rgba(31, 122, 102, 0.16), transparent 20rem),
    repeating-linear-gradient(0deg, rgba(23, 32, 28, 0.035) 0, rgba(23, 32, 28, 0.035) 1px, transparent 1px, transparent 44px),
    var(--paper);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  max-width: 860px;
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: 86px;
  position: relative;
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  color: var(--cream);
  background: linear-gradient(135deg, var(--green) 0%, #1a5749 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 6px 22px rgba(18, 60, 53, 0.28);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: var(--green);
  background: var(--yellow);
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 700;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.16);
}

.brand-copy {
  display: grid;
  line-height: 1.15;
}

.brand-copy strong {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.01em;
}

.brand-copy small {
  color: rgba(255, 250, 240, 0.72);
  font-size: 11px;
  margin-top: 3px;
}

.mast-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #d7a344;
  box-shadow: 0 0 0 4px rgba(247, 185, 66, 0.18);
}

.status-dot.online {
  background: #72e0b1;
  box-shadow: 0 0 0 4px rgba(114, 224, 177, 0.2);
}

.status-dot.offline {
  background: #ff7b62;
  box-shadow: 0 0 0 4px rgba(255, 123, 98, 0.18);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 13px;
  color: var(--cream);
  background: rgba(255, 255, 255, 0.08);
  font-size: 18px;
}

.content {
  padding: 20px 18px 12px;
}

.view {
  animation: rise 0.35s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.home-hero {
  position: relative;
  padding: 30px 22px 28px;
  margin-bottom: 24px;
  overflow: hidden;
  border-radius: 28px;
  color: var(--cream);
  background:
    linear-gradient(140deg, rgba(18, 60, 53, 0.98), rgba(31, 122, 102, 0.92)),
    var(--green);
  box-shadow: var(--shadow);
}

.home-hero::after {
  content: "";
  position: absolute;
  width: 210px;
  height: 210px;
  right: -72px;
  top: -80px;
  border: 34px solid rgba(244, 185, 66, 0.2);
  border-radius: 50%;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.home-hero .eyebrow {
  color: var(--yellow);
}

.home-hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(32px, 8vw, 52px);
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.hero-note {
  max-width: 34em;
  margin: 16px 0 0;
  color: rgba(255, 250, 240, 0.78);
  font-size: 14px;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-label {
  margin: 0;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 700;
}

.section-hint {
  margin: 3px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.primary-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  color: var(--cream);
  background: var(--green-bright);
  font-weight: 700;
  box-shadow: 0 6px 0 #0d4c40, 0 10px 18px rgba(31, 122, 102, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.primary-button:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #0d4c40, 0 6px 12px rgba(31, 122, 102, 0.22);
}

.primary-button.wide {
  width: 100%;
  margin-top: 6px;
}

.session-list {
  display: grid;
  gap: 12px;
}

.session-card {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  text-align: left;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.9);
  box-shadow: 0 5px 0 var(--paper-deep);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.session-card:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--paper-deep);
}

.session-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.session-number {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 700;
  color: var(--teal);
}

.session-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 11px;
}

.badge {
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--ink);
  background: var(--paper-deep);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge.running {
  color: #0c5a3d;
  background: #d9f3e4;
}

.session-preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.session-path {
  display: block;
  margin-top: 10px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  border: 2px dashed var(--line);
  border-radius: 24px;
  padding: 42px 22px;
  text-align: center;
  color: var(--ink-soft);
}

.empty-glyph {
  margin: 0;
  font-family: var(--serif);
  font-size: 54px;
  color: var(--teal);
}

.empty-state h2 {
  margin: 6px 0;
  font-family: var(--serif);
  color: var(--ink);
}

.page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.1;
}

.back-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.9);
  font-size: 19px;
}

.panel-form {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  background: rgba(255, 250, 240, 0.88);
  box-shadow: 0 8px 0 var(--paper-deep);
}

.panel-form label {
  display: grid;
  gap: 7px;
}

.panel-form label > span {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px 13px;
  color: var(--ink);
  background: var(--cream);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

textarea {
  resize: vertical;
}

.form-note {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.form-note code {
  font-family: var(--mono);
  font-size: 11px;
}

.chat-head {
  align-items: start;
}

.chat-title-wrap {
  min-width: 0;
}

.chat-title-wrap h1 {
  overflow: hidden;
  font-size: 23px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cwd-line {
  display: block;
  max-width: 70vw;
  margin-top: 4px;
  overflow: hidden;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread {
  display: grid;
  gap: 12px;
  min-height: 40vh;
  padding-bottom: 16px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(255, 250, 240, 0.92);
  box-shadow: 0 4px 0 rgba(236, 227, 210, 0.8);
}

.item.user {
  margin-left: 8%;
  color: var(--cream);
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 4px 0 #0d4038;
}

.item.reasoning {
  background: rgba(244, 185, 66, 0.12);
}

.item.command, .item.fileChange {
  font-family: var(--mono);
  font-size: 12px;
}

.item-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal);
}

.item.user .item-label {
  color: rgba(255, 250, 240, 0.72);
}

.item-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.item-code {
  margin: 6px 0 0;
  overflow-x: auto;
  padding: 10px;
  border-radius: 10px;
  color: #d8f0e6;
  background: #10241f;
  font-family: var(--mono);
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
}

.item-status {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 11px;
}

.approval-dock {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.approval-card {
  border: 2px solid var(--orange);
  border-radius: 18px;
  padding: 14px 16px;
  background: #fff3e6;
  box-shadow: 0 5px 0 #e8d3b7;
}

.approval-card h3 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 17px;
}

.approval-card p {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.approval-actions button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--ink);
  background: var(--cream);
  font-size: 12px;
  font-weight: 700;
}

.approval-actions .approve {
  border-color: var(--green-bright);
  color: var(--cream);
  background: var(--green-bright);
}

.approval-actions .deny {
  border-color: var(--orange);
  color: #7a2d12;
  background: #ffe4d3;
}

.composer {
  position: sticky;
  bottom: 76px;
  display: flex;
  align-items: end;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 250, 240, 0.96);
  box-shadow: 0 10px 30px rgba(23, 32, 28, 0.14);
}

.composer textarea {
  min-height: 46px;
  max-height: 130px;
  border: 0;
  background: transparent;
  box-shadow: none;
  resize: none;
}

.composer textarea:focus {
  box-shadow: none;
}

.send-button {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 16px;
  color: var(--cream);
  background: var(--green-bright);
  font-size: 20px;
  box-shadow: 0 4px 0 #0d4c40;
}

.send-button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #0d4c40;
}

.terminal-output {
  margin-top: 14px;
  border-radius: 18px;
  padding: 14px;
  color: #d8f0e6;
  background: #10241f;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 120px;
  max-height: 50vh;
  overflow: auto;
}

.terminal-placeholder {
  margin: 0;
  color: rgba(216, 240, 230, 0.5);
}

.terminal-line {
  margin: 0;
}

.terminal-meta {
  margin: 10px 0 0;
  color: var(--yellow);
  font-size: 11px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 10px;
  z-index: 30;
  display: flex;
  gap: 6px;
  width: min(92vw, 460px);
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  background: rgba(18, 60, 53, 0.96);
  box-shadow: 0 14px 40px rgba(18, 60, 53, 0.32);
  transform: translateX(-50%);
  backdrop-filter: blur(12px);
}

.nav-item {
  flex: 1;
  display: grid;
  place-items: center;
  gap: 2px;
  border: 0;
  border-radius: 16px;
  padding: 8px 4px;
  color: rgba(255, 250, 240, 0.72);
  background: transparent;
  font-size: 16px;
}

.nav-item small {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.nav-item.active {
  color: var(--green);
  background: var(--yellow);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 50;
  max-width: min(90vw, 420px);
  padding: 12px 16px;
  border-radius: 14px;
  color: var(--cream);
  background: var(--green);
  box-shadow: var(--shadow);
  font-size: 13px;
  transform: translateX(-50%);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(18, 60, 53, 0.5);
  backdrop-filter: blur(6px);
}

.modal {
  width: min(94vw, 440px);
  max-height: 80vh;
  overflow: auto;
  border-radius: 22px;
  padding: 18px;
  background: var(--cream);
  box-shadow: var(--shadow);
}

.modal h2 {
  margin: 0 0 10px;
  font-family: var(--serif);
}

.modal .question {
  margin: 14px 0 6px;
  font-weight: 700;
}

.modal .choice-grid {
  display: grid;
  gap: 8px;
}

.modal .choice-grid button {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 11px 13px;
  text-align: left;
  background: var(--paper);
}

.modal .choice-grid button strong {
  display: block;
}

.modal .choice-grid button small {
  color: var(--ink-soft);
}

.modal input[type="text"] {
  margin-top: 8px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.modal-actions button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--paper);
  font-weight: 700;
}

.modal-actions .primary {
  border-color: var(--green-bright);
  color: var(--cream);
  background: var(--green-bright);
}

@media (min-width: 720px) {
  .content {
    padding-left: 26px;
    padding-right: 26px;
  }

  .session-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .thread {
    max-width: 720px;
    margin: 0 auto;
  }

  .composer {
    max-width: 720px;
    margin: 0 auto;
  }
}

@media (max-width: 420px) {
  .brand-copy small {
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .home-hero {
    padding: 24px 18px 22px;
  }

  .session-card {
    padding: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
