/* StudyKit Hub — single shared stylesheet. Mobile first, light/dark via prefers-color-scheme.
   Palette: teal (#0f766e) primary, amber (#fbbf24) highlight, slate neutrals. All text pairs meet WCAG AA. */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #0f172a;
  --muted: #475569;
  --border: #d5dde8;
  --field-border: #64748b;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --accent-hover: #115e59;
  --accent-soft: #ccfbf1;
  --accent-soft-text: #134e4a;
  --hero-bg: linear-gradient(135deg, #ecfdf5 0%, #f0f9ff 55%, #fffbeb 100%);
  --focus: #b45309;
  --ok: #166534;
  --ok-bg: #dcfce7;
  --err: #b91c1c;
  --err-bg: #fee2e2;
  --warn-bg: #fef3c7;
  --warn-text: #78350f;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 4px 14px rgb(15 23 42 / 6%);
  --radius: 14px;
  --radius-sm: 10px;
  --maxw: 72rem;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #111a2e;
    --surface-2: #1c2740;
    --text: #e6edf7;
    --muted: #a9b6c9;
    --border: #2c3a55;
    --field-border: #7c8aa5;
    --accent: #5eead4;
    --accent-text: #042f2e;
    --accent-hover: #99f6e4;
    --accent-soft: #134e4a;
    --accent-soft-text: #ccfbf1;
    --hero-bg: linear-gradient(135deg, #0d2b2a 0%, #111a2e 60%, #1f1a0d 100%);
    --focus: #fbbf24;
    --ok: #86efac;
    --ok-bg: #12301f;
    --err: #fca5a5;
    --err-bg: #3b1515;
    --warn-bg: #3a2a0a;
    --warn-text: #fde68a;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 14px rgb(0 0 0 / 25%);
  }
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Nastaliq Urdu", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip-link {
  position: absolute; left: 0.5rem; top: -3rem; z-index: 10;
  background: var(--accent); color: var(--accent-text); padding: 0.5rem 1rem; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 0.5rem; color: var(--accent-text); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 1rem; }
@media (min-width: 40rem) { .wrap { padding: 0 1.5rem; } }

/* Header */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.25rem 1rem; padding-top: 0.5rem; padding-bottom: 0.5rem; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 800; font-size: 1.2rem; letter-spacing: -0.01em; color: var(--text); text-decoration: none; min-height: 44px; }
.brand:hover { color: var(--text); }
.brand svg { width: 32px; height: 32px; flex: none; }
.brand-hub { color: var(--accent); }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.15rem 0.35rem; }
.site-nav a { display: inline-flex; align-items: center; padding: 0 0.7rem; min-height: 44px; border-radius: 999px; color: var(--text); text-decoration: none; font-weight: 500; }
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-soft-text); font-weight: 700; }

/* Breadcrumbs */
.breadcrumbs { font-size: 0.9rem; color: var(--muted); margin: 1.1rem 0 0; }
.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.breadcrumbs li + li::before { content: "›"; margin: 0 0.35rem 0 0.1rem; color: var(--muted); }
.breadcrumbs a { color: var(--muted); }

main { padding-bottom: 3rem; }
h1, h2, h3 { letter-spacing: -0.015em; }
h1 { font-size: clamp(1.75rem, 5vw, 2.6rem); line-height: 1.15; margin: 1rem 0 0.6rem; }
h2 { font-size: clamp(1.3rem, 3vw, 1.55rem); line-height: 1.3; margin: 2.25rem 0 0.6rem; }
h3 { font-size: 1.1rem; margin: 1.4rem 0 0.4rem; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 46rem; margin-top: 0; }
.prose { max-width: 46rem; }
.prose li { margin-bottom: 0.35rem; }
.section-intro { color: var(--muted); margin-top: -0.2rem; max-width: 46rem; }
code, kbd, pre { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 0.92em; }
code { background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 5px; }
pre { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.8rem; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
pre code { background: none; padding: 0; }

/* Hero (home and hub pages) */
.hero { background: var(--hero-bg); border-bottom: 1px solid var(--border); padding: 2rem 0 2.25rem; }
.hero h1 { margin-top: 0.25rem; }
.eyebrow { display: inline-block; margin: 0; padding: 0.15rem 0.75rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-soft-text); font-weight: 700; font-size: 0.9rem; letter-spacing: 0.02em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.25rem 0 0; }
@media (min-width: 48rem) { .hero { padding: 3rem 0 3.25rem; } }

/* Tool grid */
.tool-grid { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
.tool-card { display: flex; flex-direction: column; gap: 0.35rem; height: 100%; padding: 1.1rem 1.2rem 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); text-decoration: none; transition: border-color 0.15s, transform 0.15s; }
.tool-card:hover { border-color: var(--accent); color: var(--text); }
@media (prefers-reduced-motion: no-preference) { .tool-card:hover { transform: translateY(-2px); } }
.tool-card h3 { margin: 0; color: var(--accent); font-size: 1.12rem; }
.tool-card p { margin: 0; color: var(--muted); font-size: 0.97rem; }
.tool-card-featured { border-color: var(--accent); border-width: 2px; }
.tool-tag { align-self: flex-start; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent-soft-text); background: var(--accent-soft); padding: 0.05rem 0.55rem; border-radius: 999px; }

