:root {
  --bg: #f7f4ff;
  --panel: #ffffff;
  --ink: #17151f;
  --muted: #6f657b;
  --line: #ded6ea;
  --blue: #5b5cf6;
  --green: #10a37f;
  --pink: #ff4fa3;
  --yellow: #ffd447;
  --radius: 8px;
  --shadow: 0 14px 32px rgba(30, 24, 50, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(91, 92, 246, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(16, 163, 127, 0.07) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 16px;
}

p {
  margin: 6px 0 0;
  line-height: 1.45;
}

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

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(12px);
}

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

.mark {
  width: 56px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--yellow);
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  text-transform: uppercase;
  box-shadow: 5px 5px 0 var(--pink);
}

.field {
  display: grid;
  gap: 6px;
  margin: 14px 0 16px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  box-shadow: 0 4px 0 rgba(23, 21, 31, 0.08);
}

input[type="radio"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 1px 0 0;
  padding: 0;
  box-shadow: none;
  accent-color: var(--blue);
  flex: 0 0 auto;
}

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

.utility-button {
  margin-bottom: 12px;
  border-color: rgba(16, 163, 127, 0.35);
  font-weight: 700;
}

.topic-button {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.topic-button.active {
  border-color: var(--blue);
  background: #f0efff;
  box-shadow: inset 4px 0 0 var(--pink), 0 8px 18px rgba(91, 92, 246, 0.14);
}

.content {
  padding: 22px;
  display: grid;
  gap: 16px;
  min-width: 0;
}

.topic-panels {
  display: grid;
  gap: 16px;
}

.topic-panels[hidden],
.graphs-page[hidden] {
  display: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

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

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fff3b0;
  color: #3c2f00;
  font-size: 12px;
  border: 1px solid #f4d64f;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 18px 20px;
  min-width: 0;
  box-shadow: var(--shadow);
}

.panel h3 {
  margin-bottom: 12px;
}

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

.def {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  border-left: 5px solid var(--blue);
}

.def summary {
  cursor: pointer;
  font-weight: 700;
}

.def .source {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.quiz-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
  border-left: 5px solid var(--green);
}

.quiz-item .q {
  font-weight: 700;
  margin-bottom: 8px;
}

.options {
  display: grid;
  gap: 6px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  padding: 8px;
  border: 1px solid #eee7f7;
  border-radius: var(--radius);
  background: #fcfbff;
  min-width: 0;
}

.option span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.quiz-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
  margin-bottom: 20px;
}

.quiz-item .source {
  margin-top: 20px;
  display: block;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  cursor: pointer;
  font: inherit;
}

.btn.primary {
  border-color: var(--blue);
  background: #ebeaff;
  color: #26228a;
  font-weight: 700;
}

.result {
  color: var(--muted);
  font-size: 13px;
}

.result:empty {
  display: none;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
  cursor: pointer;
  min-height: 120px;
  display: grid;
  align-content: start;
  gap: 8px;
  border-top: 5px solid var(--pink);
  box-shadow: 0 10px 20px rgba(255, 79, 163, 0.1);
}

.card .label {
  color: var(--muted);
  font-size: 12px;
}

.card .text {
  font-size: 14px;
  line-height: 1.35;
}

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

.file {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fff;
  min-width: 0;
}

.file a {
  display: block;
  min-width: 0;
  color: var(--blue);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file a:hover {
  text-decoration: underline;
}

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

.graphs-page {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.formula-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 18px 20px;
  min-width: 0;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--green);
}

.formula-card.wide {
  grid-template-columns: 1fr;
}

.formula-card.wide .chart-wrap {
  order: -1;
}

.formula-copy {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.formula-copy h3 {
  font-size: 18px;
}

.formula-copy h4 {
  margin: 0;
  font-size: 14px;
}

.formula-box,
.calc-box {
  display: grid;
  gap: 6px;
  border: 1px solid #eee7f7;
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fcfbff;
  overflow-wrap: break-word;
  line-height: 1.45;
}

.formula-box span {
  font-size: 14px;
}

.calc-box {
  font-family: "Courier New", Courier, monospace;
  font-size: 14px;
}

.calc-box {
  background: #fffdf2;
  border-color: #f4d64f;
}

.gdp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  min-width: 0;
}

