:root {
  color-scheme: light;
  --bg: #f6f2e8;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #1f2523;
  --muted: #67706d;
  --line: #ded7ca;
  --accent: #146c5f;
  --accent-strong: #0f554b;
  --violet: #7856a3;
  --amber: #a66a16;
  --red: #b33b36;
  --shadow: 0 10px 30px rgba(39, 33, 24, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 340px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

body.web-mode {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.72), rgba(246, 242, 232, 0.88)),
    var(--bg);
}

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

button {
  cursor: pointer;
}

.shell {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  gap: 12px;
  padding: 34px 16px 16px;
  overflow-y: auto;
}

.web-mode .shell {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 28px 18px 32px;
}

.web-mode .topbar,
.web-mode .tabs,
.web-mode .view {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-lockup {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 3px 8px rgba(39, 33, 24, 0.18));
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1.12;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
  line-height: 1.25;
}

.browser-actions {
  display: grid;
  grid-template-columns: repeat(4, 30px);
  gap: 4px;
}

.icon-button,
.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  border: 1px solid transparent;
  border-radius: 7px;
  min-height: 32px;
  font-weight: 700;
}

.icon-button {
  display: grid;
  place-items: center;
  min-width: 30px;
  background: var(--surface-strong);
  border-color: var(--line);
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
}

.primary-button {
  background: var(--accent);
  color: white;
  padding: 0 12px;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button,
.ghost-button {
  background: var(--surface-strong);
  border-color: var(--line);
  color: var(--ink);
  padding: 0 10px;
}

.danger-button {
  background: #fff6f4;
  border-color: #ebc4bf;
  color: var(--red);
  padding: 0 10px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 36px;
  padding: 0 10px;
}

textarea {
  min-height: 78px;
  resize: vertical;
  padding: 10px;
  line-height: 1.35;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 95, 0.14);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: #e8dfd0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tab {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab.is-active {
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(49, 38, 23, 0.1);
}

.view {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.view.is-active {
  display: flex;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #e1f0eb;
  color: var(--accent-strong);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.stack {
  display: grid;
  gap: 10px;
}

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

.workflow-button-group {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.workflow-button-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.workflow-count {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: #e1f0eb;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.workflow-button-list {
  display: grid;
  gap: 8px;
}

.workflow-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.workflow-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: 114px;
}

.workflow-path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 9px;
  background: #eef7f4;
  border: 1px solid rgba(20, 108, 95, 0.16);
  border-radius: 7px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
}

.workflow-path-button {
  width: 100%;
  text-align: left;
}

.workflow-path-button:hover,
.workflow-path-button.is-open {
  background: #e7f3ef;
  border-color: rgba(20, 108, 95, 0.28);
}

.workflow-caret {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.workflow-path b {
  color: var(--muted);
}

.workflow-prompt-menu {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #fbfefa;
  border: 1px solid rgba(20, 108, 95, 0.18);
  border-radius: 7px;
}

.workflow-prompt-menu[hidden] {
  display: none;
}

.workflow-prompt-button,
.workflow-launch-button {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 2px 10px;
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 9px;
  text-align: left;
}

.workflow-prompt-button:hover,
.workflow-launch-button:hover {
  border-color: rgba(20, 108, 95, 0.28);
  background: #f8fcfb;
}

.workflow-prompt-button:disabled,
.workflow-launch-button:disabled {
  cursor: wait;
  opacity: 0.82;
}

.workflow-prompt-button.is-sent,
.workflow-launch-button.is-sent {
  border-color: rgba(20, 108, 95, 0.28);
  background: #e8f6f1;
}

.workflow-prompt-button.is-error,
.workflow-launch-button.is-error {
  border-color: #ebc4bf;
  background: #fff6f4;
}

.prompt-step-label {
  grid-row: span 2;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  text-transform: uppercase;
}

.prompt-action {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompt-preview-text {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.workflow-steps {
  display: grid;
  gap: 8px;
}

.workflow-step {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 2px 10px;
  padding: 9px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.workflow-step span {
  grid-row: span 2;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.workflow-step h4,
.workflow-rules h4 {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.2;
}

.workflow-step p,
.logic-row p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.workflow-rules {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #f6f1e8;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.logic-row {
  display: grid;
  gap: 2px;
  padding-top: 8px;
  border-top: 1px solid rgba(103, 112, 109, 0.18);
}

.form-grid {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 10px;
}

.form-actions,
.utility-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.utility-row {
  justify-content: space-between;
}

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

.task-card {
  gap: 9px;
  padding: 12px;
}

.task-card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.task-card-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.item-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 8px;
}

.item-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.item-title h3 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swatch {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
}

.meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.task-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: 142px;
}

.tiny-button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

.task-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.38;
}

.complete-button {
  border-color: rgba(20, 108, 95, 0.24);
  background: #e8f6f1;
  color: var(--accent-strong);
}

.delete-button {
  border-color: #ebc4bf;
  background: #fff6f4;
  color: var(--red);
}

.prompt-box,
.note-body {
  border-left: 3px solid var(--violet);
  background: #f8f3ff;
  border-radius: 6px;
  padding: 9px;
  color: #33263f;
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.prompt-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border-left: 3px solid var(--violet);
  border-radius: 7px;
  background: #f5effd;
  padding: 8px 8px 8px 10px;
}

.prompt-preview {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.prompt-label {
  color: #6c5290;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

.prompt-value {
  min-width: 0;
  overflow: hidden;
  color: #33263f;
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompt-copy-button {
  background: #ffffff;
  border-color: #d9cce8;
  color: #4b3566;
}

.empty-state {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.path-text {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

@media (max-width: 370px) {
  .shell {
    padding: 14px 12px;
  }

  .browser-actions {
    grid-template-columns: repeat(2, 32px);
  }

  .split {
    grid-template-columns: 1fr;
  }
}