/* Planned sections (not yet published) */
.planned-grid { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.planned-card { padding: 1rem 1.2rem; border: 1px dashed var(--field-border); border-radius: var(--radius); background: var(--surface-2); }
.planned-card h3 { margin: 0.5rem 0 0.25rem; }
.planned-card p { margin: 0; color: var(--muted); font-size: 0.97rem; }
.badge { display: inline-block; font-size: 0.82rem; font-weight: 700; color: var(--warn-text); background: var(--warn-bg); padding: 0.05rem 0.6rem; border-radius: 999px; }

/* Tool hub groups */
.tool-group { margin-top: 2rem; }
.tool-group > h2 { margin-top: 0; }

/* Tool panel */
.tool { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin: 1.25rem 0; }
@media (min-width: 40rem) { .tool { padding: 1.25rem 1.5rem; } }
.field { margin-bottom: 0.9rem; }
.field label, .label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.hint { display: block; font-size: 0.9rem; color: var(--muted); margin-top: 0.2rem; }
textarea, input[type="text"], input[type="number"], input[type="search"], select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--field-border); border-radius: var(--radius-sm); padding: 0.6rem 0.75rem; min-height: 44px;
}
textarea { min-height: 12rem; resize: vertical; line-height: 1.5; unicode-bidi: plaintext; }
textarea[readonly] { background: var(--surface-2); }
input[type="number"] { max-width: 10rem; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--err); box-shadow: 0 0 0 1px var(--err); }
.field-error { color: var(--err); font-weight: 600; font-size: 0.95rem; margin: 0.3rem 0 0; }
.field-error:empty { display: none; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.6rem 0.9rem 0.8rem; margin: 0 0 0.9rem; }
legend { font-weight: 600; padding: 0 0.3rem; }
.check { display: flex; align-items: flex-start; gap: 0.5rem; margin: 0.35rem 0; min-height: 32px; }
.check input { width: 1.2rem; height: 1.2rem; margin-top: 0.25rem; flex: none; accent-color: var(--accent); }
.row { display: flex; flex-wrap: wrap; gap: 1rem; }
.row > .field { flex: 1 1 12rem; }
.two-col { display: grid; gap: 1rem; }
@media (min-width: 52rem) { .two-col { grid-template-columns: 1fr 1fr; } }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.6rem 0; }
button, .button {
  font: inherit; font-weight: 650; cursor: pointer; min-height: 44px; padding: 0.5rem 1.1rem;
  border-radius: 999px; border: 2px solid var(--accent); background: var(--accent); color: var(--accent-text);
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
button:hover, .button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
button.secondary, .button.secondary { background: var(--surface); color: var(--accent); }
button.secondary:hover, .button.secondary:hover { background: var(--surface-2); color: var(--accent-hover); }
button.danger { background: transparent; color: var(--err); border-color: var(--err); }
button.danger:hover { background: var(--err-bg); color: var(--err); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.status { min-height: 1.6em; margin: 0.4rem 0; font-weight: 600; }
.status[data-kind="ok"] { color: var(--ok); }
.status[data-kind="error"] { color: var(--err); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.6rem; margin: 0.8rem 0 0; padding: 0; }
.stats div { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.6rem 0.75rem; }
.stats dt { font-size: 0.88rem; color: var(--muted); }
.stats dd { margin: 0; font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.notice { border-left: 4px solid var(--focus); background: var(--warn-bg); color: var(--warn-text); padding: 0.75rem 1rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 1rem 0; }
.notice strong { display: block; }
.callout { border: 1px solid var(--border); border-left: 4px solid var(--accent); background: var(--surface); padding: 0.75rem 1rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 1rem 0; }

.example { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.4rem 1rem 0.8rem; margin: 1rem 0; }
.faq dt { font-weight: 700; margin-top: 1rem; }
.faq dd { margin: 0.25rem 0 0; }
.related ul { padding-left: 1.2rem; }
.policy-meta { color: var(--muted); }
.contact-email { font-size: 1.1rem; font-weight: 700; overflow-wrap: anywhere; }

/* Notes */
.notes-list { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: 0.8rem; }
.note { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.8rem 1rem; }
.note h3 { margin: 0 0 0.25rem; overflow-wrap: anywhere; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0.4rem 0; unicode-bidi: plaintext; max-height: 16rem; overflow: auto; }
.note-meta { font-size: 0.88rem; color: var(--muted); margin: 0; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 0.35rem; padding: 0; margin: 0.35rem 0; }
.tags li { background: var(--accent-soft); color: var(--accent-soft-text); border-radius: 999px; padding: 0.05rem 0.6rem; font-size: 0.85rem; }
.empty-state { color: var(--muted); font-style: italic; }
.file-label { position: relative; }
.file-label input[type="file"] { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 2rem 0 2rem; font-size: 0.95rem; color: var(--muted); }
.footer-cols { display: grid; gap: 1rem 2rem; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.site-footer h2 { font-size: 1rem; margin: 0 0 0.4rem; color: var(--text); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li a { display: inline-block; padding: 0.3rem 0; min-height: 32px; }
.footer-bottom { border-top: 1px solid var(--border); margin-top: 1.5rem; padding-top: 1rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1.5rem; }
.footer-bottom p { margin: 0; }
.footer-brand strong { color: var(--text); }

@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
@media print {
  .site-header, .site-footer, .actions, .skip-link, .breadcrumbs, .hero-actions { display: none; }
  .hero { background: none; border: 0; padding: 0; }
}
