@layer base {
  :root {
    --font-sans: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-display: "Manrope", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

    --color-brand-50: #f0fdfb;
    --color-brand-100: #ccfbf1;
    --color-brand-200: #99f6e4;
    --color-brand-300: #5ee7d9;
    --color-brand-400: #2dd4bf;
    --color-brand-500: #14b8a6;
    --color-brand-600: #0d9488;
    --color-brand-700: #0f766e;
    --color-brand-800: #134e4a;
    --color-brand-900: #0d3b35;

    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;

    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-pill: 9999px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.1);
    --shadow-lg: 0 20px 45px rgba(15, 23, 42, 0.1);
  }

  body {
    font-family: var(--font-sans);
    color: #0f172a;
    background-color: #f8fafc;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
  }

  h1, h2, h3, h4 {
    margin: 0;
    font-family: var(--font-display);
    color: #0f172a;
  }

  h1 {
    font-size: clamp(2rem, 1rem + 2vw, 2.5rem);
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: -0.01em;
  }

  h2 {
    font-size: clamp(1.5rem, 1rem + 1.25vw, 2rem);
    line-height: 1.25;
    font-weight: 600;
  }

  h3 {
    font-size: clamp(1.25rem, 0.9rem + 1vw, 1.5rem);
    line-height: 1.3;
    font-weight: 600;
  }

  p {
    margin: 0;
  }

  .page-title {
    font-size: clamp(2rem, 1.4rem + 1.5vw, 2.75rem);
    font-weight: 600;
    letter-spacing: -0.015em;
  }

  .page-subtitle {
    margin-top: 0.75rem;
    color: #475569;
    font-size: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
  }

  .section-heading {
    font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
    font-weight: 600;
  }

  .body-large {
    font-size: 1.125rem;
  }

  .body-small {
    font-size: 0.875rem;
    color: #475569;
  }
}

@layer components {
  .surface-shell {
    border-radius: var(--radius-xl);
    background: #ffffff;
    box-shadow: var(--shadow-sm);
  }

  .surface-sunken {
    border-radius: var(--radius-lg);
    background: #f1f5f9;
    border: 1px solid rgba(148, 163, 184, 0.25);
  }

  .form-control {
    display: block;
    width: 100%;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: #ffffff;
    padding: 0.75rem 0.9rem;
    font-size: 0.95rem;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 120ms ease, box-shadow 120ms ease;
  }

  .form-control::placeholder {
    color: #94a3b8;
  }

  .form-control:focus {
    border-color: var(--color-brand-400);
    box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.12);
  }

  .form-control--select {
    padding-right: 2.75rem;
    background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 8L10 13L15 8' stroke='%23667788' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    appearance: none;
  }

  .form-control textarea,
  .form-control--textarea {
    resize: vertical;
    line-height: 1.6;
  }

  .form-label {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #475569;
  }

  .form-label.required::after {
    content: "*";
    color: #f97316;
    font-size: 0.8em;
  }

  .form-hint {
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: #475569;
  }

  .form-error {
    display: block;
    font-size: 0.875rem;
    color: #e11d48;
  }

  .form-control[aria-invalid="true"] {
    border-color: #f87171;
  }

  .form-control[aria-invalid="true"]:focus {
    border-color: #f87171;
    box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.12);
  }

  .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
  }

  .toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
  }

  .pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-pill);
    background: var(--color-brand-50);
    color: var(--color-brand-600);
    font-weight: 600;
    font-size: 0.75rem;
  }

  /* Focus visible styles for keyboard navigation (WCAG 2.4.7) */
  *:focus-visible {
    outline: 2px solid var(--color-brand-500, #14b8a6);
    outline-offset: 2px;
  }

  /* Remove default outline when using mouse (but keep for keyboard) */
  *:focus:not(:focus-visible) {
    outline: none;
  }
}
