/* ============ Base & Typography ============ */
:root {
  --brand: #2563eb;
  --brand-d: #1e40af;
  --ink: #111827;
  --muted: #6b7280;
  --ring: rgba(37, 99, 235, 0.18);
  --surface: #fff;
  --border: #e5e7eb;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: #fafafa;
  line-height: 1.6;
}

.container {
  max-width: 980px;
  margin: 32px auto;
  padding: 0 16px;
}

h1, .h2 {
  font-size: 1.9rem;
  font-weight: 700;
  margin: 0 0 18px;
  color: var(--ink);
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 12px;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 10px;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.small {
  font-size: 0.9rem;
}

.dim {
  color: #6b7280;
  margin-top: 8px;
}

/* ============ Form Controls ============ */
textarea,
input[type="text"],
select {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  resize: vertical;
  min-height: 200px;
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
}

textarea::placeholder {
  color: #9ca3af;
}

/* ============ Segmented Pills (Note Type Selector) ============ */
.segmented {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0 12px;
}

.segmented label,
.segmented-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  font-weight: 500;
  font-size: 0.95rem;
}

.segmented input[type="radio"] {
  display: none;
}

.segmented label:hover,
.segmented-item:hover {
  background: var(--slate-50);
  border-color: var(--slate-300);
}

.segmented input:checked + span,
.segmented label:has(input:checked) {
  background: #eef2ff;
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}

/* ============ Buttons ============ */
.btn {
  --bg: var(--brand);
  --fg: #fff;
  --bd: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.2rem;
  border-radius: 12px;
  border: 2px solid var(--bd);
  background: var(--bg);
  color: var(--fg);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: all 0.12s ease;
  text-decoration: none;
  font-family: inherit;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 6px var(--ring);
}

.btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn:active,
.btn.is-active {
  transform: translateY(1px) scale(0.99);
}

.btn[disabled] {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Primary Button */
.btn-primary {
  --bg: var(--brand);
  --fg: #fff;
  --bd: var(--brand);
}

.btn-primary:hover {
  background: #2b6be7;
}

.btn-primary:active {
  background: var(--brand-d);
  border-color: var(--brand-d);
}

/* Outline Button */
.btn-outline {
  --bg: #fff;
  --fg: var(--ink);
  --bd: var(--border);
}

.btn-outline:hover {
  background: #f3f4f6;
}

.btn-outline:active,
.btn.is-active.btn-outline {
  background: var(--slate-200);
  border-color: var(--slate-300);
}

.btn-outline.copied {
  background: #10b981;
  color: #fff;
  border-color: #10b981;
}

/* Ghost Button */
.btn-ghost {
  --bg: transparent;
  --fg: var(--ink);
  --bd: transparent;
}

.btn-ghost:hover {
  background: var(--slate-100);
}

.btn-ghost:active,
.btn.is-active.btn-ghost {
  background: var(--slate-200);
}

/* Loading State */
.btn.is-loading {
  --bg: #111827;
  --bd: #111827;
  color: #fff;
}

.btn .inline-spinner {
  width: 1.1em;
  height: 1.1em;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.btn-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ============ Cards & Result Frame ============ */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 14px 0;
}

.result-box {
  background: #fff;
  border: 2px solid #111827;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
}

/* ============ Lists ============ */
ul {
  margin: 12px 0;
  padding-left: 20px;
}

ul li {
  margin: 8px 0;
  line-height: 1.6;
}

/* ============ Animations ============ */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
  .container {
    margin: 16px auto;
  }

  .result-box {
    padding: 16px;
  }

  h1, .h2 {
    font-size: 1.5rem;
  }

  .segmented {
    gap: 8px;
  }

  .segmented label,
  .segmented-item {
    padding: 6px 12px;
    font-size: 0.9rem;
  }

  .btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }
}