:root {
  --bg: #0d0f14;
  --surface: #141821;
  --surface-2: #1a1f2b;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --border: #232a38;
  --accent-from: #6c5ce7;
  --accent-to: #00d1ff;
  --radius: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 15, 20, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.logo-accent {
  background: linear-gradient(90deg, var(--accent-from), var(--accent-to));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav-tag {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Layout */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  flex: 1;
}

.hero {
  text-align: center;
  margin-bottom: 28px;
}

.hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--accent-from), var(--accent-to));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

.subtitle {
  color: var(--muted);
  max-width: 640px;
  margin: 10px auto 0;
  font-size: 0.98rem;
}

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin-bottom: 22px;
}

.control-group {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
}

.seg-btn,
.btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:active,
.seg-btn:active {
  transform: translateY(1px);
}

.seg-btn.active {
  background: linear-gradient(90deg, var(--accent-from), var(--accent-to));
  color: #fff;
}

.seg-btn:not(.active):hover {
  background: var(--surface-2);
}

.btn-primary {
  background: linear-gradient(90deg, var(--accent-from), var(--accent-to));
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  border-color: var(--accent-from);
  color: var(--text);
}

.btn-secondary:hover {
  background: rgba(108, 92, 231, 0.15);
}

.btn-ghost {
  color: var(--muted);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-2);
}

.btn-small {
  padding: 5px 12px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.btn-small:hover {
  border-color: var(--accent-from);
}

/* Panels */
.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.panel-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

textarea {
  width: 100%;
  min-height: 340px;
  flex: 1;
  resize: vertical;
  border: none;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.85rem;
  line-height: 1.55;
  padding: 14px;
  tab-size: 2;
}

textarea::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

textarea[readonly] {
  background: #11141c;
}

/* Savings */
.savings {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.savings-bar-wrap {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
  margin-bottom: 10px;
}

.savings-bar {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-from), var(--accent-to));
  transition: width 0.4s ease;
}

.savings-text {
  font-size: 0.88rem;
  color: var(--muted);
}

.savings-text strong {
  color: var(--text);
}

/* Status */
.status {
  margin-top: 14px;
  min-height: 1.4em;
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
}

.status.error {
  color: #ff7a8a;
}

.status.ok {
  color: #4ade80;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 760px) {
  .panels {
    grid-template-columns: 1fr;
  }

  textarea {
    min-height: 240px;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .control-group {
    justify-content: center;
  }

  .nav-tag {
    display: none;
  }
}
