:root {
  --color-bg: #f0f3f7;
  --color-surface: #ffffff;
  --color-text: #172033;
  --color-text-secondary: #5b6678;
  --color-accent: #2563eb;
  --color-accent-dark: #1d4ed8;
  --color-accent-soft: #dbeafe;
  --color-border: #d8dee8;
  --color-warning: #f59e0b;
  --color-warning-soft: #fff7ed;
  --color-muted: #7b8494;
  --radius-sm: 8px;
  --radius-md: 16px;
  --shadow-sm: 0 8px 24px rgba(18, 31, 52, 0.08);
  --shadow-md: 0 18px 40px rgba(18, 31, 52, 0.12);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-9: 36px;
  --space-10: 40px;
  --space-11: 44px;
  --space-12: 48px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--color-bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--color-text);
  background:
    radial-gradient(circle at 12% 8%, rgba(37, 99, 235, 0.10), transparent 30%),
    linear-gradient(180deg, #eef3fb 0%, var(--color-bg) 260px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

header {
  color: #ffffff;
  background: linear-gradient(135deg, #111827 0%, #1e3a8a 54%, #2563eb 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.header-inner,
.footer-inner,
.main-content {
  width: min(100% - var(--space-8), 960px);
  margin: 0 auto;
}

.header-inner {
  padding: var(--space-7) 0 var(--space-5);
}

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

h1 {
  margin-bottom: var(--space-1);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.subtitle {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.92rem;
}

.main-content {
  display: grid;
  gap: var(--space-5);
  padding: var(--space-8) 0 var(--space-10);
}

.card {
  padding: var(--space-6);
  background: var(--color-surface);
  border: 1px solid rgba(216, 222, 232, 0.8);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.mode-section {
  display: grid;
  gap: var(--space-4);
}

.mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.segment-control {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: var(--space-1);
  gap: var(--space-1);
  background: #eef2f7;
  border: 1px solid var(--color-border);
  border-radius: 999px;
}

.segment-btn {
  min-height: 40px;
  padding: 0 var(--space-5);
  color: var(--color-text-secondary);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.segment-btn:hover {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.72);
}

.segment-btn.active {
  color: #ffffff;
  background: var(--color-accent);
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.24);
}

.hint-text {
  color: var(--color-muted);
  font-style: italic;
}

.mode-hint {
  flex: 1 1 280px;
  margin-bottom: 0;
  text-align: right;
}

.input-block {
  display: grid;
  gap: var(--space-3);
}

.label-row,
.number-row,
.channel-count-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.field-label,
.section-title,
.result-label {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

.section-title {
  margin-bottom: 0;
  font-size: 1.15rem;
}

.preset-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.preset-btn {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  color: var(--color-text-secondary);
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.preset-btn:hover,
.preset-btn:has(input:checked) {
  color: var(--color-accent-dark);
  background: var(--color-accent-soft);
  border-color: rgba(37, 99, 235, 0.36);
}

.preset-btn input[type="radio"] {
  accent-color: var(--color-accent);
}

.custom-label {
  border-radius: var(--radius-sm);
}

input[type="number"] {
  min-height: 36px;
  padding: 0 var(--space-2);
  color: var(--color-text);
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.number-input-sm {
  width: 90px;
}

.number-input-md {
  width: 100px;
}

.number-input-xs {
  width: 50px;
}

.unit-label {
  color: var(--color-text-secondary);
  font-weight: 700;
}

.table-wrapper {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.channel-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.channel-table th,
.channel-table td {
  padding: var(--space-3);
  text-align: center;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.channel-table thead {
  color: #334155;
  background: #f1f5f9;
}

.channel-table th {
  font-weight: 800;
  white-space: nowrap;
}

.channel-table small {
  color: var(--color-muted);
  font-weight: 600;
}

.channel-table tbody tr:hover {
  background: #f8fbff;
}

.channel-table tbody tr:last-child td {
  border-bottom: 0;
}

.row-warning {
  color: var(--color-warning, #f59e0b);
  font-size: 0.85rem;
  margin-left: 4px;
}

.park-disabled {
  opacity: 0.45;
}

.park-disabled label {
  cursor: not-allowed;
}

.text-center {
  text-align: center;
}

.ch-label {
  font-weight: 600;
  color: var(--color-text-secondary, #5a6478);
  text-align: center;
  white-space: nowrap;
}

.ch-label .row-warning {
  display: inline-block;
  margin-left: 4px;
  font-weight: 500;
}

.radio-cell {
  white-space: nowrap;
}

.radio-cell label {
  margin-right: 4px;
  cursor: pointer;
}

.apply-all-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-4);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-4);
  color: var(--color-accent-dark);
  background: transparent;
  border: 1px solid rgba(37, 99, 235, 0.42);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
}

.btn-secondary:hover {
  background: var(--color-accent-soft);
}

.help-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: var(--space-1);
  color: var(--color-muted);
  background: #eef2f7;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  cursor: help;
  font-size: 0.75rem;
  font-style: normal;
  line-height: 1;
  vertical-align: middle;
}

.help-trigger.sm {
  width: 17px;
  height: 17px;
  font-size: 0.66rem;
}

.tooltip {
  position: fixed;
  z-index: 9999;
  top: var(--tooltip-top, 0);
  left: var(--tooltip-left, 50%);
  display: none;
  width: max-content;
  max-width: min(280px, 80vw);
  padding: var(--space-3);
  color: #ffffff;
  background: #111827;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.45;
  text-align: left;
  transform: translate(-50%, -100%);
  white-space: normal;
  pointer-events: none;
}

.tooltip::after {
  position: absolute;
  top: 100%;
  left: 50%;
  width: 10px;
  height: 10px;
  background: #111827;
  content: "";
  transform: translate(-50%, -50%) rotate(45deg);
}

.tooltip.tooltip-measuring {
  display: block !important;
  visibility: hidden !important;
}

.help-trigger:hover .tooltip,
.help-trigger:focus .tooltip,
.help-trigger.is-tooltip-active .tooltip,
.help-trigger:focus-visible .tooltip {
  display: block;
}

.result-section {
  background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
}

.result-inner {
  display: grid;
  gap: var(--space-4);
}

.result-label {
  margin-bottom: var(--space-1);
  color: var(--color-text-secondary);
  font-size: 0.95rem;
}

.result-number-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.result-value {
  color: var(--color-accent-dark);
  font-size: clamp(2.5rem, 7vw, 4rem);
  font-weight: 900;
  letter-spacing: -0.06em;
  line-height: 1;
}

.result-unit {
  color: var(--color-text-secondary);
  font-size: 1.25rem;
  font-weight: 800;
}

.result-helper {
  color: var(--color-muted);
  font-style: italic;
}

.result-warning {
  padding: var(--space-3) var(--space-4);
  color: #92400e;
  background: var(--color-warning-soft);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-left: 4px solid var(--color-warning);
  border-radius: var(--radius-sm);
  font-weight: 800;
}

.result-footnote {
  margin: var(--space-4) 0 0;
  color: var(--color-muted);
  font-size: 0.86rem;
}

footer {
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
}

.footer-inner {
  padding: var(--space-6) 0 var(--space-8);
}

.hidden {
  /* biome-ignore lint/complexity/noImportantStyles: required utility must override conditional UI state */
  display: none !important;
}

@media (max-width: 720px) {
  .header-inner,
  .footer-inner,
  .main-content {
    width: min(100% - var(--space-4), 960px);
  }

  .card {
    padding: var(--space-4);
  }

  .segment-control,
  .segment-btn,
  .section-header {
    width: 100%;
  }

  .mode-row {
    display: grid;
    gap: var(--space-3);
  }

  .segment-btn {
    flex: 1 1 0;
    padding-inline: var(--space-3);
  }

  .mode-hint {
    text-align: left;
  }

  .section-header {
    display: grid;
  }

  .apply-all-bar {
    justify-content: stretch;
  }

  .btn-secondary {
    justify-content: center;
    width: 100%;
  }
}
