:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --ink: #1f2528;
  --muted: #657176;
  --line: #d7e0df;
  --accent: #176b6a;
  --accent-strong: #0e4f50;
  --accent-soft: #e4f1ee;
  --gold: #9f6b12;
  --rose: #a84e59;
  --shadow: 0 18px 48px rgba(20, 43, 48, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Hiragino Sans", "Yu Gothic", sans-serif;
  letter-spacing: 0;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  min-height: 100vh;
}

.input-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #eef4f3;
  padding: 24px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 30px;
}

.brand > span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
}

.brand p,
.muted {
  color: var(--muted);
}

.input-group {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.group-label,
.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.file-card {
  position: relative;
  display: block;
  margin-bottom: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.file-card input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.file-card span,
.file-card strong {
  display: block;
}

.file-card span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

.file-card strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-label {
  display: block;
  margin: 14px 0 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  line-height: 1.55;
}

textarea:focus,
button:focus-visible,
.file-card:focus-within {
  outline: 3px solid rgba(23, 107, 106, 0.2);
  outline-offset: 2px;
}

.primary-button,
.secondary-actions button,
.copy-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #fff;
}

.secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.secondary-actions button,
.copy-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  gap: 20px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 18px;
}

.topbar h2 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}

.status-line {
  max-width: 440px;
  color: var(--muted);
  text-align: right;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card,
.surface,
.side-block,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(20, 43, 48, 0.06);
}

.metric-card {
  padding: 16px;
}

.metric-card span,
.metric-card p {
  color: var(--muted);
  font-size: 13px;
}

.metric-card span,
.metric-card strong,
.metric-card p {
  display: block;
  margin: 0;
}

.metric-card strong {
  margin: 7px 0 4px;
  font-size: 28px;
  line-height: 1;
}

.tabbar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 18px;
  padding-bottom: 2px;
}

.tabbar button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  white-space: nowrap;
}

.tabbar button.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 330px);
  gap: 18px;
  align-items: start;
}

.main-panel,
.side-panel {
  min-width: 0;
}

.panel-section {
  margin-bottom: 18px;
}

.panel-section > h2,
.empty-state h2 {
  margin: 0 0 10px;
  max-width: 880px;
  font-size: 30px;
  line-height: 1.2;
}

.lead {
  max-width: 920px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.8;
}

.panel-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

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

.panel-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.surface {
  padding: 18px;
}

.surface h3,
.surface h4,
.side-block h3,
.theme-item h4,
.pattern-item h4,
.article-item h4,
.seed-item h4 {
  margin: 0 0 8px;
}

.surface p,
.theme-item p,
.pattern-item p,
.article-item p,
.seed-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

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

.insight {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong) !important;
  font-weight: 700;
}

.tag-list,
.word-row,
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag-list span,
.word-row span,
.article-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 4px 9px;
  font-size: 12px;
}

.tag-list.small span {
  min-height: 26px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-head h3 {
  margin: 0;
  font-size: 20px;
}

.theme-list,
.pattern-list,
.article-list,
.seed-list {
  display: grid;
  gap: 10px;
}

.theme-item,
.pattern-item,
.article-item,
.seed-item {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.theme-item,
.pattern-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.theme-metrics {
  min-width: 76px;
  border-left: 1px solid var(--line);
  padding-left: 14px;
  text-align: right;
}

.theme-metrics strong,
.theme-metrics span {
  display: block;
}

.theme-metrics strong {
  font-size: 24px;
}

.theme-metrics span,
.pattern-item > span {
  color: var(--muted);
  font-size: 12px;
}

.mini {
  min-height: 160px;
}

.quote {
  margin-bottom: 10px !important;
  color: var(--ink) !important;
  font-weight: 800;
}

.post-card {
  display: grid;
  gap: 12px;
}

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

.card-top span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
}

.copy-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

pre {
  overflow-x: auto;
  margin: 0;
  border-radius: 8px;
  background: #eef3f5;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
}

dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

dd {
  margin: 0;
  line-height: 1.55;
}

.focus-card {
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr);
  gap: 20px;
  align-items: start;
}

.action-list {
  margin: 0;
  padding-left: 22px;
  line-height: 1.8;
}

.loop-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.loop-step {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.loop-step span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.loop-step p {
  margin: 0;
  line-height: 1.55;
}

.article-item {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.55fr);
}

.article-item ol {
  margin: 0;
  padding-left: 22px;
  line-height: 1.8;
}

.article-meta {
  margin-top: 12px;
}

.seed-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.seed-grid p {
  border-left: 3px solid var(--accent);
  background: #f1f6f5;
  padding: 8px 10px;
}

.seed-grid strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
}

.side-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
}

.side-block {
  padding: 16px;
}

.compact-list,
.note-list {
  display: grid;
  gap: 10px;
}

.compact-post {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.compact-post:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.compact-post p {
  margin: 0 0 7px;
  line-height: 1.55;
}

.compact-post div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.compact-post span {
  color: var(--muted);
  font-size: 11px;
}

.note-list p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.checklist p {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 10px 0 0;
  line-height: 1.45;
}

.checklist span {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 99px;
  background: var(--accent);
}

.empty-state {
  min-height: 420px;
  display: grid;
  place-content: center;
  gap: 18px;
  padding: 36px;
  text-align: center;
}

.empty-state p {
  max-width: 560px;
  margin: 0 auto;
  color: var(--muted);
  line-height: 1.8;
}

.empty-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: min(620px, 100%);
  margin: 0 auto;
}

.empty-grid div {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.empty-grid strong {
  color: var(--accent-strong);
  font-size: 28px;
}

@media (max-width: 1180px) {
  .content-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .panel-grid.three,
  .loop-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .input-rail {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .input-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .input-group .group-label,
  .action-area .group-label {
    grid-column: 1 / -1;
  }

  .field-label,
  textarea,
  .action-area .primary-button,
  .secondary-actions {
    grid-column: 1 / -1;
  }

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

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

  .status-line {
    text-align: left;
  }
}

@media (max-width: 680px) {
  .workspace,
  .input-rail {
    padding: 18px;
  }

  .input-group,
  .panel-grid.two,
  .panel-grid.three,
  .loop-row,
  .side-panel,
  .article-item,
  .seed-grid,
  .focus-card,
  .empty-grid {
    grid-template-columns: 1fr;
  }

  .theme-item,
  .pattern-item {
    grid-template-columns: 1fr;
  }

  .theme-metrics {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 10px 0 0;
    text-align: left;
  }

  .panel-section > h2,
  .empty-state h2 {
    font-size: 24px;
  }
}
