:root {
  --paper: #f1efe9;
  --paper-deep: #ddd8ce;
  --ink: #201d1a;
  --muted: #5a5854;
  --line: rgba(56, 56, 54, 0.16);
  --accent: #445560;
  --accent-soft: rgba(68, 85, 96, 0.12);
  --moss: #5a655a;
  --slate: #4c5d69;
  --gold: #8d8772;
  --shadow: 0 22px 54px rgba(26, 24, 21, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(90, 101, 90, 0.08), transparent 24%),
    radial-gradient(circle at top right, rgba(86, 97, 107, 0.08), transparent 28%),
    linear-gradient(180deg, #f7f5f0 0%, #e7e4dc 100%);
  font-family:
    "Avenir Next",
    "Hiragino Sans",
    "Yu Gothic",
    "Trebuchet MS",
    sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 11px,
      rgba(78, 74, 68, 0.02) 11px,
      rgba(78, 74, 68, 0.02) 12px
    );
  opacity: 0.7;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1400px, calc(100vw - 32px));
  margin: 22px auto 40px;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.54), rgba(255, 255, 255, 0.24)),
    var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 72px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent);
  pointer-events: none;
}

.hero-panel,
.toolbar,
.summary-panel,
.init-panel,
.system-panel,
.diary-panel,
.backstage-panel {
  animation: rise 540ms ease both;
}

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

.hero-panel {
  padding: 28px 30px 30px;
  margin-bottom: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.26)),
    var(--paper);
}

.eyebrow,
.panel-kicker,
.toolbar-label,
.metric-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  color: var(--muted);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 20px;
  align-items: start;
}

h1,
h2,
h3 {
  margin: 0;
  font-family:
    "Yu Mincho",
    "Hiragino Mincho ProN",
    "BIZ UDPMincho",
    "Iowan Old Style",
    "Palatino Linotype",
    serif;
  font-weight: 600;
  letter-spacing: 0.01em;
}

h1 {
  margin-top: 8px;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.06;
}

h2 {
  font-size: clamp(1.3rem, 2vw, 1.85rem);
  line-height: 1.18;
}

.hero-copy {
  max-width: 60ch;
  margin: 14px 0 0;
  font-size: 15px;
  line-height: 1.82;
  color: #2d2a26;
}

.hero-copy span {
  color: var(--accent);
  font-weight: 700;
}

.hero-note {
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px dashed rgba(89, 98, 106, 0.18);
  color: var(--slate);
  font-size: 14px;
  line-height: 1.7;
}

.hero-note strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--ink);
}

.hero-note p {
  margin: 0;
}

.toolbar {
  padding: 18px 20px;
  margin-bottom: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.22)),
    var(--paper-deep);
}

.toolbar-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 18px;
  align-items: start;
}

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

.segmented,
.day-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

button {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.segmented button,
.day-tabs button {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(66, 69, 72, 0.14);
  background: rgba(255, 255, 255, 0.56);
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.segmented button:hover,
.day-tabs button:hover {
  transform: translateY(-1px);
}

.segmented button.is-active,
.day-tabs button.is-active {
  background: linear-gradient(180deg, rgba(68, 85, 96, 0.24), rgba(68, 85, 96, 0.12));
  border-color: rgba(68, 85, 96, 0.36);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(68, 85, 96, 0.12), 0 4px 16px rgba(68, 85, 96, 0.08);
}

.track-overview {
  margin-top: 14px;
}

.track-overview-head {
  margin-bottom: 14px;
}

.track-overview-head h2 {
  margin-bottom: 9px;
  font-size: clamp(1.55rem, 2.3vw, 2.2rem);
}

.track-overview-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.overview-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
  margin-bottom: 18px;
}

.content-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}

.summary-panel,
.init-panel,
.system-panel,
.diary-panel,
.backstage-panel {
  padding: 22px 22px 24px;
}

.panel-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.panel-header h2 {
  line-height: 1.2;
}

.panel-toggle-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  text-align: left;
  padding: 0;
  margin: 0 0 18px;
}

.panel-toggle-header .panel-header {
  margin-bottom: 0;
}

.panel-toggle-label {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 62px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(66, 69, 72, 0.14);
  background: rgba(255, 255, 255, 0.52);
  color: var(--accent);
  font-size: 12px;
}

.panel-toggle-label::before {
  content: "▸";
  font-size: 11px;
  line-height: 1;
}

.panel-toggle-header.is-open .panel-toggle-label {
  background: rgba(68, 85, 96, 0.12);
  border-color: rgba(68, 85, 96, 0.24);
}

.panel-toggle-header.is-open .panel-toggle-label::before {
  content: "▾";
}

.summary-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

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

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

.mini-card,
.init-card,
.state-card,
.trace-card,
.scene-card,
.memory-card,
.reflection-card {
  padding: 14px 15px;
  border-radius: 18px;
  border: 1px solid rgba(61, 60, 57, 0.1);
  background: rgba(255, 255, 255, 0.56);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.mini-card strong,
.init-card strong,
.state-card strong,
.trace-card strong,
.scene-card strong,
.memory-card strong,
.reflection-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  letter-spacing: 0.03em;
  color: var(--ink);
}

.small-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

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

