:root {
  color-scheme: light;
  --bg: #f7fbfa;
  --surface: #ffffff;
  --surface-soft: #edf6f3;
  --ink: #10201c;
  --muted: #61716c;
  --line: #d9e6e1;
  --teal: #057c70;
  --teal-dark: #075b54;
  --amber: #d9941e;
  --red: #b64a42;
  --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;
  --red: #ff8d82;
  --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) 17%, transparent), transparent 340px),
    radial-gradient(circle at 68px 80px, color-mix(in srgb, var(--amber) 13%, transparent), transparent 190px),
    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: 22px;
}

.topbar,
.workspace {
  max-width: 1440px;
  margin: 0 auto;
}

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

.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: 28px;
  line-height: 1.05;
}

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

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

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 780;
  text-decoration: none;
}

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

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 350px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.mode-panel,
.calculator-card,
.panel {
  border: 1px solid color-mix(in srgb, var(--line) 84%, transparent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.mode-panel {
  position: sticky;
  top: 18px;
  padding: 18px;
}

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

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 320px;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.02;
}

h2 {
  font-size: 16px;
}

.panel-heading p,
.panel-heading span,
.calculator-heading p,
.result-strip span,
.input-field span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.mode-button {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-soft));
  color: var(--ink);
  padding: 9px 10px;
  text-align: left;
}

.mode-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--teal) 10%, var(--surface));
  color: var(--teal-dark);
  line-height: 1;
  overflow: hidden;
}

.mode-icon svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 23px;
  height: 23px;
  stroke-width: 2;
  margin: auto;
}

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

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

.mode-button span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
}

.mode-button.active {
  border-color: var(--teal);
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff;
}

.mode-button.active .mode-icon {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.mode-button.active span {
  color: rgba(255, 255, 255, 0.78);
}

.calculator-area {
  display: grid;
  gap: 16px;
}

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

.calculator-card::after {
  content: "";
  position: absolute;
  right: -64px;
  bottom: -84px;
  width: 280px;
  height: 280px;
  border: 34px solid color-mix(in srgb, var(--teal) 10%, transparent);
  border-radius: 50%;
  pointer-events: none;
}

.calculator-heading {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.calculator-heading h2 {
  font-size: clamp(32px, 4.4vw, 56px);
  line-height: 1;
}

.precision-control {
  display: grid;
  gap: 5px;
  min-width: 132px;
}

.precision-control span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
}

.precision-control select {
  border: 1px solid color-mix(in srgb, var(--teal) 30%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--teal) 10%, var(--surface));
  color: var(--teal-dark);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}

.input-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.input-field {
  display: grid;
  gap: 9px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-soft));
  padding: 15px;
}

.input-field.wide {
  grid-column: 1 / -1;
}

.input-control {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  min-height: 66px;
  border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
}

.input-control b,
.input-control em {
  align-self: stretch;
  display: grid;
  place-items: center;
  min-width: 42px;
  padding: 0 10px;
  color: var(--teal-dark);
  font-size: 13px;
  font-style: normal;
  font-weight: 860;
}

.input-control b {
  border-right: 1px solid var(--line);
}

.input-control em {
  border-left: 1px solid var(--line);
}

.input-control b[aria-hidden="true"],
.input-control em[aria-hidden="true"] {
  display: none;
}

input,
select,
output {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

input {
  min-height: 66px;
  padding: 0 12px;
  font-size: clamp(30px, 4vw, 52px);
  font-weight: 820;
  line-height: 1;
}

input:focus {
  outline: 0;
}

input:invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 16%, transparent);
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.result-strip {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 7px;
  margin-top: 16px;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 96% 0%, rgba(255, 255, 255, 0.16), transparent 36%),
    linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff;
  padding: 18px;
}

.result-strip span,
.result-strip p {
  color: rgba(255, 255, 255, 0.78);
}

.result-strip strong {
  font-size: clamp(38px, 6vw, 72px);
  line-height: 0.98;
  overflow-wrap: anywhere;
}

.result-strip p {
  font-size: 14px;
  font-weight: 720;
  line-height: 1.45;
}

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

.panel {
  padding: 16px;
  box-shadow: none;
}

.steps-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 22px;
}

.steps-list li {
  padding-left: 4px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.steps-list strong {
  color: var(--ink);
}

.quick-grid,
.recent-list {
  display: grid;
  gap: 8px;
}

.quick-example,
.recent-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-soft));
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.quick-example strong,
.quick-example span,
.recent-row strong,
.recent-row span {
  display: block;
}

.quick-example strong,
.recent-row strong {
  font-size: 13px;
}

.quick-example span,
.recent-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.recent-row {
  display: grid;
  gap: 9px;
}

.recent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.text-button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--teal-dark);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

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

.about-panel {
  background:
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--amber) 14%, transparent), transparent 42%),
    color-mix(in srgb, var(--surface) 90%, var(--surface-soft));
}

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

.about-note {
  margin-top: 14px;
  border-left: 4px solid var(--amber);
  padding: 10px 12px;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: color-mix(in srgb, var(--amber) 12%, var(--surface));
  color: var(--ink);
  font-size: 13px;
  font-weight: 720;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .workspace,
  .support-grid {
    grid-template-columns: 1fr;
  }

  .mode-panel {
    position: static;
  }

  .mode-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand span span {
    display: none;
  }

  .icon-button {
    width: 42px;
    padding: 0;
    font-size: 0;
  }

  .mode-list,
  .input-grid {
    grid-template-columns: 1fr;
  }

  .calculator-heading {
    display: grid;
  }

  .result-strip {
    position: sticky;
    bottom: 10px;
    z-index: 2;
  }
}
