/* ================================================
   SIMPLE.CSS — a minimal modern CSS framework
   ================================================ */

/* --- Tokens --- */
:root {
  --primary:    #3b82f6;
  --primary-dk: #1d4ed8;
  --success:    #16a34a;
  --warning:    #d97706;
  --danger:     #dc2626;
  --info:       #0284c7;

  --text:       #0f172a;
  --text-2:     #475569;
  --text-3:     #94a3b8;
  --border:     #e2e8f0;
  --surface:    #ffffff;
  --body-bg:    #f8fafc;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-300:   #cbd5e1;

  --r:    .375rem;
  --r2:   .75rem;
  --rp:   99rem;

  --shadow-sm: 0 1px 2px rgb(0 0 0/.06);
  --shadow:    0 1px 3px rgb(0 0 0/.1), 0 1px 2px -1px rgb(0 0 0/.06);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0/.1), 0 2px 4px -2px rgb(0 0 0/.06);
  --shadow-lg: 0 10px 25px -3px rgb(0 0 0/.1), 0 4px 6px -4px rgb(0 0 0/.05);
  --shadow-xl: 0 20px 40px -4px rgb(0 0 0/.15);

  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
  --ease: 160ms ease;
}

/* --- Dark mode tokens --- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary:    #60a5fa;
    --primary-dk: #93c5fd;
    --success:    #4ade80;
    --warning:    #fbbf24;
    --danger:     #f87171;
    --info:       #38bdf8;
    --text:       #f1f5f9;
    --text-2:     #94a3b8;
    --text-3:     #475569;
    --border:     #1e293b;
    --surface:    #0f172a;
    --body-bg:    #020617;
    --gray-100:   #0f172a;
    --gray-200:   #1e293b;
    --gray-300:   #334155;
    --shadow-sm: 0 1px 2px rgb(0 0 0/.3);
    --shadow:    0 1px 3px rgb(0 0 0/.4), 0 1px 2px -1px rgb(0 0 0/.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0/.4), 0 2px 4px -2px rgb(0 0 0/.3);
    --shadow-lg: 0 10px 25px -3px rgb(0 0 0/.5), 0 4px 6px -4px rgb(0 0 0/.3);
    --shadow-xl: 0 20px 40px -4px rgb(0 0 0/.6);
  }
}

[data-theme="dark"] {
  --primary:    #60a5fa;
  --primary-dk: #93c5fd;
  --success:    #4ade80;
  --warning:    #fbbf24;
  --danger:     #f87171;
  --info:       #38bdf8;
  --text:       #f1f5f9;
  --text-2:     #94a3b8;
  --text-3:     #475569;
  --border:     #1e293b;
  --surface:    #0f172a;
  --body-bg:    #020617;
  --gray-100:   #0f172a;
  --gray-200:   #1e293b;
  --gray-300:   #334155;
  --shadow-sm: 0 1px 2px rgb(0 0 0/.3);
  --shadow:    0 1px 3px rgb(0 0 0/.4), 0 1px 2px -1px rgb(0 0 0/.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0/.4), 0 2px 4px -2px rgb(0 0 0/.3);
  --shadow-lg: 0 10px 25px -3px rgb(0 0 0/.5), 0 4px 6px -4px rgb(0 0 0/.3);
  --shadow-xl: 0 20px 40px -4px rgb(0 0 0/.6);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: hidden; }
html { transition: background-color .25s ease, color .25s ease; }
body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.625;
  color: var(--text);
  background: var(--body-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video, svg, canvas { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; }
ul, ol { padding-left: 1.5em; }
table { border-collapse: collapse; width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
summary { cursor: pointer; user-select: none; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-bottom: .4em;
  margin-top: 1.5em;
}
h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.2rem; }
h5 { font-size: 1.05rem; }
h6 { font-size: 1rem; }
p  { margin-bottom: 1em; }

strong, b  { font-weight: 700; }
em, i      { font-style: italic; }
small      { font-size: .875em; }
u          { text-underline-offset: 3px; }
s          { opacity: .6; }
mark       { background: #fef08a; padding: 0 .15em; border-radius: 2px; }
del        { color: var(--text-2); opacity: .7; }
ins        { text-decoration: none; background: #bbf7d0; padding: 0 .15em; border-radius: 2px; }
abbr[title]{ text-decoration: underline dotted; cursor: help; }
dfn        { font-style: italic; font-weight: 600; }
var        { font-family: var(--mono); font-size: .875em; color: #9333ea; font-style: italic; }
samp       { font-family: var(--mono); font-size: .875em; }
q::before  { content: open-quote; }
q::after   { content: close-quote; }

sub, sup   { font-size: .75em; line-height: 0; position: relative; vertical-align: baseline; }
sup        { top: -.45em; }
sub        { bottom: -.25em; }

kbd {
  font-family: var(--mono);
  font-size: .8em;
  background: var(--text);
  color: #fff;
  padding: .1em .45em;
  border-radius: var(--r);
}
code {
  font-family: var(--mono);
  font-size: .875em;
  background: var(--gray-100);
  color: #be185d;
  padding: .1em .35em;
  border-radius: var(--r);
}
pre {
  font-family: var(--mono);
  font-size: .875rem;
  background: #0f172a;
  color: #e2e8f0;
  padding: 1.25rem 1.5rem;
  border-radius: var(--r2);
  overflow-x: auto;
  line-height: 1.7;
  margin-bottom: 1em;
}
pre code { background: transparent; color: inherit; padding: 0; font-size: inherit; }
blockquote {
  border-left: 4px solid var(--primary);
  padding: .75rem 1.25rem;
  margin: 1.25rem 0;
  background: #eff6ff;
  border-radius: 0 var(--r) var(--r) 0;
  color: var(--text-2);
  font-style: italic;
}
blockquote cite { display: block; margin-top: .5rem; font-size: .875rem; font-style: normal; font-weight: 600; }
address { font-style: normal; }

/* --- Layout --- */
.container {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: 1.5rem;
}
.container-sm { max-width: 740px; }
.section { padding: 4rem 0; }

.grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.flex         { display: flex; gap: 1rem; align-items: center; }
.flex-wrap    { flex-wrap: wrap; }
.flex-col     { flex-direction: column; }
.gap-sm       { gap: .5rem; }
.gap-lg       { gap: 2rem; }

/* --- Navbar --- */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.navbar > .container {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 58px;
}
.navbar-brand {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -.03em;
  flex-shrink: 0;
}
.navbar-menu {
  display: flex;
  align-items: center;
  gap: .2rem;
  list-style: none;
  padding: 0;
  flex: 1;
}
.navbar-menu a {
  padding: .35rem .75rem;
  border-radius: var(--r);
  color: var(--text-2);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--ease);
}
.navbar-menu a:hover, .navbar-menu a.active {
  background: var(--gray-100);
  color: var(--text);
  text-decoration: none;
}
.navbar-end { margin-left: auto; display: flex; gap: .5rem; align-items: center; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4em;
  padding: .5rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--r);
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--ease);
  white-space: nowrap;
  user-select: none;
  background: var(--btn-bg, var(--primary));
  color: var(--btn-txt, #fff);
  border-color: var(--btn-border, transparent);
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); filter: brightness(.96); }
.btn:disabled, .btn[disabled] { opacity: .45; pointer-events: none; }

.btn.success { --btn-bg: var(--success); }
.btn.warning { --btn-bg: var(--warning); }
.btn.danger  { --btn-bg: var(--danger); }
.btn.info    { --btn-bg: var(--info); }
.btn.dark    { --btn-bg: #1e293b; }
.btn.light   { --btn-bg: var(--gray-200); --btn-txt: var(--text); }
.btn.ghost   {
  --btn-bg: transparent;
  --btn-txt: var(--text);
  --btn-border: var(--border);
}
.btn.ghost:hover { background: var(--gray-100); filter: none; }

.btn.sm   { padding: .3rem .75rem; font-size: .8rem; }
.btn.lg   { padding: .7rem 1.5rem; font-size: 1rem; }
.btn.xl   { padding: .9rem 2rem; font-size: 1.1rem; }
.btn.pill { border-radius: var(--rp); }
.btn.block{ width: 100%; }
.btn.icon { padding: .5rem; aspect-ratio: 1; }

/* --- Forms --- */
.field          { margin-bottom: 1.25rem; }
.field label    { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .35rem; color: var(--text); }
.field label.switch, .field label.check-group { display: inline-flex; margin-bottom: 0; }
.field .hint    { font-size: .8rem; color: var(--text-2); margin-top: .35rem; }
.field .error   { font-size: .8rem; color: var(--danger); margin-top: .35rem; }

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgb(220 38 38/.15);
}

