:root {
  --bg: #0b0c0a;
  --bg-alt: #111310;
  --surface: #17190f;
  --surface-raised: #1d2015;
  --lime: #b8ff3d;
  --lime-soft: #d4ff8a;
  --lime-dim: #7ecb1e;
  --text: #f5f7ef;
  --text-muted: #a8ac9e;
  --text-faint: #6c7063;
  --border: #262a1b;
  --danger: #ff6b6b;
  --danger-soft: #3a1c1c;
  --radius: 14px;
  --radius-lg: 20px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --sidebar-w: 240px;
}

/* Dark is the brand default (matches the mobile app + landing page);
   :root[data-theme="light"] is set client-side (see app.js /
   the inline cookie-read script in layout.php) and overrides below. */
:root[data-theme="light"] {
  --bg: #f5f6f0;
  --bg-alt: #ffffff;
  --surface: #ffffff;
  --surface-raised: #eef0e4;
  --lime: #8fd41c;
  --lime-soft: #4f7a13;
  --lime-dim: #6ea617;
  --text: #14150f;
  --text-muted: #55594c;
  --text-faint: #8b8f80;
  --border: #e1e4d5;
  --danger: #c0362c;
  --danger-soft: #fbeceb;
}
:root[data-theme="light"] .btn--primary { color: #0b0c0a; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 8px; color: var(--text-muted); line-height: 1.5; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 18px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), opacity .18s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--lime); color: #0b0c0a; }
.btn--primary:hover { box-shadow: 0 8px 24px -10px rgba(184, 255, 61, .6); }
.btn--ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn--ghost:hover { border-color: var(--text-faint); }
.btn--danger { background: var(--danger-soft); color: var(--danger); }
.btn--danger:hover { opacity: .85; }
.btn--small { padding: 6px 14px; font-size: 13px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

button.link {
  background: none; border: none; padding: 0; margin: 0;
  color: var(--lime-soft); font: inherit; cursor: pointer; text-decoration: underline;
}

/* ---------- app shell ---------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  display: block;
  padding: 8px 10px 20px;
  text-decoration: none;
}
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar__link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.sidebar__link:hover { background: var(--surface); color: var(--text); }
.sidebar__link.is-active { background: var(--surface-raised); color: var(--lime-soft); }
.sidebar__link .badge { margin-left: auto; }

/* ---------- brand logo (theme-swapped image pair) ---------- */

.sidebar__logo, .auth-card__logo { display: block; }
.sidebar__logo img, .auth-card__logo img { height: 26px; width: auto; }
.auth-card__logo img { height: 30px; margin-bottom: 4px; }
.sidebar__logo--light, .auth-card__logo--light { display: none; }
:root[data-theme="light"] .sidebar__logo--dark,
:root[data-theme="light"] .auth-card__logo--dark { display: none; }
:root[data-theme="light"] .sidebar__logo--light,
:root[data-theme="light"] .auth-card__logo--light { display: block; }

/* ---------- theme toggle ---------- */

.theme-toggle {
  display: flex; align-items: center; gap: 10px;
  width: 100%; margin: 4px 0 8px; padding: 10px 12px;
  background: none; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text-faint); }
.theme-toggle__icon-dark { display: none; }
:root[data-theme="light"] .theme-toggle__icon-light { display: none; }
:root[data-theme="light"] .theme-toggle__icon-dark { display: inline; }
.theme-toggle--floating {
  position: fixed; top: 20px; right: 20px; width: 40px; height: 40px; padding: 0;
  justify-content: center; border-radius: 50%; margin: 0;
}

/* ---------- sidebar user / dropup ---------- */

.sidebar__footer { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.dropup { position: relative; }
.sidebar__user {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; background: none; border: none; border-radius: var(--radius);
  cursor: pointer; font: inherit; color: var(--text); text-align: left;
}
.sidebar__user:hover { background: var(--surface); }
.sidebar__user-text { flex: 1; min-width: 0; }
.sidebar__user-name { font-size: 14px; font-weight: 600; }
.sidebar__user-handle { font-size: 12px; color: var(--text-faint); }
.sidebar__user-caret { color: var(--text-faint); transition: transform .15s var(--ease); }
.dropup.is-open .sidebar__user-caret { transform: rotate(180deg); }

.dropup__menu {
  display: none;
  position: absolute; bottom: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px; box-shadow: 0 12px 32px -12px rgba(0, 0, 0, .4);
}
.dropup.is-open .dropup__menu { display: block; }
.dropup__item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: calc(var(--radius) - 4px);
  background: none; border: none; color: var(--text); text-decoration: none;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-align: left;
}
.dropup__item:hover { background: var(--surface); }
.dropup__item--danger { color: var(--danger); }
.dropup__divider { height: 1px; background: var(--border); margin: 6px 2px; }
.dropup__langs { display: flex; gap: 4px; padding: 2px 8px 6px; }
.dropup__langs a {
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  color: var(--text-faint); text-decoration: none; border: 1px solid var(--border);
}
.dropup__langs a.is-active { color: var(--lime-soft); border-color: var(--lime-dim); background: var(--surface); }

.main { flex: 1; min-width: 0; }
.main__inner { max-width: 960px; margin: 0 auto; padding: 32px 28px 80px; }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.page-header h1 { font-size: 24px; }
.page-header p { margin: 0; }

/* ---------- flash ---------- */

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.flash--success { background: rgba(184, 255, 61, .12); color: var(--lime-soft); border: 1px solid rgba(184, 255, 61, .25); }
.flash--error { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(255, 107, 107, .3); }

/* ---------- cards & lists ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card + .card { margin-top: 14px; }

.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 820px) { .grid--2, .grid--3 { grid-template-columns: 1fr; } }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.list-item__body { flex: 1; min-width: 0; }
.list-item__title { font-weight: 600; font-size: 15px; }
.list-item__meta { font-size: 13px; color: var(--text-faint); }
.list-item__actions { display: flex; gap: 8px; flex-shrink: 0; }

.empty {
  text-align: center; padding: 48px 20px; color: var(--text-faint);
  border: 1px dashed var(--border); border-radius: var(--radius-lg);
}
.empty .ph, .empty i { font-size: 28px; display: block; margin-bottom: 10px; color: var(--text-faint); }

/* ---------- avatar ---------- */

.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface-raised); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--lime-soft); font-size: 15px;
  object-fit: cover; overflow: hidden;
}
.avatar--sm { width: 32px; height: 32px; font-size: 13px; }
.avatar--lg { width: 84px; height: 84px; font-size: 28px; }
.avatar--xl { width: 104px; height: 104px; font-size: 34px; border-width: 3px; }