.init-flow-stack {
  display: grid;
  gap: 12px;
  align-content: start;
}

.init-flow-card {
  padding: 14px 15px;
  border-radius: 18px;
  border: 1px solid rgba(61, 60, 57, 0.11);
  background: rgba(255, 255, 255, 0.54);
  height: fit-content;
}

.generated-card {
  display: grid;
  gap: 14px;
}

.compact-input {
  align-self: start;
}

.flow-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.flow-head strong {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.flow-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--accent);
}

.flow-arrow.vertical {
  min-height: 34px;
  opacity: 0.8;
}

.flow-label {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.08em;
  line-height: 1.1;
  white-space: nowrap;
}

.flow-label.human {
  color: #6c655c;
  background: rgba(109, 103, 94, 0.1);
}

.flow-label.ai {
  color: #445560;
  background: rgba(68, 85, 96, 0.12);
}

.person-name {
  margin-bottom: 8px !important;
  font-family:
    "Yu Mincho",
    "Hiragino Mincho ProN",
    "BIZ UDPMincho",
    serif;
  font-size: 20px !important;
  letter-spacing: 0.02em;
}

.metric-pill-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 18px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(59, 40, 28, 0.12);
}

.pill.good {
  color: var(--moss);
  border-color: rgba(106, 112, 80, 0.24);
}

.pill.warn {
  color: var(--accent);
  border-color: rgba(68, 85, 96, 0.24);
}

.trait-text-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.trait-text-row {
  padding: 12px 13px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(61, 60, 57, 0.09);
}

.trait-text-row strong {
  display: inline-block;
  margin: 0 8px 6px 0;
  font-size: 13px;
}

.trait-level {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--accent);
  background: rgba(68, 85, 96, 0.12);
}

.trait-text-row p {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
}

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

.stack-list li {
  margin-left: 18px;
  line-height: 1.6;
  font-size: 13px;
}

.generated-card .stack-list {
  margin: 0;
}

.labeled-list-item {
  list-style: none;
  margin-left: 0 !important;
}

.labeled-list-head {
  display: flex;
  align-items: baseline;
  gap: 0;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.labeled-list-head strong {
  display: inline;
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.03em;
}

.labeled-list-head span {
  font-size: 13px;
  color: var(--ink);
}

.pipeline-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.pipeline-step {
  padding: 14px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid rgba(61, 60, 57, 0.09);
}

.pipeline-step strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

.pipeline-step p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.metric-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.metric-row[hidden] {
  display: none;
}

.diary-paper {
  position: relative;
  padding: 26px 24px 24px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.42)),
    var(--paper);
  border: 1px solid rgba(64, 45, 32, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.diary-paper::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(68, 85, 96, 0.12);
}

.diary-paper p {
  margin: 0 0 16px;
  padding-left: 10px;
  font-family:
    "Yu Mincho",
    "Hiragino Mincho ProN",
    "BIZ UDPMincho",
    "Georgia",
    serif;
  font-size: 18px;
  line-height: 1.95;
  letter-spacing: 0.01em;
}

.backstage-stack {
  display: grid;
  gap: 14px;
}

.section-block {
  display: grid;
  gap: 12px;
}

.section-title {
  font-family:
    "Yu Mincho",
    "Hiragino Mincho ProN",
    "BIZ UDPMincho",
    serif;
  font-size: 17px;
  color: var(--accent);
  padding-left: 12px;
  border-left: 2px solid rgba(68, 85, 96, 0.22);
}

.section-explainer {
  margin: -2px 0 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.74;
}

.section-explainer.lead-explainer {
  margin: 4px 0 24px;
}

.micro-label {
  margin: 10px 0 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.scene-card small,
.trace-card small,
.memory-card small {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.scene-card p,
.trace-card p,
.memory-card p,
.reflection-card p,
.state-card p,
.mini-card p,
.init-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
}

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

.expandable-preview,
.expandable-full p {
  margin: 0;
  font-size: 14px;
  line-height: 1.75;
}

.expand-toggle {
  justify-self: start;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(68, 85, 96, 0.2);
  background: rgba(68, 85, 96, 0.08);
  color: var(--accent);
  font-size: 12px;
}

.expand-toggle:hover,
.panel-toggle-header:hover .panel-toggle-label {
  background: rgba(68, 85, 96, 0.12);
}

.note-body {
  color: #4c4239;
  font-size: 14px;
  line-height: 1.75;
}

.empty {
  color: rgba(32, 25, 19, 0.55);
  font-style: italic;
}

@media (max-width: 1180px) {
  .overview-grid,
  .hero-grid,
  .toolbar-grid {
    grid-template-columns: 1fr;
  }

  .pipeline-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .summary-meta-three {
    grid-template-columns: 1fr;
  }

  .summary-meta-two,
  .init-flows-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100vw - 18px, 100%);
    margin: 10px auto 24px;
  }

  .hero-panel,
  .toolbar,
  .summary-panel,
  .init-panel,
  .system-panel,
  .diary-panel,
  .backstage-panel {
    padding: 18px 16px 18px;
    border-radius: 20px;
  }

  .pipeline-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .diary-paper {
    padding: 20px 16px 18px;
  }

  .diary-paper p {
    font-size: 16px;
    line-height: 1.9;
  }
}
