:root {
  --bg: #07111f;
  --bg-elevated: #0c1a2c;
  --panel: rgba(13, 28, 46, 0.88);
  --panel-strong: #102238;
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(125, 211, 252, 0.34);
  --text: #e5f0fb;
  --muted: #8fa6bc;
  --subtle: #60788f;
  --accent: #67e8f9;
  --accent-strong: #22d3ee;
  --accent-2: #a78bfa;
  --success: #6ee7b7;
  --error: #fda4af;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -5%, rgba(34, 211, 238, 0.14), transparent 34rem),
    radial-gradient(circle at 92% 8%, rgba(167, 139, 250, 0.12), transparent 32rem),
    linear-gradient(180deg, #07111f 0%, #081522 58%, #06101b 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

button, input, textarea { font: inherit; }
button, label, summary { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 28px;
}

.hero {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 26px;
}

.brand-mark {
  position: relative;
  display: grid;
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(34, 211, 238, 0.18), rgba(167, 139, 250, 0.14));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 12px 36px rgba(34, 211, 238, 0.1);
}

.brand-mark span {
  position: absolute;
  width: 25px;
  height: 8px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  transform: rotate(-32deg);
}

.brand-mark span:nth-child(1) { margin-top: -15px; }
.brand-mark span:nth-child(2) { border-color: #c4b5fd; }
.brand-mark span:nth-child(3) { margin-top: 15px; }

.hero-copy { min-width: 0; }

.eyebrow, .step-label {
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.16em;
}

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

h1 {
  margin-bottom: 4px;
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  line-height: 1.2;
  letter-spacing: -0.035em;
}

.hero-copy p {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: auto;
  padding: 8px 12px;
  border: 1px solid rgba(110, 231, 183, 0.24);
  border-radius: 999px;
  color: var(--success);
  background: rgba(110, 231, 183, 0.07);
  font-size: 0.78rem;
  font-weight: 650;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(110, 231, 183, 0.1);
}

.privacy-note {
  display: flex;
  gap: 10px 18px;
  align-items: baseline;
  margin-bottom: 22px;
  padding: 12px 16px;
  border: 1px solid rgba(103, 232, 249, 0.16);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(103, 232, 249, 0.045);
  font-size: 0.84rem;
}

.privacy-note strong { color: #bdeef7; }

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

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(155deg, rgba(16, 34, 56, 0.94), rgba(9, 23, 39, 0.94));
  box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, 0.025);
}

.input-panel, .control-panel, .output-panel { padding: 22px; }

.panel-heading, .control-topline, .output-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-heading h2, .control-topline h2 {
  margin: 2px 0 0;
  font-size: 1.08rem;
  letter-spacing: -0.015em;
}

h2 small {
  margin-left: 4px;
  color: var(--subtle);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 500;
}

.count-pill {
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.72rem;
  white-space: nowrap;
}

.dropzone {
  display: flex;
  min-height: 116px;
  padding: 18px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 1px dashed rgba(103, 232, 249, 0.3);
  border-radius: 13px;
  background: rgba(103, 232, 249, 0.035);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--accent);
  background: rgba(103, 232, 249, 0.085);
}

.dropzone.is-dragover { transform: translateY(-1px); }

.dropzone-icon {
  display: grid;
  width: 30px;
  height: 30px;
  margin-bottom: 6px;
  place-items: center;
  border: 1px solid rgba(103, 232, 249, 0.3);
  border-radius: 9px;
  color: var(--accent);
  background: rgba(103, 232, 249, 0.08);
  font-size: 1.15rem;
  line-height: 1;
}