/* ---------- badges / pills ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--surface-raised); color: var(--text-muted);
  border: 1px solid var(--border);
}
.pill--lime { background: rgba(184, 255, 61, .12); color: var(--lime-soft); border-color: rgba(184, 255, 61, .25); }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--lime); color: #0b0c0a; font-size: 11px; font-weight: 700;
}

/* ---------- profile hero ---------- */

.profile-hero {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  overflow: hidden;
}
.profile-hero__cover {
  position: absolute; top: 0; left: 0; right: 0; height: 96px;
  background: linear-gradient(135deg, rgba(184, 255, 61, .16), rgba(184, 255, 61, 0) 70%);
}
.profile-hero__body { position: relative; display: flex; gap: 20px; align-items: flex-end; flex-wrap: wrap; }
.profile-hero__info { flex: 1; min-width: 200px; padding-top: 8px; }
.profile-hero__info h1 { font-size: 22px; }
.profile-hero__handle { margin: 0 0 12px; color: var(--text-faint); font-size: 14px; }
.profile-hero__pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.profile-hero__pills .pill { display: inline-flex; align-items: center; gap: 4px; }
.profile-hero__actions { display: flex; gap: 10px; }
.profile-hero__bio { margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--border); color: var(--text); }

/* ---------- tabs ---------- */

.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tabs__link {
  padding: 10px 14px; font-size: 14px; font-weight: 600; text-decoration: none;
  color: var(--text-faint); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs__link.is-active { color: var(--lime-soft); border-color: var(--lime); }

/* ---------- forms ---------- */

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="datetime-local"], input[type="number"], input[type="search"],
select, textarea {
  width: 100%; padding: 11px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-alt); color: var(--text);
  font-family: inherit; font-size: 14px; outline: none;
  transition: border-color .15s var(--ease);
}
input:focus, select:focus, textarea:focus { border-color: var(--lime-dim); }
textarea { resize: vertical; min-height: 90px; }
input[type="range"] { width: 100%; accent-color: var(--lime); }

.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13px; font-weight: 600; color: var(--text-muted);
}
.chip input { accent-color: var(--lime); }
.chip:has(input:checked) { background: rgba(184, 255, 61, .12); color: var(--lime-soft); border-color: rgba(184, 255, 61, .3); }

.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: none; }
.switch-row__label { font-size: 14px; font-weight: 600; }

form.stack { display: flex; flex-direction: column; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* ---------- auth shell ---------- */

.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: radial-gradient(circle at 20% 0%, rgba(184, 255, 61, .08), transparent 55%), var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px;
}
.auth-card__brand { margin-bottom: 24px; }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card__foot { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-faint); }
.auth-card__lang { display: flex; justify-content: center; gap: 6px; margin-top: 16px; }
.auth-card__lang a {
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  color: var(--text-faint); text-decoration: none; border: 1px solid var(--border);
}
.auth-card__lang a.is-active { color: var(--lime-soft); border-color: var(--lime-dim); }

/* ---------- misc ---------- */

.stat-row { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 8px; }
.stat { min-width: 80px; }
.stat__value { font-size: 22px; font-weight: 700; color: var(--lime-soft); }
.stat__label { font-size: 12px; color: var(--text-faint); }

.section-title { font-size: 15px; font-weight: 700; margin: 28px 0 12px; }
.section-title:first-child { margin-top: 0; }

.divider { height: 1px; background: var(--border); margin: 20px 0; }

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.mt-0 { margin-top: 0; }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; padding: 12px; }
  .sidebar__brand { display: none; }
  .sidebar__nav { flex-direction: row; flex: none; }
  .sidebar__footer, .sidebar__user { display: none; }
  .main__inner { padding: 20px 16px 60px; }
}
