:root {
  color-scheme: light;
  --bg: #f7fbfa;
  --surface: #ffffff;
  --surface-soft: #edf6f3;
  --ink: #10201c;
  --muted: #61716c;
  --line: #d9e6e1;
  --teal: #057c70;
  --teal-dark: #075b54;
  --amber: #d9941e;
  --shadow: 0 22px 62px rgba(28, 50, 44, 0.12);
  --radius: 8px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1715;
  --surface: #16221f;
  --surface-soft: #20312d;
  --ink: #edf7f4;
  --muted: #a5b7b1;
  --line: #31433e;
  --teal: #19a896;
  --teal-dark: #7de0d2;
  --amber: #f1b84b;
  --shadow: 0 22px 62px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 72%, transparent), transparent 380px),
    radial-gradient(circle at 84% 10%, color-mix(in srgb, var(--teal) 16%, transparent), transparent 340px),
    radial-gradient(circle at 72px 72px, color-mix(in srgb, var(--amber) 13%, transparent), transparent 180px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 16px;
}

.topbar,
.tool-actions,
.workspace,
.site-footer {
  max-width: 1500px;
  margin-inline: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 6px 0 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  filter: drop-shadow(0 8px 12px rgba(32, 53, 47, 0.16));
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: clamp(22px, 3vw, 28px);
  line-height: 1.05;
}

.brand span span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 680;
}

.site-nav,
.tool-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.tool-actions {
  margin: -4px auto 12px;
}

.site-nav > a,
.tools-menu summary {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 780;
  text-decoration: none;
  cursor: pointer;
}

.site-nav > a:hover,
.tools-menu[open] summary,
.tools-menu summary:hover {
  background: var(--surface-soft);
}

.tools-menu {
  position: relative;
}

.tools-menu summary {
  list-style: none;
  gap: 6px;
}

.tools-menu summary::-webkit-details-marker {
  display: none;
}

.tools-menu summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.tools-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: grid;
  gap: 6px;
  width: min(340px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 8px;
}

.tools-panel a {
  display: grid;
  gap: 3px;
  border-radius: var(--radius);
  color: inherit;
  padding: 10px;
  text-decoration: none;
}

.tools-panel a:hover,
.tools-panel a[aria-current="page"] {
  background: var(--surface-soft);
}

.tools-panel strong,
.tools-panel span {
  display: block;
}

.tools-panel strong {
  font-size: 13px;
}

.tools-panel span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  border: 1px solid color-mix(in srgb, var(--teal) 22%, var(--line));
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, #fff 72%, var(--surface)), var(--surface));
  color: var(--teal-dark);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 780;
  box-shadow: 0 8px 20px rgba(28, 50, 44, 0.08);
}

:root[data-theme="dark"] .icon-button {
  background:
    linear-gradient(180deg, color-mix(in srgb, #fff 6%, var(--surface)), var(--surface));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.icon-button:hover,
.mode-control button:hover,
.quick-button:hover {
  transform: translateY(-1px);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--teal) 42%, transparent);
  outline-offset: 3px;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.calculator-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 14px;
  align-items: start;
}

.calculator-area > * {
  min-width: 0;
}

.calculator-card,
.result-card,
.panel,
.seo-panel,
.reference-panel,
.examples-panel,
.faq-panel,
.related-tools,
.disclaimer {
  border: 1px solid color-mix(in srgb, var(--line) 84%, transparent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.calculator-card {
  position: relative;
  overflow: hidden;
  padding: clamp(18px, 3vw, 30px);
}

.calculator-card::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -80px;
  width: 260px;
  height: 260px;
  border: 32px solid color-mix(in srgb, var(--teal) 11%, transparent);
  border-radius: 50%;
  pointer-events: none;
}

.calculator-heading {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
  margin-bottom: 22px;
}

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

h1 {
  max-width: 660px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.03;
}

.calculator-heading p,
.seo-panel p,
.faq-list p,
.disclaimer,
.panel-heading span,
.steps-list,
.quick-button span {
  color: var(--muted);
  line-height: 1.55;
}

.calculator-heading p {
  max-width: 68ch;
  margin-top: 10px;
  font-size: 15px;
}

.mode-control {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  width: fit-content;
  border: 1px solid color-mix(in srgb, var(--teal) 30%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--teal) 10%, var(--surface));
  padding: 4px;
}

.mode-control button {
  min-height: 36px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--teal-dark);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 820;
}