.dropzone-title { color: #c8e9f3; font-size: 0.88rem; font-weight: 650; }
.dropzone-hint { margin-top: 2px; color: var(--subtle); font-size: 0.75rem; }

.file-status {
  min-height: 24px;
  padding: 6px 2px 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

textarea {
  display: block;
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  color: #d8e8f5;
  background: rgba(3, 12, 22, 0.68);
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.8rem;
  line-height: 1.65;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea::placeholder { color: #4f6981; }
textarea:focus, input:focus { border-color: var(--border-strong); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.08); }

.control-panel { margin-top: 18px; }
.control-topline { margin-bottom: 12px; }

.button-row { display: flex; flex-wrap: wrap; gap: 9px; justify-content: flex-end; }

.button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: 0.58; }

.button-primary {
  color: #04202a;
  background: linear-gradient(135deg, #7debf6, #5bd8e8);
  box-shadow: 0 8px 24px rgba(34, 211, 238, 0.15);
}

.button-primary:hover:not(:disabled) { background: linear-gradient(135deg, #a0f4fa, #6ee7f2); }

.button-ghost {
  border-color: var(--border);
  color: #b9ccdd;
  background: rgba(255, 255, 255, 0.025);
}

.button-ghost:hover:not(:disabled) { border-color: var(--border-strong); background: rgba(103, 232, 249, 0.06); }

.settings-details {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.settings-details summary { width: fit-content; cursor: pointer; color: #a9bfce; user-select: none; }
.settings-details summary:hover { color: var(--accent); }

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(140px, 1fr) minmax(140px, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.field { display: grid; gap: 6px; color: var(--muted); font-size: 0.76rem; }
.field-wide { grid-column: span 1; }

.field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: rgba(3, 12, 22, 0.68);
  padding: 8px 11px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.78rem;
}

.alert {
  margin-top: 18px;
  padding: 13px 16px;
  border: 1px solid;
  border-radius: 12px;
  font-size: 0.84rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.error-alert { border-color: rgba(253, 164, 175, 0.28); color: #fecdd3; background: rgba(244, 63, 94, 0.07); }
.success-alert { border-color: rgba(110, 231, 183, 0.25); color: #bbf7dc; background: rgba(16, 185, 129, 0.06); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.stat-card {
  display: grid;
  gap: 3px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(13, 28, 46, 0.74);
}

.stat-card span { color: var(--muted); font-size: 0.76rem; }
.stat-card strong { color: #d7f7ff; font-size: 1.5rem; line-height: 1.25; }

.country-strip {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(13, 28, 46, 0.62);
}

.country-strip-label { flex: 0 0 auto; color: var(--muted); font-size: 0.76rem; font-weight: 700; }
.country-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.country-chip {
  padding: 4px 9px;
  border: 1px solid rgba(167, 139, 250, 0.22);
  border-radius: 999px;
  color: #d8ccff;
  background: rgba(167, 139, 250, 0.07);
  font-size: 0.74rem;
}

.output-panel { margin-top: 18px; }
.output-heading { align-items: flex-start; }
.output-heading p { margin: 4px 0 0; color: var(--subtle); font-size: 0.74rem; }
#output-text { min-height: 480px; resize: vertical; tab-size: 2; }

footer {
  display: flex;
  gap: 12px 24px;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--subtle);
  font-size: 0.72rem;
}

footer code { color: #9fb7ca; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

button:focus-visible, label:focus-within, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (max-width: 820px) {
  .page-shell { width: min(100% - 28px, 1180px); padding-top: 30px; }
  .hero { align-items: flex-start; flex-wrap: wrap; }
  .local-badge { margin-left: 74px; }
  .input-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .field-wide { grid-column: span 2; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .control-topline, .output-heading { align-items: flex-start; flex-direction: column; }
  .button-row { justify-content: flex-start; }
  footer { flex-direction: column; }
}

@media (max-width: 480px) {
  .privacy-note { flex-direction: column; gap: 2px; }
  .input-panel, .control-panel, .output-panel { padding: 17px; }
  .settings-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: span 1; }
  .country-strip { align-items: flex-start; flex-direction: column; gap: 8px; }
  .brand-mark { flex-basis: 46px; width: 46px; height: 46px; }
  .local-badge { margin-left: 66px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
