:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --ink: #17202a;
  --muted: #64717f;
  --line: #d8dee6;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --warn: #b42318;
  --soft: #e8f4f2;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.app {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  padding: 8px 0 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.intro {
  max-width: 680px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.status {
  min-width: 180px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
}

.status.error {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--warn);
  background: #fff7f6;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  gap: 4px;
  margin: 0 0 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(23, 32, 42, 0.06);
}

.mode-switch button {
  border-color: transparent;
  background: transparent;
}

.mode-switch button.active {
  background: var(--accent);
  color: #ffffff;
}

[hidden] {
  display: none !important;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 0.78fr) minmax(360px, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.input-panel {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 18px;
  padding: 22px;
}

.field {
  min-width: 0;
}

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

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfd;
  color: var(--ink);
  font: inherit;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

input.invalid {
  border-color: var(--warn);
  background: #fff7f6;
}

input[type="range"] {
  min-height: 34px;
  padding: 0;
  accent-color: var(--accent);
}

.hint {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.82rem;
}

.prefix-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
}

.prefix-row span {
  color: var(--muted);
  font-size: 1.4rem;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
}

.results-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
}

.result {
  min-height: 92px;
  padding: 17px;
  background: #fbfcfd;
}

.result.primary {
  grid-column: 1 / -1;
  background: var(--soft);
}

.result span {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

output {
  display: block;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: clamp(0.92rem, 2vw, 1.08rem);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.primary output {
  font-size: clamp(1.3rem, 3.2vw, 2rem);
  font-weight: 760;
}

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

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.mode-switch button.active:hover {
  color: #ffffff;
}

@media (max-width: 780px) {
  .app {
    width: min(100% - 22px, 1120px);
    padding: 24px 0;
  }

  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

  .status {
    width: 100%;
    text-align: left;
  }

  .mode-switch {
    display: grid;
  }

  .input-panel,
  .results-panel {
    grid-template-columns: 1fr;
  }

  .result.primary {
    grid-column: auto;
  }
}
