:root {
  color-scheme: light;
  --workspace-bg: #f6f8fc;
  --workspace-soft: #eef3fc;
  --workspace-ink: #142039;
  --workspace-muted: #4e5e76;
  --workspace-border: #d9e3f0;
  --fc-panel: #fff;
  --fc-tint: #eaf2ff;
  --fc-tint-border: #cbdfff;
  --fc-blue: #1355c9;
  --fc-blue-strong: #124ab2;
  --fc-focus: #286cda;
  --fc-error: #a12836;
  --fc-error-bg: #fff0f1;
  --fc-shadow: 0 18px 42px -30px #28457161;
}

:root[data-fc-theme="dark"] {
  color-scheme: dark;
  --workspace-bg: #131a27;
  --workspace-soft: #242e40;
  --workspace-ink: #f0f5ff;
  --workspace-muted: #bbc9dd;
  --workspace-border: #39475e;
  --fc-panel: #1b2535;
  --fc-tint: #233755;
  --fc-tint-border: #405879;
  --fc-blue: #a4c8ff;
  --fc-blue-strong: #124ab2;
  --fc-focus: #80b5ff;
  --fc-error: #ffbac1;
  --fc-error-bg: #492a38;
  --fc-shadow: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

.fraction-page {
  margin: 0;
  background: var(--workspace-bg);
  color: var(--workspace-ink);
  font: 400 17px/1.55 "Inter Tight", system-ui, sans-serif;
}

.fraction-page :is(button, input, select, textarea) { font: inherit; }
.fraction-page :is(button, select, summary) { touch-action: manipulation; cursor: pointer; }
.fraction-page :is(button, input, select):disabled { opacity: .68; cursor: default; }
.fraction-page :focus-visible { outline: 2px solid var(--fc-focus); outline-offset: 3px; }
.fraction-page h2, .fraction-page h3, .fraction-page p { margin: 0; }
.fraction-page h2 { font-size: clamp(1.38rem, 3.2vw, 1.78rem); line-height: 1.16; letter-spacing: -.025em; }
.fraction-page h3 { font-size: 1.06rem; line-height: 1.3; }

.fc-visually-hidden, .fc-skip:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.fc-skip:focus {
  position: fixed;
  z-index: 5;
  top: 8px;
  left: 8px;
  padding: 12px;
  background: var(--fc-panel);
  color: var(--fc-blue);
}

.fc-shell {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
}

.fc-header {
  border-bottom: 1px solid var(--workspace-border);
  background: var(--fc-panel);
  padding-top: env(safe-area-inset-top, 0px);
}

.fc-header-inner, .fc-header-actions, .fc-home, .fc-header-photo {
  display: flex;
  align-items: center;
}

.fc-header-inner { min-height: 64px; justify-content: space-between; gap: 10px; }
.fc-header-actions { gap: 12px; }
.fc-home, .fc-header-photo {
  min-height: 44px;
  color: var(--workspace-ink);
  text-decoration: none;
  font-weight: 650;
}
.fc-home { gap: 5px; font-size: 1.08rem; }
.fc-home svg { width: 19px; height: 19px; stroke: currentColor; stroke-width: 1.8; fill: none; }
.fc-header-photo { color: var(--fc-blue); font-size: .92rem; }
#fc-theme { min-height: 42px; padding: 0 8px; font-size: .89rem; }

.fc-hero { padding: clamp(34px, 7vw, 74px) 0 clamp(23px, 5vw, 38px); }
.fc-hero h1 {
  max-width: 17ch;
  margin: 0 0 12px;
  font-size: clamp(2.35rem, 6vw, 4rem);
  font-weight: 740;
  line-height: .99;
  letter-spacing: -.055em;
  text-wrap: balance;
}
.fc-hero p { max-width: 54ch; color: var(--workspace-muted); font-size: clamp(1rem, 2.7vw, 1.2rem); }

.fc-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 16px; scroll-margin-top: 12px; }
.fc-panel {
  min-width: 0;
  padding: clamp(16px, 3vw, 27px);
  border: 1px solid var(--workspace-border);
  border-radius: 24px;
  background: var(--fc-panel);
  box-shadow: var(--fc-shadow);
}