input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image]),
select,
textarea {
  display: block;
  width: 100%;
  padding: .5rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--ease), box-shadow var(--ease);
  outline: none;
  line-height: 1.5;
}
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image]):focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(59 130 246/.2);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 100px; }

/* Custom select */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  padding-right: 2.5rem;
}
select[multiple] { background-image: none; padding-right: .8rem; height: auto; }

/* Checkbox & Radio */
input[type=checkbox],
input[type=radio] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.check-group,
.radio-group {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .4rem;
  cursor: pointer;
  font-size: .9rem;
}

/* Checkbox toggle inside .check-group */
.check-group input[type=checkbox] {
  appearance: none;
  -webkit-appearance: none;
  width: 2.5rem;
  height: 1.375rem;
  background: var(--gray-300);
  border-radius: var(--rp);
  transition: background var(--ease);
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}
.check-group input[type=checkbox]::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 1rem;
  height: 1rem;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--ease);
}
.check-group input[type=checkbox]:checked { background: var(--primary); }
.check-group input[type=checkbox]:checked::after { transform: translateX(1.125rem); }
.check-group input[type=checkbox]:disabled { opacity: .5; cursor: not-allowed; }

/* Range */
input[type=range] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
  height: 4px;
}

/* Color */
input[type=color] {
  width: 3rem;
  height: 2.25rem;
  padding: .2rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  background: var(--surface);
}

/* Native file */
input[type=file] {
  display: block;
  width: 100%;
  font-size: .875rem;
  padding: .4rem .5rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
}
input[type=file]::file-selector-button {
  padding: .25rem .7rem;
  background: var(--gray-200);
  border: none;
  border-radius: var(--r);
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  margin-right: .75rem;
  transition: background var(--ease);
  color: var(--text);
}
input[type=file]::file-selector-button:hover { background: var(--gray-300); }

/* File drop zone */
.file-upload {
  border: 2px dashed var(--border);
  border-radius: var(--r2);
  background: var(--gray-100);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--ease);
  display: block;
}
.file-upload:hover { border-color: var(--primary); background: #eff6ff; }
.file-upload input[type=file] { display: none; }
.file-upload .icon { font-size: 2.5rem; margin: 0 auto .5rem; }
.file-upload p { color: var(--text-2); font-size: .9rem; margin: 0; line-height: 1.5; }
.file-upload strong { color: var(--primary); }

/* Input group */
.input-group { display: flex; align-items: stretch; }
.input-group input {
  flex: 1;
  border-radius: var(--r) 0 0 var(--r);
}
.input-group .btn { border-radius: 0 var(--r) var(--r) 0; }
.input-group .addon {
  display: flex;
  align-items: center;
  padding: .5rem .8rem;
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--r) 0 0 var(--r);
  color: var(--text-2);
  font-size: .875rem;
  white-space: nowrap;
}
.input-group .addon + input { border-radius: 0 var(--r) var(--r) 0; }

/* Toggle / Switch */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  cursor: pointer;
  font-size: .9rem;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 2.5rem;
  height: 1.375rem;
  background: var(--gray-300);
  border-radius: var(--rp);
  transition: background var(--ease);
  position: relative;
  flex-shrink: 0;
}
.switch .track::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 1rem;
  height: 1rem;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--ease);
}
.switch input:checked ~ .track { background: var(--primary); }
.switch input:checked ~ .track::after { transform: translateX(1.125rem); }

