:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1f1f22;
  --muted: #62656b;
  --line: #dde0e5;
  --accent: #ef3124;
  --accent-2: #c4261b;
  --soft: #fff0ef;
  --shadow: 0 14px 36px rgba(18, 24, 40, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #fafbfc, var(--bg));
}

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

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto;
  padding-bottom: 96px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}

.subtitle {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.actions button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.actions .action-text {
  width: auto;
  min-width: 124px;
  padding: 0 14px;
  font-weight: 700;
}

.topbar-count {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #fff7f6;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(330px, 0.88fr);
  min-height: 660px;
}

.controls {
  display: grid;
  gap: 18px;
  padding: 24px;
  align-content: start;
}

fieldset {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

legend {
  padding: 0 8px;
  font-weight: 760;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

small {
  color: var(--muted);
  font-weight: 500;
  line-height: 1.35;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(239, 49, 36, 0.24);
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 112px;
}

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

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

.preset-actions button,
.selected-box button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.preset-actions button:first-child {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.scenario-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.scenario-toolbar button,
.subtle-btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  padding: 0 14px;
}

.scenario-toolbar button:first-child {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.selected-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff8f7;
}

.selected-box p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.selected-box ul {
  padding: 0;
  list-style: none;
}

.selected-box .empty {
  color: var(--muted);
}

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

.scenario-empty {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfbfc;
}

.scenario-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.scenario-card.is-base {
  border-color: rgba(239, 49, 36, 0.24);
  background: linear-gradient(180deg, #fffefe, #fff8f7);
}

.scenario-card-head,
.quality-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.scenario-card-head h3,
.compare-title {
  margin: 0;
  font-size: 14px;
}

.scenario-card-meta,
.quality-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.scenario-badges,
.quality-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.scenario-badge,
.gate-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.scenario-badge {
  background: var(--soft);
  color: var(--accent-2);
}

.gate-pass {
  background: #ebfff5;
  color: #127a50;
}

.gate-warn {
  background: #fff8df;
  color: #9b6900;
}

.gate-fail {
  background: #ffecea;
  color: #b82318;
}

.scenario-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}

.scenario-metric {
  padding: 10px;
  border-radius: 10px;
  background: #fafbfc;
  border: 1px solid #eef0f4;
}

.scenario-metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}

.scenario-metric strong {
  font-size: 14px;
}

.scenario-diff {
  margin: 0;
  color: #4f5561;
  font-size: 12px;
  line-height: 1.5;
}

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

.scenario-actions button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.scenario-actions button:hover,
.subtle-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.scenario-compare {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfbfc;
}

.compare-table {
  display: grid;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--line);
}

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

.compare-cell {
  padding: 10px 12px;
  background: #fff;
  font-size: 12px;
  line-height: 1.45;
}

.compare-cell.is-head {
  font-weight: 800;
  background: #f7f8fb;
}

.field-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.impact-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -2px;
}

.impact-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.01em;
}

.impact-info {
  background: #eef5ff;
  color: #305fa8;
}

.impact-calendar {
  background: #fff6e4;
  color: #9a6400;
}

.impact-effort {
  background: #edf8fb;
  color: #0d6b7f;
}

.impact-explain {
  background: #f3f4f7;
  color: #5b6270;
}

.required-label::after {
  content: " *";
  color: var(--accent);
}

.required-field.field-missing select,
.required-field.field-missing input {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(239, 49, 36, 0.12);
}

.required-field.field-missing .required-label {
  color: var(--accent-2);
}

.explain-box {
  padding: 12px 14px;
  border: 1px solid rgba(239, 49, 36, 0.12);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 247, 246, 0.96));
  color: #5f4440;
  font-size: 13px;
  line-height: 1.55;
}

.factor-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 760;
}

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

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

.help-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.help-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #f2d1ce;
  color: #7a4b45;
  font-size: 12px;
  font-weight: 700;
}

.help-stack p {
  margin: 0;
}