.fc-segment, .fc-operators, .fc-form-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.fc-segment {
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--workspace-border);
  border-radius: 15px;
  background: var(--workspace-soft);
}
.fc-segment > button {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 3px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--workspace-muted);
  font-weight: 650;
}
.fc-segment > [aria-pressed="true"] { color: var(--fc-blue); background: var(--fc-panel); border-color: var(--workspace-border); }
#fc-fields { display: grid; gap: 12px; min-width: 0; margin: 0; padding: 0; border: 0; }
.fc-operations { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fc-operators { flex: 1; }
.fc-operators > button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--workspace-border);
  border-radius: 11px;
  background: var(--fc-panel);
  color: var(--workspace-ink);
  line-height: 1;
}
.fc-operators > button { flex: 1; font-size: 1.42rem; font-weight: 630; }
.fc-operators > [aria-pressed="true"] {
  border-color: var(--fc-focus);
  background: var(--fc-tint);
  color: var(--fc-blue);
}
.fraction-page select {
  max-width: 100%;
  min-height: 44px;
  padding: 0 8px;
  border: 1px solid var(--workspace-border);
  border-radius: 10px;
  background: var(--fc-panel);
  color: var(--workspace-ink);
}
#fc-extra { flex: 1; width: 100%; min-width: min(100%, 173px); font-size: .94rem; }

.fc-values { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: stretch; gap: 8px; }
.fc-values.fc-single { grid-template-columns: minmax(0, 1fr); }
.fc-operand {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--workspace-border);
  border-radius: 14px;
  background: var(--workspace-soft);
}
.fc-operand legend {
  padding: 0 4px;
  color: var(--workspace-ink);
  font-size: .91rem;
  font-weight: 650;
}
.fc-operand .fc-kind { width: 100%; font-size: .89rem; }
.fc-operand-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  min-height: 104px;
}
.fc-operand-row { display: flex; min-width: 0; align-items: center; justify-content: center; gap: 4px; }
.fc-stacked { flex: 1; min-width: 0; max-width: 116px; display: grid; gap: 4px; }
.fc-stacked label, .fc-decimal { display: block; min-width: 0; }
.fc-whole { flex: 0 0 44%; min-width: 0; max-width: 77px; display: grid; align-items: center; }
.fc-fraction-line { height: 2px; border-radius: 2px; background: var(--workspace-ink); }
.fc-operand input, .fc-insert input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 5px;
  border: 1px solid var(--workspace-border);
  border-radius: 9px;
  background: var(--fc-panel);
  color: var(--workspace-ink);
  text-align: center;
  font-size: 1.07rem;
  font-variant-numeric: tabular-nums;
}
.fc-operand input::placeholder { color: var(--workspace-muted); opacity: .73; }
.fc-operand input[aria-invalid="true"] { border-color: var(--fc-error); }
.fc-negative {
  min-height: 44px;
  min-width: 30px;
  padding: 0 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--workspace-muted);
  font-size: 1.04rem !important;
}
.fc-negative[aria-pressed="true"] {
  border-color: var(--fc-tint-border);
  background: var(--fc-tint);
  color: var(--fc-blue);
}
.fc-between { display: grid; align-self: center; margin-top: 44px; min-width: 14px; place-items: center; color: var(--fc-blue); font-size: 1.25rem; font-weight: 650; }
.fc-values.fc-decimals .fc-operand-body { min-height: 56px; }
.fc-values.fc-decimals .fc-between { margin-top: 8px; }
.fc-hint { color: var(--workspace-muted); font-size: .91rem; }
.fc-error { color: var(--fc-error); background: var(--fc-error-bg); border-radius: 10px; padding: 9px 11px; font-size: .93rem; }
.fc-expression-editor, .fc-insert-fields { display: grid; gap: 8px; min-width: 0; }
.fc-expression-editor > label, .fc-insert-fields label, .fc-copy-fallback { font-size: .92rem; font-weight: 630; }
.fraction-page textarea {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--workspace-border);
  border-radius: 10px;
  background: var(--workspace-soft);
  color: var(--workspace-ink);
  font-size: 1rem;
  resize: vertical;
}
.fraction-page textarea[aria-invalid="true"], .fc-insert input[aria-invalid="true"] { border-color: var(--fc-error); }
.fc-symbols { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
.fc-symbols > button {
  min-height: 44px;
  border: 1px solid var(--workspace-border);
  border-radius: 9px;
  background: var(--fc-panel);
  color: var(--workspace-ink);
  font-weight: 660;
}
.fc-insert { padding: 0 9px; border: 1px solid var(--workspace-border); border-radius: 10px; }
.fc-insert summary { min-height: 42px; padding: 8px 0; color: var(--fc-blue); font-weight: 630; }
.fc-insert-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: end; padding-bottom: 9px; }
.fc-insert-fields > button { grid-column: 1 / -1; justify-self: start; }
.fc-insert-fields label { display: grid; gap: 4px; }
.fc-insert-fields .fc-stacked { max-width: none; }
.fc-insert-fields input::placeholder { font-size: .82rem; }
.fc-expression-preview { padding: 9px 10px; border-radius: 10px; background: var(--fc-tint); color: var(--fc-blue); overflow-wrap: anywhere; }

