:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #161616;
  --muted: #4a4a4a;
  --accent: #5a5ff1;
  --accent-strong: #2d2f93;
  --danger: #c62828;
  --border: #e3e3e8;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  --radius: 16px;
  --mono: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 24px;
}

.page {
  max-width: 900px;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

h1 {
  margin: 6px 0 8px;
  font-size: 2rem;
}

.subtitle {
  color: var(--muted);
  margin: 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--accent-strong);
  margin: 0;
  font-weight: 700;
}

.badge {
  background: linear-gradient(135deg, #b5c7ff, #7f8eff);
  color: #0f1446;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(91, 101, 255, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.badge::before {
  content: '🛡️';
  font-size: 1rem;
}

.controls, .outputs, .info, .stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.text-input, .text-output {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  background: #fafafa;
  color: var(--text);
  font-family: var(--mono);
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 150px;
}

.text-input:focus, .text-output:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90, 95, 241, 0.2);
}

.text-output {
  background: #fdfdfd;
}

.input-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.warning {
  color: var(--danger);
  font-weight: 700;
}

.error {
  margin: 0;
  min-height: 20px;
  color: var(--danger);
  font-weight: 600;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 12px 30px rgba(90, 95, 241, 0.35);
  touch-action: manipulation;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 35px rgba(90, 95, 241, 0.4);
  background: #4a4fdc;
}

.primary-btn:active {
  transform: translateY(0);
}

.primary-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  box-shadow: none;
}

.outputs {
  gap: 16px;
}

.output-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.output-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  display: inline-block;
  background: rgba(90, 95, 241, 0.12);
  color: var(--accent-strong);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
}

.pill.secondary {
  background: rgba(22, 22, 22, 0.08);
  color: var(--muted);
}

.monospace {
  font-family: var(--mono);
}

.stats h3, .info h3 {
  margin: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.stat {
  background: #f7f7fb;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-value {
  margin: 6px 0 0;
  font-weight: 800;
  font-size: 1.2rem;
}

.info ul {
  padding-left: 20px;
  margin: 0;
  color: var(--muted);
}

.info p {
  margin: 0 0 6px;
  color: var(--muted);
}

.credits {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.credits a {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.credits a:hover {
  text-decoration: underline;
}

.text-input.warning-border {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.15);
}

@media (max-width: 640px) {
  body {
    padding: 16px;
  }

  .card {
    padding: 20px;
  }

  h1 {
    font-size: 1.6rem;
  }

  .primary-btn {
    width: 100%;
    justify-content: center;
    font-size: 1.05rem;
    padding: 14px 18px;
  }

  .text-input, .text-output {
    min-height: 180px;
  }
}
