:root {
  --ink: #12222f;
  --paper: #f8f7f2;
  --panel: rgba(255, 255, 255, 0.84);
  --line: #1f3548;
  --accent: #1f7a64;
  --accent-warm: #db6a40;
  --muted: #5e6c77;
  --ok: #17613e;
  --warn: #8e4300;
  --danger: #8a1f2c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 15%, #ffe4b8 0%, #f7f7f3 40%),
    radial-gradient(circle at 85% 5%, #cdece2 0%, transparent 34%),
    linear-gradient(140deg, #f6f4ec 0%, #f6f5ee 60%, #f4d8cb 100%);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background-image: radial-gradient(#0f223322 0.9px, transparent 0.9px);
  background-size: 5px 5px;
}

.shell {
  position: relative;
  width: min(980px, 92vw);
  margin: 30px auto 56px;
  display: grid;
  gap: 14px;
}

.hero {
  border: 2px solid var(--line);
  box-shadow: 8px 8px 0 var(--line);
  background: rgba(255, 255, 255, 0.74);
  padding: 24px;
  animation: rise 0.55s ease both;
}

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

h1 {
  margin: 0;
  line-height: 1.05;
  font-size: clamp(30px, 7vw, 50px);
}

.sub {
  margin: 10px 0 0;
  max-width: 56ch;
}

.hero-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.pwa-meta {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.pwa-network-bar {
  margin: 8px 0 0;
  border: 2px solid var(--warn);
  background: #fff5e7;
  color: #7d3e00;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.pwa-network-bar.is-online {
  border-color: var(--ok);
  background: #ebf8ef;
  color: var(--ok);
}

.pwa-top-actions {
  margin-top: 10px;
}

.stepper {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.step {
  border: 2px solid var(--line);
  background: var(--panel);
  padding: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  transition: transform 0.15s ease;
}

.step-index {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  background: #fff;
  font-weight: 700;
}

.step p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.step.is-active {
  transform: translateY(-2px);
  box-shadow: 4px 4px 0 var(--line);
}

.step.is-done {
  border-color: var(--ok);
}

.step.is-done .step-index {
  border-color: var(--ok);
  background: #e7f6ee;
  color: var(--ok);
}

.panel {
  border: 2px solid var(--line);
  box-shadow: 5px 5px 0 rgba(18, 34, 47, 0.58);
  background: var(--panel);
  padding: 16px;
  animation: rise 0.55s ease both;
}

.journey-panel {
  border-style: dashed;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 8px;
}

h2 {
  margin: 0;
  font-size: 20px;
}

h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.badge {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.meta {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.compact-meta {
  margin: 8px 0 0;
}

.runtime-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

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

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

.grid.compact {
  margin-bottom: 8px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  padding: 10px;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

.actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.journey-track {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.journey-pill {
  border: 2px solid var(--line);
  padding: 6px 10px;
  background: #f1f4f8;
  font-size: 12px;
  font-weight: 700;
  color: #354756;
}

.journey-pill.is-active {
  background: #fff2de;
  border-color: #9a5a00;
  color: #6e3d00;
}

.journey-pill.is-done {
  background: #e8f8ef;
  border-color: var(--ok);
  color: var(--ok);
}

.inline-input {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}

.inline-input input {
  width: 84px;
  padding: 6px 8px;
}

.inline-input select {
  width: auto;
  min-width: 98px;
  padding: 6px 8px;
}

.history-keyword input {
  width: 200px;
}

.history-filter-row {
  margin-top: 0;
}

.history-filter-row .inline-input input {
  width: auto;
  min-width: 140px;
}

.history-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 13px;
  color: var(--muted);
}

button {
  border: 2px solid var(--line);
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
  transition: filter 0.12s ease;
}

button:hover {
  filter: brightness(0.96);
}

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

button.tone-warm {
  background: var(--accent-warm);
}

button.tone-ghost {
  background: #2f475b;
}

.notice {
  margin: 10px 0 0;
  border: 2px solid var(--line);
  background: #edf4fb;
  padding: 8px 10px;
  font-size: 13px;
}

.notice.is-success {
  border-color: var(--ok);
  background: #e8f8ef;
}

.notice.is-warning {
  border-color: var(--warn);
  background: #fff4e8;
}

.notice.is-error {
  border-color: var(--danger);
  background: #ffecee;
}

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

.summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 10px;
}

.feedback-card,
.summary-card {
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  padding: 12px;
}

.assistant-reply {
  margin: 0;
  line-height: 1.6;
  white-space: pre-wrap;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.next-line {
  margin: 8px 0;
  display: grid;
  gap: 4px;
}

.next-line small,
.summary-card small {
  color: var(--muted);
}

.ofnr-list,
.progress-list {
  margin: 8px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.conversation-list {
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  min-height: 70px;
  max-height: 280px;
  overflow: auto;
  padding: 10px;
}

.history-session-list {
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  min-height: 70px;
  max-height: 320px;
  overflow: auto;
  padding: 10px;
}

.history-session-card {
  border: 1px solid #d4dde6;
  background: #f9fbfd;
  padding: 8px;
  margin-bottom: 8px;
  display: grid;
  gap: 6px;
}

.history-risk-group {
  margin-bottom: 10px;
}

.history-risk-head {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.history-session-head {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.history-session-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.history-session-snippet {
  margin: 0;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.45;
}

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

.turn-card {
  border: 1px solid #d4dde6;
  background: #f9fbfd;
  padding: 8px;
  margin-bottom: 8px;
  scroll-margin-top: 12px;
}

.turn-card p {
  margin: 4px 0;
  font-size: 13px;
  line-height: 1.5;
}

.turn-card .turn-head {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
}

.turn-card.is-highlight {
  border: 2px solid var(--accent);
  background: #ecfaf5;
}

.turn-keyline {
  margin-top: 6px;
  border-left: 3px solid var(--accent);
  padding-left: 8px;
  color: #194f40;
}

.turn-keyline strong {
  color: #153d33;
}

mark {
  background: #ffe4b2;
  color: inherit;
}

.empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.summary-card p {
  margin: 8px 0;
  display: grid;
  gap: 4px;
}

.summary-value {
  display: inline-block;
  white-space: pre-wrap;
  line-height: 1.5;
}

.summary-actions {
  margin-top: 8px;
}

.advanced-block {
  margin-top: 10px;
  border: 2px dashed #9ab0c4;
  background: #f6fbff;
  padding: 8px 10px;
}

.advanced-block summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #355068;
}

.advanced-block label {
  margin-top: 8px;
}

.message-starter-row button {
  padding: 6px 10px;
  font-size: 12px;
}

.share-template-block {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

#shareTemplatePreview {
  min-height: 120px;
  border: 2px solid var(--line);
  background: #f3f8fc;
  line-height: 1.5;
  resize: vertical;
}

pre {
  margin: 0;
  max-height: 300px;
  overflow: auto;
  border: 2px solid var(--line);
  background: #132132;
  color: #ecf5ff;
  padding: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}

.is-hidden {
  display: none !important;
}

.install-guide-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 25, 34, 0.45);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 14px;
}

.install-guide-card {
  width: min(540px, 92vw);
  border: 2px solid var(--line);
  background: #fffdf8;
  box-shadow: 8px 8px 0 rgba(18, 34, 47, 0.58);
  padding: 14px;
}

.install-guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.install-guide-head h3 {
  margin: 0;
}

.install-guide-head button {
  padding: 6px 10px;
}

.install-guide-steps {
  margin: 10px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  line-height: 1.5;
  font-size: 14px;
}

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

@media (max-width: 980px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .stepper,
  .grid.two,
  .feedback-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .panel-title-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .install-guide-card {
    width: 100%;
    box-shadow: 5px 5px 0 rgba(18, 34, 47, 0.58);
  }
}