.gdp-grid section {
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(30, 24, 50, 0.06);
  overflow: hidden;
}

.gdp-grid h4 {
  padding-bottom: 8px;
  border-bottom: 2px solid #eee7f7;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.mini-table th,
.mini-table td {
  border: 1px solid var(--line);
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
  background: #fff;
  overflow-wrap: normal;
  word-break: normal;
}

.mini-table th {
  background: #f0efff;
}

.mini-table td:first-child {
  font-weight: 700;
  white-space: nowrap;
}

.chart-wrap {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.chart-caption {
  color: var(--muted);
  font-size: 13px;
}

.econ-svg {
  width: 100%;
  max-width: 520px;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.gdp-svg {
  max-width: 760px;
  min-height: 170px;
  justify-self: center;
}

.axis,
.scheme-line {
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: round;
}

.guide {
  stroke: #9d92ac;
  stroke-width: 1.5;
  stroke-dasharray: 5 5;
}

.demand {
  stroke: var(--blue);
  stroke-width: 3;
}

.supply,
.tax-supply {
  stroke: var(--green);
  stroke-width: 3;
}

.tax-supply {
  stroke-dasharray: 6 5;
}

.price-line,
.tax-wedge {
  stroke: var(--pink);
  stroke-width: 3;
}

.equality {
  stroke: #9d92ac;
  stroke-width: 2;
  stroke-dasharray: 6 5;
}

.lorenz-line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3;
}

.cs-area {
  fill: rgba(91, 92, 246, 0.18);
}

.ps-area {
  fill: rgba(16, 163, 127, 0.2);
}

.dwl-area {
  fill: rgba(255, 79, 163, 0.25);
  stroke: var(--pink);
  stroke-width: 1.5;
}

.lorenz-gap {
  fill: rgba(255, 79, 163, 0.16);
}

.point {
  fill: var(--pink);
  stroke: #fff;
  stroke-width: 2;
}

.axis-label,
.strong-label,
.small-label,
.demand-label,
.supply-label,
.area-label,
.scheme-title,
.scheme-text {
  font-family: Arial, Helvetica, sans-serif;
  fill: var(--ink);
}

.axis-label,
.strong-label,
.scheme-title {
  font-weight: 700;
  font-size: 14px;
}

.small-label,
.demand-label,
.supply-label,
.area-label,
.scheme-text {
  font-size: 12px;
}

.demand-label {
  fill: var(--blue);
  font-weight: 700;
}

.supply-label {
  fill: var(--green);
  font-weight: 700;
}

.area-label {
  font-weight: 700;
}

.scheme-box {
  stroke: var(--line);
  stroke-width: 1.5;
}

.scheme-box.one {
  fill: #f0efff;
}

.scheme-box.two {
  fill: #eaf8f4;
}

.scheme-box.three {
  fill: #fff3b0;
}

.bar.nominal {
  fill: rgba(91, 92, 246, 0.75);
}

.bar.inflation {
  fill: rgba(255, 79, 163, 0.75);
}

.bar.real {
  fill: rgba(16, 163, 127, 0.75);
}

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

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

  .topbar,
  .formula-card,
  .formula-card.wide {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

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

  .econ-svg {
    max-width: 100%;
  }
}

@media (max-width: 520px) {
  .content {
    padding: 14px;
  }

  .formula-card {
    padding: 14px;
  }

  .formula-box span,
  .calc-box {
    overflow-wrap: anywhere;
    font-size: 13px;
  }

  .mini-table {
    table-layout: fixed;
    font-size: 12px;
  }

  .mini-table th,
  .mini-table td {
    padding: 6px;
    overflow-wrap: anywhere;
  }

  .mini-table td:first-child {
    white-space: normal;
  }
}
