:root {
  --paper: #f1eadc;
  --paper-dark: #d6ccb6;
  --paper-shadow: rgba(64, 45, 28, 0.2);
  --ink: #1f1a14;
  --accent: #a54e2b;
  --desk-1: #5b3f2c;
  --desk-2: #6d4a33;
  --desk-3: #845d41;
  --window-h: 28px;
  --window-gap: 10px;
  --window-w-sm: 24px;
  --window-w-md: 38px;
  --window-w-lg: 52px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.12), transparent 30%),
    repeating-linear-gradient(
      90deg,
      var(--desk-1) 0 60px,
      var(--desk-2) 60px 120px,
      var(--desk-3) 120px 180px
    );
}

.app-shell {
  width: min(1500px, calc(100vw - 20px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.eyebrow,
.panel-kicker {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(31, 26, 20, 0.66);
}

.intro {
  max-width: 860px;
  margin-bottom: 14px;
}

.intro h1,
.sliderule-header h2 {
  margin: 6px 0 10px;
  font-family: "Avenir Next Condensed", "Franklin Gothic Medium", sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.intro h1 {
  font-size: clamp(2rem, 4.8vw, 3.8rem);
  line-height: 0.92;
}

.toolbar,
.sliderule {
  background: rgba(241, 234, 220, 0.94);
  border: 1px solid rgba(31, 26, 20, 0.08);
  box-shadow:
    0 20px 42px rgba(23, 15, 10, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px 18px;
  border-radius: 14px;
  margin-bottom: 12px;
}

.toggle-group {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(31, 26, 20, 0.07);
}

.toggle {
  border: 0;
  background: transparent;
  color: rgba(31, 26, 20, 0.78);
  padding: 10px 14px;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.toggle.active {
  background: var(--accent);
  color: #fff8f0;
}

.root-control {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.root-control input {
  width: min(420px, 36vw);
  accent-color: var(--accent);
}

.root-control strong {
  min-width: 3ch;
  font-size: 1.15rem;
}

.sliderule {
  padding: 18px 20px 14px;
  border-radius: 12px;
}

.sliderule-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 10px;
}

.sliderule-header h2 {
  font-size: clamp(1.15rem, 1.8vw, 1.5rem);
  text-transform: uppercase;
}

.panel-instruction {
  max-width: 24ch;
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.45;
  text-align: right;
  color: rgba(31, 26, 20, 0.75);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.slider-stage {
  position: relative;
  padding: 10px 0 18px;
}

.sleeve {
  position: relative;
  z-index: 2;
  width: 100%;
  margin: 0 auto;
  padding: 20px 20px;
  border-radius: 8px;
  aspect-ratio: 1085 / 560;
  background:
    linear-gradient(180deg, #f7f2e8, #e8decb);
  box-shadow:
    0 10px 18px rgba(24, 17, 11, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.insert-sheet {
  position: absolute;
  z-index: 1;
  top: 24px;
  left: 24px;
  right: 24px;
  bottom: 24px;
  transform: translateX(var(--card-shift, 0px));
  opacity: 0;
  pointer-events: none;
}

.insert-core {
  position: relative;
  height: 100%;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0)),
    linear-gradient(180deg, #f2ecdf, #ddd0bc);
  box-shadow:
    0 14px 18px rgba(24, 17, 11, 0.15),
    inset 0 0 0 1px rgba(31, 26, 20, 0.08);
  touch-action: none;
}

.insert-core::before {
  content: "";
  position: absolute;
  inset: 16px 20px;
  border: 1px solid rgba(31, 26, 20, 0.1);
  border-radius: 10px;
}

.insert-rows,
.cutout-rows {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 4px;
}

.insert-rows {
  padding: 28px 22px;
  opacity: 0.72;
}

.insert-row {
  height: 52px;
  display: flex;
  align-items: center;
}

.note-track {
  display: flex;
  gap: var(--window-gap);
  white-space: nowrap;
  min-width: max-content;
}

.note-chip {
  height: var(--window-h);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(31, 26, 20, 0.48);
  background: rgba(255, 255, 255, 0.32);
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(31, 26, 20, 0.42);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.note-chip.sm {
  width: var(--window-w-sm);
}

.note-chip.md {
  width: var(--window-w-md);
}

.note-chip.lg {
  width: var(--window-w-lg);
}

.cutout-rows {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
}

.sleeve-frame {
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(59, 43, 28, 0.82);
  border-radius: 2px;
  pointer-events: none;
}

.formula-row {
  position: absolute;
  display: grid;
  grid-template-columns: 115px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  min-height: 40px;
  width: max-content;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 2px;
  padding: 2px 4px;
}

.formula-caption {
  display: block;
  min-height: auto;
  width: auto;
  cursor: default;
  pointer-events: none;
}

.formula-labels {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-top: 2px;
  justify-content: center;
}

.formula-main {
  display: grid;
  gap: 2px;
  min-width: 0;
  background: transparent;
  border-radius: 0;
  padding: 0;
}

.formula-name {
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.formula-family {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(31, 26, 20, 0.6);
  white-space: pre;
}

.windows {
  display: flex;
  gap: var(--window-gap);
  align-items: center;
  min-width: 0;
  white-space: nowrap;
}

.window {
  position: relative;
  height: var(--window-h);
  border-radius: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(231, 223, 209, 0.94));
  box-shadow:
    0 0 0 1.5px rgba(59, 43, 28, 0.72),
    inset 0 0 0 1px rgba(255, 255, 255, 0.44);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.window::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 1px;
}

.window.sm {
  width: var(--window-w-sm);
}

.window.md {
  width: var(--window-w-md);
}

.window.lg {
  width: var(--window-w-lg);
}

.window-note {
  position: relative;
  z-index: 1;
  padding: 0 3px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.degree-list {
  display: flex;
  gap: var(--window-gap);
  align-items: center;
  font-size: 0.64rem;
  color: rgba(31, 26, 20, 0.72);
  min-width: 0;
  white-space: nowrap;
}

.degree {
  text-align: center;
}

.degree.sm {
  width: var(--window-w-sm);
}

.degree.md {
  width: var(--window-w-md);
}

.degree.lg {
  width: var(--window-w-lg);
}

.formula-row.active .formula-name {
  color: var(--accent);
}

.formula-row.active .window {
  box-shadow:
    0 0 0 1.5px rgba(165, 78, 43, 0.88),
    inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.formula-row.active .formula-main {
  background: transparent;
}

.panel-decor {
  position: absolute;
  text-transform: uppercase;
  color: rgba(31, 26, 20, 0.9);
  line-height: 0.95;
  pointer-events: none;
}

.decor-left,
.decor-right,
.decor-center {
  font-size: clamp(1.8rem, 2.3vw, 2.35rem);
}

.decor-note,
.decor-inline {
  font-size: 0.82rem;
  line-height: 1.2;
}

.decor-note {
  text-align: left;
}

.decor-roman {
  font-size: 1.15rem;
  line-height: 1;
}

.decor-inline {
  letter-spacing: 0.02em;
}

.print-footer {
  padding: 8px 8px 0;
}

.cut-instruction {
  margin: 0 0 10px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: rgba(31, 26, 20, 0.7);
}

.footer-line {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}

.footer-line h3,
.panel-stamp {
  margin: 0;
  font-family: "Marker Felt", "Chalkboard SE", "Avenir Next Condensed", sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.footer-line h3 {
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  line-height: 0.95;
}

.panel-stamp {
  font-size: clamp(1.6rem, 3.4vw, 2.8rem);
}

@media (max-width: 980px) {
  .toolbar,
  .sliderule-header {
    flex-direction: column;
    align-items: start;
  }

  .panel-instruction {
    text-align: left;
  }

  .root-control {
    width: 100%;
    flex-wrap: wrap;
  }

  .root-control input {
    width: 100%;
  }

  .slider-stage {
    min-height: auto;
  }

  .sleeve {
    width: 100%;
  }

  .insert-sheet {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin-bottom: 16px;
  }

  .formula-row {
    transform: scale(0.92);
    transform-origin: top left;
  }

  .sleeve {
    padding: 20px;
  }

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