/* output */
output {
  display: inline-block;
  font-size: .875rem;
  font-weight: 700;
  color: var(--primary);
  padding: .2rem .5rem;
  background: #eff6ff;
  border-radius: var(--r);
  margin-top: .5rem;
}

/* --- Tables --- */
th {
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  padding: .7rem 1rem;
  border-bottom: 2px solid var(--border);
}
td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
.table-hover tr:hover td { background: var(--gray-100); }
.table-striped tr:nth-child(even) td { background: var(--gray-100); }
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  overflow-x: auto;
  overflow-y: hidden;
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
caption {
  caption-side: top;
  text-align: left;
  font-weight: 700;
  font-size: .875rem;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.card-body   { padding: 1.25rem; }
.card-footer {
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--gray-100);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.card-img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }

/* --- Alerts --- */
.alert {
  padding: .875rem 1.125rem;
  border-radius: var(--r);
  border: 1px solid transparent;
  font-size: .9rem;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: 1rem;
}
.alert-icon    { flex-shrink: 0; font-size: 1rem; margin-top: .075rem; }
.alert-content { flex: 1; }
.alert-title   { font-weight: 700; margin-bottom: .2rem; }
.alert.primary { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert.success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.alert.warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert.danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.info    { background: #ecfeff; border-color: #a5f3fc; color: #155e75; }

/* --- Badges & Tags --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .15em .55em;
  font-size: .72rem;
  font-weight: 700;
  border-radius: var(--rp);
  background: var(--badge-bg, var(--primary));
  color: var(--badge-txt, #fff);
  line-height: 1.4;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge.success { --badge-bg: var(--success); }
.badge.warning { --badge-bg: var(--warning); }
.badge.danger  { --badge-bg: var(--danger); }
.badge.info    { --badge-bg: var(--info); }
.badge.dark    { --badge-bg: #1e293b; }
.badge.light   { --badge-bg: var(--gray-200); --badge-txt: var(--text); }
.badge.outline { --badge-bg: transparent; --badge-txt: currentColor; outline: 1.5px solid currentColor; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: .35em;
  padding: .3em .75em;
  font-size: .8rem;
  font-weight: 500;
  border-radius: var(--rp);
  background: var(--gray-100);
  border: 1px solid var(--border);
  color: var(--text-2);
  line-height: 1.4;
}
.tag .close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: .8rem;
  background: transparent;
  border: none;
  color: inherit;
  padding: 0;
  opacity: .6;
  transition: all var(--ease);
}
.tag .close:hover { opacity: 1; background: rgb(0 0 0/.12); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .9rem;
  background: var(--gray-100);
  border: 1px solid var(--border);
  border-radius: var(--rp);
  font-size: .85rem;
  font-weight: 500;
}

/* --- Progress & Meter --- */
progress {
  width: 100%;
  height: .7rem;
  border: none;
  border-radius: var(--rp);
  background: var(--gray-200);
  appearance: none;
  overflow: hidden;
  display: block;
}
progress::-webkit-progress-bar   { background: var(--gray-200); border-radius: var(--rp); }
progress::-webkit-progress-value { background: var(--primary); border-radius: var(--rp); transition: width .3s; }
progress::-moz-progress-bar      { background: var(--primary); border-radius: var(--rp); }

progress.success::-webkit-progress-value { background: var(--success); }
progress.success::-moz-progress-bar      { background: var(--success); }
progress.warning::-webkit-progress-value { background: var(--warning); }
progress.warning::-moz-progress-bar      { background: var(--warning); }
progress.danger::-webkit-progress-value  { background: var(--danger); }
progress.danger::-moz-progress-bar       { background: var(--danger); }
progress.info::-webkit-progress-value    { background: var(--info); }
progress.info::-moz-progress-bar         { background: var(--info); }

meter {
  width: 100%;
  height: .7rem;
  appearance: none;
  overflow: hidden;
  border-radius: var(--rp);
  display: block;
}
meter::-webkit-meter-bar               { background: var(--gray-200); border-radius: var(--rp); border: none; }
meter::-webkit-meter-optimum-value     { background: var(--success); }
meter::-webkit-meter-suboptimum-value  { background: var(--warning); }
meter::-webkit-meter-even-less-good-value { background: var(--danger); }

/* --- Tabs --- */
.tabs {
  border-bottom: 2px solid var(--border);
  display: flex;
  list-style: none;
  padding: 0;
  margin-bottom: 1.5rem;
  gap: 0;
}
.tabs li a,
.tabs li button {
  display: block;
  padding: .6rem 1rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all var(--ease);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  text-decoration: none;
}
.tabs li a:hover,
.tabs li button:hover { color: var(--primary); text-decoration: none; }
.tabs li.active a,
.tabs li.active button { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content        { display: none; }
.tab-content.active { display: block; }

/* --- Accordion --- */
details {
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: .5rem;
}
details > summary {
  padding: .875rem 1.125rem;
  font-weight: 600;
  font-size: .9rem;
  background: var(--surface);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background var(--ease);
}
details > summary::-webkit-details-marker { display: none; }
details > summary::after {
  content: '+';
  font-size: 1.4rem;
  font-weight: 300;
  color: var(--text-2);
  transition: transform var(--ease);
  flex-shrink: 0;
  line-height: 1;
}
details[open] > summary::after { transform: rotate(45deg); }
details > summary:hover { background: var(--gray-100); }
details[open] > summary { border-bottom: 1px solid var(--border); }
details > div, details > p { padding: 1rem 1.125rem; }

/* --- Modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0/.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--ease), visibility var(--ease);
}
.modal-backdrop.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--surface);
  border-radius: var(--r2);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-xl);
  transform: scale(.96) translateY(-12px);
  transition: transform .2s ease;
  max-height: 90dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-backdrop.open .modal { transform: scale(1) translateY(0); }
.modal-header {
  padding: 1.125rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.modal-close {
  width: 1.875rem;
  height: 1.875rem;
  border-radius: var(--r);
  border: none;
  background: var(--gray-100);
  color: var(--text-2);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--ease);
  padding: 0;
  line-height: 1;
}
.modal-close:hover { background: var(--gray-200); color: var(--text); }
.modal-body   { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  background: var(--gray-100);
  flex-shrink: 0;
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: .625rem;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: .875rem 1rem;
  box-shadow: var(--shadow-lg);
  max-width: 360px;
  min-width: 280px;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  pointer-events: all;
  animation: toastIn .22s ease forwards;
  border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.danger  { border-left-color: var(--danger);  }
.toast.info    { border-left-color: var(--info);    }
.toast-icon  { font-size: 1.1rem; flex-shrink: 0; padding-top: .05rem; }
.toast-body  { flex: 1; min-width: 0; }
.toast-title { font-weight: 700; font-size: .875rem; margin-bottom: .1rem; }
.toast-msg   { font-size: .8rem; color: var(--text-2); }
.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-3);
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
  transition: color var(--ease);
}
.toast-close:hover { color: var(--text); }
.toast.hide { animation: toastOut .22s ease forwards; }

@keyframes toastIn  { from { transform: translateX(110%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { from { transform: none; opacity: 1; } to { transform: translateX(110%); opacity: 0; } }

/* --- Avatar --- */
.avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .875rem;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar.sm { width: 2rem; height: 2rem; font-size: .75rem; }
.avatar.lg { width: 3.5rem; height: 3.5rem; font-size: 1.2rem; }

/* --- Breadcrumb --- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: .5rem;
  list-style: none;
  padding: 0;
  font-size: .875rem;
  flex-wrap: wrap;
}
.breadcrumb li + li::before { content: '/'; opacity: .35; margin-right: .25rem; }
.breadcrumb li:last-child { color: var(--text); font-weight: 600; }
.breadcrumb a { color: var(--text-2); }
.breadcrumb a:hover { color: var(--primary); }

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  gap: .25rem;
  list-style: none;
  padding: 0;
  flex-wrap: wrap;
}
.pagination a, .pagination button, .pagination span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 .5rem;
  border-radius: var(--r);
  border: 1px solid var(--border);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--ease);
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}
.pagination a:hover, .pagination button:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.pagination .active a, .pagination .active span { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { opacity: .4; pointer-events: none; }
.pagination .dots { border-color: transparent; background: transparent; cursor: default; }

/* --- Dropdown --- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  min-width: 176px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  box-shadow: var(--shadow-md);
  z-index: 200;
  padding: .35rem;
  list-style: none;
  display: none;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu li a,
.dropdown-menu li button {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem .75rem;
  border-radius: var(--r);
  font-size: .875rem;
  color: var(--text);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--ease);
}
.dropdown-menu li a:hover,
.dropdown-menu li button:hover { background: var(--gray-100); }
.dropdown-menu hr { margin: .35rem 0; border-color: var(--border); }

/* --- Tooltip --- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  font-size: .75rem;
  font-weight: 500;
  padding: .35rem .65rem;
  border-radius: var(--r);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--ease);
  z-index: 500;
  font-style: normal;
}
[data-tooltip]:hover::after { opacity: 1; }

/* --- Spinner --- */
.spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.spinner.sm { width: .875rem; height: .875rem; }
.spinner.lg { width: 2rem; height: 2rem; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Skeleton --- */
.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r);
  display: block;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* --- Divider --- */
.divider {
  display: flex;
  align-items: center;
  gap: .875rem;
  color: var(--text-2);
  font-size: .875rem;
  margin: 1.25rem 0;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* --- Hero --- */
.hero {
  padding: 5rem 0 4rem;
  text-align: center;
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 50%, #f0fdf4 100%);
}
.hero h1 { font-size: 3.25rem; letter-spacing: -.04em; margin: 0 0 1rem; }
.hero p  { font-size: 1.15rem; color: var(--text-2); max-width: 580px; margin: 0 auto 2rem; }

/* --- Section label --- */
.section-label {
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--primary);
  margin-bottom: .75rem;
}

/* --- Utilities --- */
.text-center    { text-align: center; }
.text-right     { text-align: right; }
.text-muted     { color: var(--text-2); }
.text-small     { font-size: .875rem; }
.text-xs        { font-size: .75rem; }
.text-lg        { font-size: 1.125rem; }
.font-bold      { font-weight: 700; }
.font-mono      { font-family: var(--mono); }
.mt-1           { margin-top: .5rem; }
.mt-2           { margin-top: 1rem; }
.mt-4           { margin-top: 2rem; }
.mb-1           { margin-bottom: .5rem; }
.mb-2           { margin-bottom: 1rem; }
.mb-4           { margin-bottom: 2rem; }
.p-2            { padding: 1rem; }
.d-block        { display: block; }
.d-none         { display: none; }
.w-full         { width: 100%; }
.items-start    { align-items: flex-start; }
.items-center   { align-items: center; }
.justify-center { justify-content: center; }
.justify-between{ justify-content: space-between; }
.rounded        { border-radius: var(--r); }
.rounded-lg     { border-radius: var(--r2); }
.rounded-full   { border-radius: var(--rp); }
.shadow         { box-shadow: var(--shadow); }
.shadow-lg      { box-shadow: var(--shadow-lg); }
.overflow-hidden{ overflow: hidden; }
.truncate       { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opacity-50     { opacity: .5; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: none;
}

/* --- Theme toggle button --- */
.theme-toggle {
  width: 2.125rem;
  height: 2.125rem;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--gray-100);
  color: var(--text-2);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--ease);
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
}
.theme-toggle:hover { background: var(--gray-200); color: var(--text); }

/* --- Dark-specific overrides (colour adjustments that can't use vars alone) --- */
[data-theme="dark"] blockquote         { background: rgba(96 165 250/.1); }
[data-theme="dark"] code               { background: rgba(255 255 255/.07); color: #f472b6; }
[data-theme="dark"] pre                { background: #0a0f1e; }
[data-theme="dark"] .hero              { background: linear-gradient(135deg,#0f172a 0%,#0c1a2e 50%,#0b1f15 100%); }
[data-theme="dark"] .alert.primary     { background: rgba(96 165 250/.12); border-color: rgba(96 165 250/.3); color: #93c5fd; }
[data-theme="dark"] .alert.success     { background: rgba(74 222 128/.1);  border-color: rgba(74 222 128/.3); color: #86efac; }
[data-theme="dark"] .alert.warning     { background: rgba(251 191 36/.1);  border-color: rgba(251 191 36/.3); color: #fcd34d; }
[data-theme="dark"] .alert.danger      { background: rgba(248 113 113/.1); border-color: rgba(248 113 113/.3); color: #fca5a5; }
[data-theme="dark"] .alert.info        { background: rgba(56 189 248/.1);  border-color: rgba(56 189 248/.3); color: #7dd3fc; }
[data-theme="dark"] .modal-backdrop    { background: rgb(0 0 0/.65); }
[data-theme="dark"] .skeleton          { background: linear-gradient(90deg,#1e293b 25%,#0f172a 50%,#1e293b 75%); background-size: 200%; }
[data-theme="dark"] mark               { background: #713f12; color: #fef3c7; }
[data-theme="dark"] ins                { background: #14532d; color: #bbf7d0; }
[data-theme="dark"] kbd               { background: #334155; }
[data-theme="dark"] .file-upload:hover { background: rgba(96 165 250/.08); }

/* Same overrides for OS dark pref when no explicit theme is set */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) blockquote      { background: rgba(96 165 250/.1); }
  :root:not([data-theme="light"]) code            { background: rgba(255 255 255/.07); color: #f472b6; }
  :root:not([data-theme="light"]) pre             { background: #0a0f1e; }
  :root:not([data-theme="light"]) .hero           { background: linear-gradient(135deg,#0f172a 0%,#0c1a2e 50%,#0b1f15 100%); }
  :root:not([data-theme="light"]) .alert.primary  { background: rgba(96 165 250/.12); border-color: rgba(96 165 250/.3); color: #93c5fd; }
  :root:not([data-theme="light"]) .alert.success  { background: rgba(74 222 128/.1);  border-color: rgba(74 222 128/.3); color: #86efac; }
  :root:not([data-theme="light"]) .alert.warning  { background: rgba(251 191 36/.1);  border-color: rgba(251 191 36/.3); color: #fcd34d; }
  :root:not([data-theme="light"]) .alert.danger   { background: rgba(248 113 113/.1); border-color: rgba(248 113 113/.3); color: #fca5a5; }
  :root:not([data-theme="light"]) .alert.info     { background: rgba(56 189 248/.1);  border-color: rgba(56 189 248/.3); color: #7dd3fc; }
  :root:not([data-theme="light"]) mark            { background: #713f12; color: #fef3c7; }
  :root:not([data-theme="light"]) ins             { background: #14532d; color: #bbf7d0; }
  :root:not([data-theme="light"]) kbd            { background: #334155; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.6rem; }
  .hero h1 { font-size: 2.25rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .container { padding-inline: 1rem; }
  .toast-container { left: 1rem; right: 1rem; bottom: 1rem; }
  .toast { max-width: 100%; min-width: unset; }
  .admin-layout { grid-template-columns: 1fr !important; }
  .navbar-end { gap: .35rem; }
  .navbar-end .btn { font-size: .75rem; padding: .3rem .55rem; }
}

/* --- Navbar layout --- */
.nav-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 58px;
}

/* --- Hamburger button --- */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  color: inherit;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
  transform-origin: center;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 700px) {
  .hamburger { display: flex; }

  .navbar-end { margin-left: auto; order: 2; }
  .hamburger  { order: 3; }

  .navbar-menu {
    display: none !important;
    flex-direction: column;
    width: 100%;
    order: 4;
    padding: .5rem 0 .75rem;
    gap: .15rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
  }
  .navbar-menu.open { display: flex !important; }
  .navbar-menu a {
    display: block;
    padding: .55rem 1rem;
  }

  .nav-container {
    flex-wrap: wrap;
    height: auto;
    padding-block: .6rem;
  }
  .navbar-brand { order: 1; }
}