.faq-section {
  margin-top: 6px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.faq-title {
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 760;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.faq-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.faq-question {
  padding: 14px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.faq-question:hover {
  background: #fafbfc;
}

.faq-arrow {
  color: var(--muted);
  transition: transform 0.18s ease;
  font-size: 12px;
}

.faq-question.open .faq-arrow {
  transform: rotate(180deg);
}

.faq-answer {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.65;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.2s ease;
  padding: 0 16px;
}

.faq-answer.open {
  max-height: 320px;
  padding: 0 16px 16px;
}

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

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

.mode-tab {
  display: block;
}

.mode-tab input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-tab span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
  text-align: center;
  padding: 6px 10px;
}

.mode-tab input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.selected-work {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.selected-work span {
  min-width: 0;
}

.selected-work button {
  width: 32px;
  min-height: 32px;
}

.range {
  grid-template-columns: minmax(130px, 1fr) minmax(160px, 2fr) 32px;
  align-items: center;
  gap: 12px;
}

.range input {
  min-height: auto;
  padding: 0;
  accent-color: var(--accent);
}

.compact-range {
  grid-template-columns: 1fr 44px;
}

.compact-range input {
  grid-column: 1 / -1;
}

output {
  display: grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--accent);
  font-weight: 800;
}

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

.range-card {
  grid-template-columns: 1fr auto;
  gap: 8px 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfcfd;
}

.range-card input {
  grid-column: 1 / -1;
}

.range-scale {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.range-scale span:first-child {
  text-align: left;
}

.range-scale span:last-child {
  text-align: right;
}

.range-scale span:not(:first-child):not(:last-child) {
  text-align: center;
}

.range-card small {
  grid-column: 1 / -1;
}

.range-card output {
  width: auto;
  justify-self: end;
}

.check {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: start;
  column-gap: 10px;
  row-gap: 4px;
  color: var(--ink);
}

.check input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
  margin-top: 2px;
}

.check small {
  grid-column: 2;
}

.full-row {
  grid-column: 1 / -1;
}

.inline-help summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
}

.inline-help[open] {
  padding: 8px;
  border-radius: 8px;
  background: rgba(29, 116, 103, 0.08);
}

.result {
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 24px;
  background: linear-gradient(180deg, #f3f4f7, #eef1f5);
  color: #17181c;
}

.score {
  padding: 24px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.07);
  backdrop-filter: blur(18px);
}

.score p,
.triple span,
.note p,
.lists li,
.fold-content li {
  color: #677085;
}

.score strong {
  display: block;
  margin: 5px 0;
  font-size: clamp(46px, 8vw, 78px);
  line-height: 1;
}

.score span {
  color: #a24a41;
  font-weight: 750;
}

.triple {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.triple div,
.breakdown,
.chart-section,
.complexity-panel,
.note,
.lists,
.fold-panel,
.quality-gate,
.confluence-export {
  padding: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.07);
  backdrop-filter: blur(18px);
}

.gate-flags {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.flag-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #edf0f5;
  background: #fbfcfd;
}

.flag-item strong,
.flag-item p {
  margin: 0;
}

.flag-item p {
  color: #5f6879;
  font-size: 13px;
  line-height: 1.55;
}

.flag-item.flag-info {
  border-color: #e4eaf3;
}

.flag-item.flag-warn {
  border-color: #f4d88a;
  background: #fffaf0;
}

.flag-item.flag-fail {
  border-color: #f0b1ab;
  background: #fff3f2;
}

.flag-rec {
  color: #3d4758;
  font-size: 12px;
  font-weight: 650;
}

.inline-select {
  display: grid;
  gap: 6px;
  min-width: 150px;
  font-size: 12px;
  color: var(--muted);
}

.inline-select select {
  min-height: 36px;
}

.preview-wrap {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.compact-fold {
  margin-top: 14px;
}

.compact-fold summary {
  font-size: 13px;
}

.preview-box {
  margin: 0;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #edf0f5;
  background: #fbfcfd;
  color: #374151;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow: auto;
}

.complexity-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.complexity-low {
  background: #ebfff5;
  color: #127a50;
}

.complexity-moderate {
  background: #edf8fb;
  color: #0d6b7f;
}

.complexity-elevated {
  background: #fff6e4;
  color: #a15d00;
}

.complexity-high {
  background: #ffecea;
  color: #b82318;
}

.complexity-score-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-top: 10px;
}

.complexity-score-row strong {
  font-size: 28px;
  line-height: 1;
}

.complexity-meter {
  margin-top: 12px;
  height: 10px;
  border-radius: 999px;
  background: #edf0f5;
  overflow: hidden;
}

.complexity-meter-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #127a50 0%, #0d6b7f 35%, #ef9a00 70%, #d83a2f 100%);
}

.complexity-summary {
  margin: 12px 0 0;
  color: #4b5565;
  line-height: 1.55;
}

.complexity-drivers {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.complexity-driver {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #edf0f5;
  background: #fbfcfd;
}

.complexity-driver-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.complexity-driver-head strong {
  font-size: 13px;
}

.complexity-driver-head span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.complexity-driver-bar {
  height: 8px;
  border-radius: 999px;
  background: #edf0f5;
  overflow: hidden;
}

.complexity-driver-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.complexity-driver-comment {
  color: #5f6879;
  font-size: 12px;
  line-height: 1.5;
}

.triple span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.triple strong {
  font-size: 28px;
}

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

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

dt {
  color: #495264;
}

dd {
  margin: 0;
  font-weight: 800;
  color: #17181c;
}

.note p {
  margin-bottom: 0;
  line-height: 1.55;
}

.lists {
  display: grid;
  gap: 18px;
}

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

.chart-section h2 {
  margin-bottom: 0;
}

.fold-panel {
  padding: 0;
  overflow: hidden;
}

.fold-panel summary {
  cursor: pointer;
  list-style: none;
  padding: 18px;
  font-size: 15px;
  font-weight: 700;
}

.fold-panel summary::-webkit-details-marker {
  display: none;
}

.fold-panel[open] summary {
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.fold-content {
  padding: 18px;
}

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

canvas {
  max-width: 100%;
}

.summary-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--panel);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 24px rgba(18, 24, 40, 0.15);
  z-index: 200;
  transform: translateY(100%);
  transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.summary-bar.visible {
  transform: translateY(0);
}

.summary-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-val {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.summary-val.primary {
  color: var(--accent);
}

.summary-val.gold {
  color: #b07b00;
}

.summary-val.muted {
  color: var(--muted);
}

.summary-divider {
  width: 1px;
  height: 32px;
  background: var(--line);
}

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 999;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes flash-update {
  0% {
    opacity: 0.4;
  }
  100% {
    opacity: 1;
  }
}

.flash {
  animation: flash-update 0.3s ease;
}

ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

li {
  line-height: 1.35;
}

@media (max-width: 860px) {
  .app {
    width: min(100% - 20px, 680px);
    margin: 10px auto;
  }

  .topbar,
  .layout,
  .grid-2,
  .triple {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    padding: 20px;
  }

  .actions {
    width: 100%;
  }

  .layout {
    display: grid;
  }

  .range {
    grid-template-columns: 1fr 42px;
  }

  .range input {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .controls,
  .result {
    padding: 16px;
  }

  .compact-complexity {
    grid-template-columns: 1fr;
  }

  .scenario-metrics,
  .compare-row {
    grid-template-columns: 1fr;
  }

  .summary-bar-inner {
    padding: 12px 16px;
    gap: 14px;
  }

  .summary-divider {
    display: none;
  }

}