.fc-primary, .fc-secondary, .fc-copy {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 9px 15px;
  font-weight: 650 !important;
  text-align: center;
  text-decoration: none;
  line-height: 1.2;
}
.fc-primary { flex: 1; min-height: 50px; color: #fff; background: var(--fc-blue-strong); }
.fc-secondary, .fc-copy { color: var(--fc-blue); background: var(--fc-tint); border-color: var(--fc-tint-border); }
.fc-copy { font-size: .89rem !important; }
.fc-form-actions { margin-top: 2px; gap: 8px; }
@media (hover: hover) {
  .fc-primary:hover { background: #103e95; }
  .fc-secondary:hover, .fc-copy:hover, .fc-symbols button:hover { border-color: var(--fc-focus); }
  .fc-header a:hover { text-decoration: underline; }
}

.fc-output { align-self: stretch; scroll-margin-top: 12px; }
.fc-output-heading { margin: 0 0 7px; }
.fraction-page .fc-empty { color: var(--workspace-muted); margin-top: 13px; }
.fc-notebook-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 7px; margin: 13px 0 8px; }
.fc-notebook { margin: 0 0 14px; padding: 0; list-style: none; }
.fc-notebook li { padding: 8px 9px; border-bottom: 1px solid var(--workspace-border); line-height: 1.7; overflow-wrap: anywhere; }
.fc-notebook li:nth-child(odd) { background: var(--workspace-soft); }
.fc-copy-fallback textarea { margin-top: 5px; }
.fc-result-detail { border-top: 1px solid var(--workspace-border); }
.fc-result-detail summary { min-height: 44px; padding: 9px 0; font-weight: 630; color: var(--fc-blue); }
.fc-edit { min-height: 42px; padding: 0; border: 0; background: none; color: var(--fc-blue); text-decoration: underline; text-underline-offset: 3px; }
.fc-fraction { display: inline-flex; flex-direction: column; align-items: stretch; max-width: 100%; text-align: center; vertical-align: middle; line-height: 1.15; font-variant-numeric: tabular-nums; }
.fc-fraction > span { overflow-wrap: anywhere; padding: 1px 5px; }
.fc-fraction > span:first-child { border-bottom: 1.5px solid currentColor; }
.fc-math-chunk { display: inline-flex; align-items: center; gap: .12em; max-width: 100%; vertical-align: middle; }
.fc-math-chunk .fc-fraction { min-width: 0; }
.fc-cancel-fraction { margin-block: .4em; }
.fc-cancel-fraction > span { display: flex; justify-content: center; gap: .28em; }
.fc-cancel-fraction > span:first-child { align-items: flex-end; }
.fc-cancel-fraction > span:last-child { align-items: flex-start; }
.fc-cancel-factor { display: inline-flex; flex-direction: column; gap: 1px; min-width: 0; }
.fc-cancel-old { position: relative; text-decoration: none; color: var(--workspace-muted); }
.fc-cancel-old::after { content: ''; position: absolute; inset: 50% -1px auto; border-top: 1.5px solid currentColor; transform: rotate(-24deg); }
.fc-cancel-new { color: var(--fc-blue); font-size: .87em; font-weight: 700; line-height: 1.05; }
.fc-cancel-top { order: -1; }
.fc-result-expression { color: var(--workspace-muted); margin-top: 7px !important; overflow-wrap: anywhere; }
.fc-result-main { margin: 5px 0 12px !important; color: var(--fc-blue); font-weight: 710; font-size: clamp(1.5rem, 4.5vw, 2.7rem); line-height: 1.15; overflow-wrap: anywhere; }
.fc-result-main:focus { outline-offset: 1px; }
.fc-decimal-note { display: block; color: var(--workspace-muted); font-size: .85rem; font-weight: 400; overflow-wrap: anywhere; }
.fc-forms { display: grid; gap: 1px; margin: 0 0 16px; overflow: hidden; border-radius: 12px; background: var(--workspace-border); }
.fc-forms:empty { display: none; }
.fc-forms > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 11px; padding: 8px 11px; background: var(--workspace-soft); font-size: .92rem; }
.fc-forms dt { color: var(--workspace-muted); }
.fc-forms dd { margin: 0; overflow-wrap: anywhere; font-weight: 600; text-align: right; }
.fc-column { margin-bottom: 16px; }
.fc-column pre { margin: 8px 0; max-height: 440px; overflow: auto; border: 1px solid var(--workspace-border); border-radius: 12px; padding: 11px; background: var(--workspace-soft); font: 500 .89rem/1.4 ui-monospace, Consolas, monospace; }
.fc-steps { display: grid; gap: 10px; margin: 8px 0 0; padding-left: 22px; }
.fc-steps li::marker { color: var(--fc-blue); font-weight: 650; }
.fc-steps li { min-width: 0; padding-left: 3px; overflow-wrap: anywhere; }
.fc-steps li p { color: var(--workspace-muted); font-size: .93rem; }
.fc-steps li .fc-step-math { margin-top: 3px; color: var(--workspace-ink); font-weight: 550; }

