:root {
  --bg: #000000;
  --fg: #f2f2f2;
  --muted: #8a8a8a;
  --faint: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Pretendard", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 10;
  opacity: 1;
  transition: opacity 0.6s ease;
}

.loader.is-done {
  opacity: 0;
  pointer-events: none;
}

.loader-word {
  font-size: clamp(40px, 7vw, 80px);
  font-weight: 800;
  letter-spacing: 0.02em;
  animation: word-fade-in 0.9s ease both;
}

@keyframes word-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding: 8vh 24px 64px;
}

.display {
  font-size: clamp(25px, 4.5vw, 47px);
  min-height: 1.2em;
}

.input-shell {
  width: min(560px, 90vw);
}

.formula-input {
  width: 100%;
  padding: 14px 18px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--faint);
  font-family: "SFMono-Regular", "Consolas", monospace;
  font-size: 16px;
  text-align: center;
  outline: none;
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.formula-input::placeholder {
  color: transparent;
}

.formula-input:hover,
.formula-input:focus {
  color: var(--fg);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.formula-input.is-error {
  color: #ff6b6b;
}

.panel {
  width: min(880px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modes {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.mode-btn {
  padding: 10px 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: linear-gradient(180deg, #1d1d1d, #101010);
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(140, 140, 140, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.mode-btn:hover {
  color: var(--fg);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(150, 150, 150, 0.11), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.mode-btn.is-active {
  color: var(--fg);
  border-color: rgba(91, 140, 255, 0.5);
  background: linear-gradient(180deg, #2b3140, #14161d);
  box-shadow: 0 3px 10px rgba(150, 150, 150, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.graph-wrap {
  position: relative;
}

.graph {
  display: block;
  width: 100%;
  height: 360px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  background:
    radial-gradient(ellipse 70% 60% at 50% 50%, rgba(120, 150, 255, 0.05), rgba(255, 255, 255, 0) 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), rgba(255, 255, 255, 0));
  box-shadow:
    0 10px 34px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.tooltip {
  position: absolute;
  transform: translate(-50%, -135%);
  padding: 4px 9px;
  background: rgba(18, 18, 18, 0.92);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg);
  font-family: "SFMono-Regular", "Consolas", monospace;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
}

.bar-wrap {
  position: relative;
}

.bar {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
  outline: none;
  cursor: pointer;
}

.bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--fg);
  border: none;
  transition: transform 0.15s ease;
}

.bar::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--fg);
  border: none;
  transition: transform 0.15s ease;
}

.bar:active::-webkit-slider-thumb {
  transform: scale(1.2);
}

.bar:active::-moz-range-thumb {
  transform: scale(1.2);
}

.bar-bubble {
  position: absolute;
  bottom: 20px;
  transform: translateX(-50%);
  padding: 3px 9px;
  background: var(--fg);
  color: #000;
  border-radius: 6px;
  font-family: "SFMono-Regular", "Consolas", monospace;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.bar-bubble.is-visible {
  opacity: 1;
}

.readout {
  min-height: 1.2em;
  text-align: center;
  color: var(--muted);
  font-family: "SFMono-Regular", "Consolas", monospace;
  font-size: 14px;
}

.settings-btn {
  position: fixed;
  top: 24px;
  right: 28px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--faint);
  border-radius: 8px;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.settings-btn:hover {
  color: var(--fg);
  border-color: var(--line);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.modal.is-open {
  opacity: 1;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(420px, 90vw);
  padding: 28px;
  background: #0c0c0c;
  border: 1px solid var(--line);
  border-radius: 14px;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.25s ease;
}

.modal.is-open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
}

.modal-desc {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field input {
  width: 100%;
  padding: 10px 12px;
  background: #000;
  border: 1px solid var(--faint);
  border-radius: 8px;
  color: var(--fg);
  font-family: "SFMono-Regular", "Consolas", monospace;
  font-size: 15px;
  outline: none;
}

.field input:focus {
  border-color: var(--line);
}

.field input.is-error {
  border-color: #ff6b6b;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.modal-btn {
  padding: 9px 18px;
  background: transparent;
  border: 1px solid var(--faint);
  border-radius: 8px;
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.modal-btn.is-primary {
  background: #5b8cff;
  border-color: #5b8cff;
  color: #000;
  font-weight: 600;
}