.mode-control button[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff;
  box-shadow:
    0 6px 14px color-mix(in srgb, var(--teal) 26%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.input-grid {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
}

fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

fieldset[hidden] {
  display: none;
}

legend,
label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

legend {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

input,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

input {
  min-height: 74px;
  padding: 0 14px;
  font-size: clamp(32px, 5vw, 58px);
  font-weight: 820;
  line-height: 1;
}

select {
  appearance: none;
  min-height: 44px;
  padding: 0 38px 0 12px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--teal-dark) 50%),
    linear-gradient(135deg, var(--teal-dark) 50%, transparent 50%),
    linear-gradient(180deg, color-mix(in srgb, #fff 62%, var(--surface)), var(--surface));
  background-position:
    calc(100% - 20px) 19px,
    calc(100% - 14px) 19px,
    0 0;
  background-repeat: no-repeat;
  background-size:
    6px 6px,
    6px 6px,
    100% 100%;
  font-size: 14px;
  font-weight: 760;
}

:root[data-theme="dark"] select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--teal-dark) 50%),
    linear-gradient(135deg, var(--teal-dark) 50%, transparent 50%),
    linear-gradient(180deg, color-mix(in srgb, #fff 6%, var(--surface)), var(--surface));
}

select option {
  background: #ffffff;
  color: #10201c;
}

:root[data-theme="dark"] select option {
  background: #16221f;
  color: #edf7f4;
}

.result-column {
  display: grid;
  gap: 12px;
}

.result-card {
  display: grid;
  gap: 12px;
  min-height: 210px;
  align-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 95% 8%, color-mix(in srgb, var(--amber) 16%, transparent), transparent 34%),
    linear-gradient(135deg, #057c70, #075b54);
  color: #fff;
}

:root[data-theme="dark"] .result-card {
  background:
    radial-gradient(circle at 95% 0%, rgba(255, 255, 255, 0.07), transparent 34%),
    linear-gradient(135deg, #117366, #0b4b46);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.24);
}

.result-card span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-weight: 780;
}

.result-card strong {
  overflow-wrap: anywhere;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1;
}

.result-card p {
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  line-height: 1.45;
}

.panel,
.seo-panel,
.reference-panel,
.examples-panel,
.faq-panel,
.related-tools,
.disclaimer {
  padding: 18px;
  box-shadow: none;
}

.panel-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.panel-heading.inline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

.steps-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
  font-size: 14px;
}

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

.quick-button {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-soft));
  color: var(--ink);
  padding: 11px;
  text-align: left;
}

.quick-button strong,
.quick-button span {
  display: block;
}

.quick-button strong {
  font-size: 13px;
}

.quick-button span {
  font-size: 12px;
  line-height: 1.35;
}

.disclaimer,
.seo-panel,
.examples-panel,
.faq-panel,
.related-tools {
  grid-column: 1 / -1;
}

.disclaimer {
  border-left: 4px solid var(--amber);
  background: color-mix(in srgb, var(--amber) 10%, var(--surface));
  color: var(--ink);
  font-size: 14px;
}

.seo-panel {
  display: grid;
  gap: 12px;
}

.seo-panel p,
.reference-panel p,
.faq-list p {
  font-size: 14px;
}

.seo-panel p,
.seo-panel h2,
.seo-panel h3,
.review-note {
  max-width: 86ch;
}

.review-note {
  border-left: 4px solid var(--teal);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: color-mix(in srgb, var(--teal) 9%, var(--surface));
  padding: 10px 12px;
  color: var(--ink) !important;
  font-weight: 700;
}

.table-wrap {
  margin-top: 12px;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

caption {
  padding: 10px 12px;
  color: var(--muted);
  text-align: left;
  font-size: 13px;
  font-weight: 760;
}

th,
td {
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  font-size: 14px;
}

th {
  background: color-mix(in srgb, var(--surface) 82%, var(--surface-soft));
  color: var(--ink);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  color: var(--muted);
}

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

.example-grid article {
  display: grid;
  gap: 8px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-soft));
  padding: 16px;
}

.example-grid h3 {
  margin-bottom: 0;
  line-height: 1.3;
}

.example-grid p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.section-note {
  max-width: 74ch;
  margin: -4px 0 2px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

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

.faq-list article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-soft));
  padding: 14px;
}

.faq-list h3 {
  margin-bottom: 6px;
}

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

.related-tool-grid a {
  display: grid;
  gap: 5px;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-soft));
  color: inherit;
  padding: 12px;
  text-decoration: none;
}

.related-tool-grid span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0 2px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.site-footer a {
  color: var(--teal-dark);
  font-weight: 760;
  text-decoration: none;
}

.ad-slot[hidden] {
  display: none;
}

.ad-slot.is-active {
  display: grid;
  place-items: center;
  min-height: 90px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 82%, var(--surface-soft));
  color: var(--muted);
}

.ad-slot-leaderboard {
  max-width: 970px;
  margin: 0 auto 14px;
}

.ad-slot-result.is-active {
  min-height: 120px;
}

@media (max-width: 880px) {
  .topbar {
    align-items: flex-start;
  }

  .site-nav,
  .tool-actions {
    justify-content: flex-start;
  }

  .calculator-area {
    grid-template-columns: 1fr;
  }

  .result-column {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.85fr);
  }

  .result-column .panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .brand span span {
    display: none;
  }

  .site-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    justify-content: stretch;
  }

  .tool-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .site-nav .icon-button,
  .tool-actions .icon-button {
    width: auto;
    min-width: 0;
    padding: 0 10px;
    font-size: 12px;
    white-space: normal;
  }

  .tools-panel {
    left: 0;
    right: auto;
    width: min(340px, calc(100vw - 24px));
  }

  .calculator-card {
    padding: 16px;
  }

  .panel,
  .seo-panel,
  .reference-panel,
  .examples-panel,
  .faq-panel,
  .related-tools,
  .disclaimer {
    padding: 14px;
  }

  fieldset,
  .result-column,
  .quick-grid,
  .example-grid,
  .related-tool-grid,
  .site-footer {
    grid-template-columns: 1fr;
  }

  input,
  select,
  button {
    font-size: 16px;
  }

  input {
    min-height: 58px;
  }

  .site-footer {
    display: grid;
  }

  .site-footer nav {
    justify-content: flex-start;
  }
}

@media (max-width: 420px) {
  .tool-actions,
  .site-nav {
    grid-template-columns: 1fr;
  }
}