.fc-guide, .fc-info, .fc-faq, .fc-ai { margin-top: clamp(28px, 5vw, 53px); }
.fc-section-lead { max-width: 73ch; margin: 10px 0 16px !important; color: var(--workspace-muted); }
.fc-guide-grid { display: grid; gap: 11px; }
.fc-guide-card {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--workspace-border);
  border-radius: 15px;
  background: var(--fc-panel);
  color: var(--workspace-ink);
  text-align: left;
}
.fc-guide-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.fc-guide-card p { margin-top: 7px; color: var(--workspace-muted); }
.fc-guide-card .fc-formula { color: var(--fc-blue); font-weight: 650; overflow-wrap: anywhere; }
.fc-info { padding: clamp(16px, 3.5vw, 28px); border: 1px solid var(--fc-tint-border); border-radius: 22px; background: var(--fc-tint); }
.fc-info p { margin: 10px 0 13px; max-width: 83ch; color: var(--workspace-muted); }
.fc-info .fc-secondary { background: var(--fc-panel); }
.fc-faq h2 { margin-bottom: 12px; }
.fc-faq details { margin-bottom: 7px; border: 1px solid var(--workspace-border); border-radius: 12px; background: var(--fc-panel); }
.fc-faq summary { padding: 11px 14px; font-weight: 630; }
.fc-faq details p { padding: 0 14px 12px; color: var(--workspace-muted); }
.fc-ai { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 13px; border-top: 1px solid var(--workspace-border); padding-top: 22px; }
.fc-ai > div { flex: 1 1 460px; }
.fc-ai p { margin-top: 6px; max-width: 65ch; color: var(--workspace-muted); }

@media (max-width: 760px) {
  .fc-workspace { grid-template-columns: minmax(0,1fr); gap: 12px; }
  .fc-output:not(.fc-has-result) { display: none; }
}

@media (max-width: 475px) {
  .fc-shell { padding-left: max(12px,env(safe-area-inset-left,0px)); padding-right: max(12px,env(safe-area-inset-right,0px)); }
  .fc-header-inner { min-height: 57px; }
  .fc-header-actions { gap: 7px; }
  .fc-home { gap: 2px; }
  .fc-hero { padding-top: 29px; }
  .fc-hero h1 { font-size: clamp(2.1rem, 10vw, 2.8rem); }
  .fc-panel { border-radius: 19px; }
  .fc-guide-grid { grid-template-columns: minmax(0,1fr); }
  .fc-output-heading h2 { font-size: 1.45rem; }
  .fc-guide-card { padding: 12px; }
  .fc-symbols { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .fc-segment > button { font-size: .94rem; }
}

@media (max-width: 375px) {
  .fc-operand { padding-inline: 5px; }
  .fc-negative { min-width: 26px; }
  .fc-values.fc-has-mixed:not(.fc-single) { grid-template-columns: minmax(0,1fr); gap: 3px; }
  .fc-values.fc-has-mixed .fc-between { min-height: 26px; margin: 0; }
}
