:root {
  color-scheme: light;
  --ink: #242016;
  --muted: #6f6758;
  --paper: #fbf5e8;
  --paper-strong: #fffaf0;
  --line: #ded1b7;
  --olive: #52663a;
  --olive-dark: #354425;
  --rust: #a5532f;
  --rust-soft: #f3ddcf;
  --amber: #f7c96f;
  --shadow: 0 22px 70px rgba(62, 49, 25, 0.13);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  font-family: "Aptos", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 10%, rgba(247, 201, 111, 0.28), transparent 28rem),
    linear-gradient(135deg, #f4ead7 0%, #fbf5e8 44%, #efe2c8 100%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

main {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 44px 0 60px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow,
.tool-heading p {
  margin: 0 0 10px;
  color: var(--rust);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 8vw, 6.7rem);
  line-height: 0.9;
  letter-spacing: -0.08em;
}

.hero-copy {
  max-width: 710px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1.02rem, 2vw, 1.25rem);
  line-height: 1.65;
}

.hero-note {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 250, 240, 0.74);
}

.hero-note span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 999px;
  background: var(--rust-soft);
  color: var(--rust);
  font-weight: 900;
}

.hero-note p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.tool-shell {
  padding: 24px;
  border: 1px solid rgba(82, 102, 58, 0.28);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(90deg, rgba(255, 250, 240, 0.96), rgba(255, 248, 230, 0.9)),
    repeating-linear-gradient(0deg, transparent 0 47px, rgba(82, 102, 58, 0.06) 48px);
  box-shadow: var(--shadow);
}

.tool-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.tool-heading span {
  color: var(--muted);
  font-size: 0.95rem;
}

.calculator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(330px, 0.95fr);
  gap: 22px;
}

.fraction-form {
  display: grid;
  gap: 14px;
}

fieldset {
  min-width: 0;
  margin: 0;
  border: 0;
}

.fraction-card,
.operation-card,
.result-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 250, 240, 0.82);
}

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

legend {
  width: 100%;
  padding: 0 0 12px;
  font-weight: 800;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

label em {
  color: #988d78;
  font-style: normal;
  font-weight: 500;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid #c9ba9e;
  border-radius: var(--radius-sm);
  background: #fffdf8;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 750;
  text-align: center;
}

input:focus,
button:focus-visible {
  outline: 3px solid rgba(165, 83, 47, 0.28);
  outline-offset: 2px;
}

.operation-card {
  padding: 16px 18px 18px;
}

.operation-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.operation {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffdf8;
  color: var(--olive-dark);
  font-size: 1.3rem;
  font-weight: 900;
}

.operation.active {
  border-color: var(--olive);
  background: var(--olive);
  color: #fffaf0;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 0.55fr;
  gap: 12px;
}

.primary-action,
.secondary-action,
#copy-button,
.example-strip button {
  min-height: 48px;
  border: 0;
  border-radius: var(--radius-sm);
  font-weight: 850;
}

.primary-action {
  background: var(--rust);
  color: #fffaf0;
}

.secondary-action,
#copy-button,
.example-strip button {
  border: 1px solid var(--line);
  background: #fffaf0;
  color: var(--olive-dark);
}

.result-panel {
  padding: 20px;
}

.result-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.result-header p {
  margin-bottom: 0;
  color: var(--rust);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

#copy-button {
  min-height: 40px;
  padding: 0 14px;
}

.status-message {
  min-height: 28px;
  margin-bottom: 14px;
  color: var(--muted);
}

.status-message.error {
  color: #8a2d1f;
  font-weight: 800;
}

.result-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.result-cards article {
  min-width: 0;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: #fffdf8;
  border: 1px solid #eadcc4;
}

.result-cards span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.result-cards strong {
  display: block;
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
}

.steps-box {
  padding: 16px;
  border-radius: var(--radius-md);
  background: #f4ead7;
}

.steps-box h2 {
  margin-bottom: 10px;
  font-size: 1.05rem;
}

.steps-box ol {
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.6;
}

.example-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.example-strip button {
  min-height: 40px;
  padding: 0 14px;
}

.content-grid,
.method-section,
.examples-section,
.faq-section,
.limitations {
  margin-top: 28px;
}

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

.content-grid article,
.method-section,
.examples-section,
.faq-section,
.limitations {
  padding: 24px;
  border: 1px solid rgba(222, 209, 183, 0.9);
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 240, 0.72);
}

h2 {
  margin-bottom: 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  letter-spacing: -0.04em;
}

h3 {
  margin-bottom: 8px;
}

.content-grid p,
.method-section p,
.examples-section p,
.faq-section p,
.limitations p {
  color: var(--muted);
  line-height: 1.72;
}

.method-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 24px;
}

.check-list {
  display: grid;
  gap: 10px;
  align-content: start;
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  padding: 12px 14px;
  border-left: 4px solid var(--olive);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: #fffdf8;
  color: var(--muted);
}

.example-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.example-cards article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fffdf8;
}

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

details {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fffdf8;
}

summary {
  padding: 16px 18px;
  cursor: pointer;
  font-weight: 850;
}

details p {
  padding: 0 18px 18px;
}

.limitations {
  border-color: rgba(165, 83, 47, 0.32);
}

@media (max-width: 880px) {
  main {
    width: min(100% - 24px, 720px);
    padding-top: 26px;
  }

  .hero,
  .calculator-grid,
  .content-grid,
  .method-section,
  .example-cards {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: clamp(3.2rem, 18vw, 5.3rem);
  }

  .tool-shell {
    padding: 16px;
  }

  .tool-heading,
  .result-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .form-actions,
  .result-cards {
    grid-template-columns: 1fr;
  }
}
