/* ===================================================================
   Star Champions — refined with UI/UX Pro Max guidance
   Style: Claymorphism (soft-3D, chunky, toy-like) · dual theme
   Type:  Baloo 2 (display) + Nunito (body)
   =================================================================== */

/* ---------- Shared design tokens ---------- */
:root {
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --border-w: 2.5px;
  --tap: 44px;                 /* min touch target */
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 180ms;
  --t-med: 240ms;
  --z-nav: 20;
  --z-overlay: 50;
  --z-toast: 60;
}

/* ---------- DARK theme (default — matches reference) ---------- */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  --page-grad: radial-gradient(120% 90% at 50% -10%, #3b2473 0%, #2a1a52 42%, #1a1030 100%);
  --frame-grad: radial-gradient(140% 60% at 50% 0%, rgba(124,58,237,0.30), transparent 60%),
                linear-gradient(180deg, #20143f 0%, #170d2b 100%);
  --card: rgba(48, 33, 92, 0.72);
  --card-2: rgba(40, 28, 78, 0.50);
  --card-line: rgba(170, 130, 255, 0.30);
  --text: #f4f1ff;
  --muted: #c3b6e6;          /* >=4.5:1 on dark card */
  --muted-2: #9d8fc4;
  --violet: #8b5cf6;
  --violet-bright: #a855f7;
  --pink: #ec4899;
  --gold: #fcd34d;
  --gold-deep: #f59e0b;
  --pos: #4ade80;            /* score-up green, bright for dark */
  --neg: #fb7185;
  --nav-bg: linear-gradient(180deg, rgba(23,13,43,0.2), rgba(23,13,43,0.94) 40%);
  /* clay shadows: outer drop + top inner highlight */
  --clay: 5px 6px 14px rgba(8,4,20,0.45), -3px -3px 10px rgba(150,110,230,0.10),
          inset 1px 1px 1px rgba(255,255,255,0.07);
  --clay-press: inset 3px 3px 8px rgba(8,4,20,0.55), inset -2px -2px 6px rgba(150,110,230,0.10);
  --focus-ring: 0 0 0 3px rgba(168,85,247,0.65);
}

/* ---------- LIGHT theme (Pro Max claymorphism rec) ---------- */
[data-theme="light"] {
  color-scheme: light;
  --page-grad: radial-gradient(120% 90% at 50% -10%, #e0e7ff 0%, #eef2ff 45%, #f5f3ff 100%);
  --frame-grad: radial-gradient(140% 55% at 50% 0%, rgba(129,140,248,0.28), transparent 60%),
                linear-gradient(180deg, #f4f5ff 0%, #eceaff 100%);
  --card: #ffffff;
  --card-2: #f3f1ff;
  --card-line: rgba(99, 102, 241, 0.18);
  --text: #1e1b4b;           /* indigo-950, ~13:1 */
  --muted: #4b4a73;          /* ~7:1 */
  --muted-2: #6b6a92;
  --violet: #6366f1;
  --violet-bright: #4f46e5;
  --pink: #ec4899;
  --gold: #f59e0b;
  --gold-deep: #d97706;
  --pos: #15803d;            /* dark green, 4.5:1 on white */
  --neg: #e11d48;
  --nav-bg: linear-gradient(180deg, rgba(244,245,255,0.4), rgba(244,245,255,0.95) 40%);
  --clay: 6px 7px 14px rgba(79,70,229,0.16), -5px -5px 12px rgba(255,255,255,0.9),
          inset 1px 1px 2px rgba(255,255,255,0.9);
  --clay-press: inset 4px 4px 9px rgba(79,70,229,0.18), inset -3px -3px 8px rgba(255,255,255,0.85);
  --focus-ring: 0 0 0 3px rgba(79,70,229,0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--text);
  background: var(--page-grad);
  -webkit-font-smoothing: antialiased;
  transition: background var(--t-med) ease, color var(--t-med) ease;
}
body { min-height: 100vh; display: flex; justify-content: center; align-items: stretch; }

h1, h2, h3, .display { font-family: "Baloo 2", "Nunito", sans-serif; }

/* ---------- Phone-like frame ---------- */
.app-frame {
  width: 100%; max-width: 460px; min-height: 100vh;
  position: relative; display: flex; flex-direction: column;
  background: var(--frame-grad);
  box-shadow: 0 0 60px rgba(0,0,0,0.45);
  overflow: hidden;
  transition: background var(--t-med) ease;
}
@media (min-width: 520px) {
  body { padding: 24px; align-items: center; }
  .app-frame {
    min-height: 0; height: calc(100vh - 48px); max-height: 900px;
    border-radius: 40px; border: var(--border-w) solid var(--card-line);
  }
}

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 20px 18px 12px; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--violet-bright), var(--pink));
  color: #fff; font-size: 16px; box-shadow: var(--clay);
}
.topbar h1 { font-size: 22px; font-weight: 700; letter-spacing: 0.2px; }
.topbar-actions { display: flex; gap: 10px; }
.icon-btn {
  border: var(--border-w) solid var(--card-line); background: var(--card);
  color: var(--text); min-width: var(--tap); min-height: var(--tap);
  display: grid; place-items: center;
  border-radius: var(--radius-sm); font-size: 19px; cursor: pointer;
  box-shadow: var(--clay);
  transition: transform var(--t-fast) var(--bounce), box-shadow var(--t-fast) ease;
}
.icon-btn:hover { transform: translateY(-2px); }
.icon-btn:active { transform: translateY(1px) scale(0.96); box-shadow: var(--clay-press); }

/* ---------- Views ---------- */
.views { flex: 1; overflow-y: auto; padding: 6px 18px 104px; -webkit-overflow-scrolling: touch; }
.views::-webkit-scrollbar { width: 0; }
.view { display: none; animation: fade var(--t-med) ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view-intro { color: var(--muted); font-size: 15px; margin: 4px 4px 16px; line-height: 1.6; }

/* ---------- Podium ---------- */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 8px; padding: 18px 6px 6px; min-height: 184px; }
.podium-slot { display: flex; flex-direction: column; align-items: center; text-align: center; }
.podium-slot .wreath { font-size: 26px; line-height: 1; }
.podium-slot .medal {
  margin-top: -4px; font-family: "Baloo 2", sans-serif; font-weight: 700; font-size: 13px; color: #3a2400;
  background: linear-gradient(145deg, #ffe9a8, var(--gold-deep)); border-radius: 999px; padding: 2px 10px;
  box-shadow: var(--clay);
}
.podium-avatar {
  width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; font-size: 30px;
  margin: 10px 0 6px; border: var(--border-w) solid rgba(255,255,255,0.5); box-shadow: var(--clay);
}
.podium-slot.first .podium-avatar { width: 76px; height: 76px; font-size: 40px; border-color: var(--gold); box-shadow: var(--clay), 0 0 22px rgba(252,211,77,0.55); }
.podium-slot .p-name { font-size: 13px; font-weight: 800; max-width: 96px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.podium-slot .p-score { font-size: 12.5px; color: var(--pos); font-weight: 800; margin-top: 2px; }
.podium-slot .p-score .arrow { font-size: 9px; }
.podium-slot.first { transform: translateY(-14px); }

/* ---------- Ranking divider ---------- */
.ranking-head { display: flex; align-items: center; gap: 12px; margin: 22px 4px 14px; }
.ranking-head .line { flex: 1; height: 2px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--card-line), transparent); }
.ranking-head .label { font-family: "Baloo 2", sans-serif; font-weight: 700; font-size: 14px; color: var(--gold-deep); letter-spacing: 0.5px; }

/* ---------- Rank / manage / activity lists ---------- */
.rank-list, .manage-list, .activity-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.rank-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: var(--border-w) solid var(--card-line);
  border-radius: var(--radius-md); padding: 11px 14px; min-height: var(--tap);
  box-shadow: var(--clay);
  transition: transform var(--t-fast) var(--bounce), box-shadow var(--t-fast) ease;
}
.rank-row:hover { transform: translateY(-3px); }
.rank-avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 23px; border: var(--border-w) solid rgba(255,255,255,0.45); box-shadow: var(--clay); flex-shrink: 0; }
.rank-info { flex: 1; min-width: 0; }
.rank-info .name { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-info .score { font-size: 13.5px; color: var(--pos); font-weight: 800; }
.rank-info .score .arrow { font-size: 9px; }
.rank-badge {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center;
  font-family: "Baloo 2", sans-serif; font-weight: 700; font-size: 13px; color: var(--gold-deep);
  border: var(--border-w) solid rgba(245,158,11,0.55);
  background: radial-gradient(circle at 50% 30%, rgba(252,211,77,0.22), transparent 72%);
}
.rank-badge sup { font-size: 8px; }
.empty-hint { text-align: center; color: var(--muted); margin-top: 40px; font-size: 15px; line-height: 1.6; }

/* ---------- Buttons ---------- */
.btn-primary {
  width: 100%; margin-top: 18px; min-height: var(--tap); padding: 15px;
  border: none; border-radius: var(--radius-md);
  font-family: "Baloo 2", sans-serif; font-weight: 700; font-size: 17px; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, var(--violet-bright), var(--pink));
  box-shadow: var(--clay), 0 8px 18px rgba(168,85,247,0.35);
  transition: transform var(--t-fast) var(--bounce), box-shadow var(--t-fast) ease, opacity var(--t-fast);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); }
.btn-primary:active:not(:disabled) { transform: translateY(1px) scale(0.99); box-shadow: var(--clay-press); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-text { background: none; border: none; color: var(--muted); font-size: 15px; font-weight: 800; cursor: pointer; min-height: var(--tap); padding: 8px 14px; border-radius: var(--radius-sm); }
.btn-text.danger { color: var(--neg); }

/* ---------- Award view ---------- */
.field-label { display: block; font-family: "Baloo 2", sans-serif; font-weight: 600; font-size: 15px; color: var(--muted); margin: 16px 4px 10px; }
.chip-row { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 10px; }
.chip-row::-webkit-scrollbar { height: 0; }
.kid-chip {
  flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--card); border: var(--border-w) solid var(--card-line);
  border-radius: var(--radius-md); padding: 10px 8px 9px; width: 76px; cursor: pointer;
  box-shadow: var(--clay);
  transition: transform var(--t-fast) var(--bounce), box-shadow var(--t-fast) ease, border-color var(--t-fast);
}
.kid-chip .c-av { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; box-shadow: var(--clay); }
.kid-chip .c-name { font-size: 12px; font-weight: 800; max-width: 62px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kid-chip.selected { border-color: var(--violet-bright); transform: translateY(-3px); box-shadow: var(--clay), 0 0 0 3px rgba(168,85,247,0.35); }

.behavior-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.behavior-card {
  display: flex; align-items: center; gap: 10px; min-height: var(--tap);
  background: var(--card); border: var(--border-w) solid var(--card-line);
  border-radius: var(--radius-sm); padding: 12px; cursor: pointer; box-shadow: var(--clay);
  transition: transform var(--t-fast) var(--bounce), box-shadow var(--t-fast) ease, border-color var(--t-fast);
}
.behavior-card:hover { transform: translateY(-3px); }
.behavior-card.selected { border-color: var(--gold); box-shadow: var(--clay), 0 0 0 3px rgba(252,211,77,0.4); }
.behavior-card.negative.selected { border-color: var(--neg); box-shadow: var(--clay), 0 0 0 3px rgba(225,29,72,0.35); }
.behavior-card .b-ic { width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; display: grid; place-items: center; font-size: 20px; box-shadow: var(--clay); }
.behavior-card .b-text { min-width: 0; }
.behavior-card .b-name { font-size: 13.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.behavior-card .b-pts { font-size: 12.5px; font-weight: 800; color: var(--pos); }
.behavior-card .b-pts.neg { color: var(--neg); }

.section-sub { font-family: "Baloo 2", sans-serif; font-weight: 600; font-size: 17px; margin: 28px 4px 12px; color: var(--text); }
.activity-row {
  display: flex; align-items: center; gap: 10px; background: var(--card-2);
  border: var(--border-w) solid var(--card-line); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13.5px;
}
.activity-row .a-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-size: 16px; flex-shrink: 0; box-shadow: var(--clay); }
.activity-row .a-txt { flex: 1; min-width: 0; }
.activity-row .a-txt b { font-weight: 800; }
.activity-row .a-when { font-size: 11px; color: var(--muted-2); }
.activity-row .a-pts { font-weight: 800; color: var(--pos); font-size: 14px; }
.activity-row .a-pts.neg { color: var(--neg); }

/* ---------- Manage lists ---------- */
.manage-row { display: flex; align-items: center; gap: 12px; background: var(--card); border: var(--border-w) solid var(--card-line); border-radius: var(--radius-md); padding: 12px 14px; box-shadow: var(--clay); }
.manage-row .m-av { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; flex-shrink: 0; box-shadow: var(--clay); }
.manage-row .m-ic { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 21px; flex-shrink: 0; box-shadow: var(--clay); }
.manage-row .m-info { flex: 1; min-width: 0; }
.manage-row .m-name { font-weight: 800; font-size: 16px; }
.manage-row .m-sub { font-size: 13px; color: var(--muted); }
.manage-row .m-sub.pts { color: var(--pos); font-weight: 800; }
.manage-row .m-sub.pts.neg { color: var(--neg); }
.edit-pencil {
  border: var(--border-w) solid var(--card-line); background: var(--card-2); color: var(--muted);
  min-width: var(--tap); min-height: var(--tap); border-radius: var(--radius-sm); font-size: 17px; cursor: pointer; flex-shrink: 0;
  display: grid; place-items: center;
  transition: transform var(--t-fast) var(--bounce), color var(--t-fast);
}
.edit-pencil:hover { color: var(--text); transform: translateY(-2px); }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: var(--z-nav);
  display: flex; justify-content: space-around;
  padding: 10px 8px calc(12px + env(safe-area-inset-bottom));
  background: var(--nav-bg); backdrop-filter: blur(14px);
  border-top: var(--border-w) solid var(--card-line);
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer; color: var(--muted-2);
  font-family: "Baloo 2", sans-serif; font-size: 12px; font-weight: 600;
  min-width: var(--tap); min-height: var(--tap); padding: 5px 12px; border-radius: var(--radius-sm);
  transition: color var(--t-fast), background var(--t-fast);
}
.nav-btn span { font-size: 21px; filter: grayscale(0.4) opacity(0.75); transition: filter var(--t-fast), transform var(--t-fast) var(--bounce); }
.nav-btn.active { color: var(--text); background: var(--card-2); }
.nav-btn.active span { filter: none; transform: translateY(-2px) scale(1.08); }
.nav-brand { display: none; }  /* desktop-only sidebar header (see desktop mode) */

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: var(--z-overlay); display: grid; place-items: center;
  background: rgba(10, 6, 24, 0.6); backdrop-filter: blur(7px); padding: 20px; animation: fade var(--t-fast) ease;
}
.overlay[hidden] { display: none; }
.close-x {
  position: absolute; top: 12px; right: 12px; background: var(--card-2);
  border: var(--border-w) solid var(--card-line); color: var(--muted);
  min-width: var(--tap); min-height: var(--tap); border-radius: 50%; font-size: 16px; cursor: pointer;
  display: grid; place-items: center;
}
.close-x:hover { color: var(--text); }

/* Champion card */
.champion-card {
  position: relative; width: 100%; max-width: 344px; text-align: center; padding: 36px 26px 28px;
  border-radius: 30px; background: var(--frame-grad); border: var(--border-w) solid var(--card-line);
  box-shadow: var(--clay), 0 24px 60px rgba(0,0,0,0.4); animation: pop var(--t-med) var(--bounce);
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.congrats { font-weight: 800; font-size: 28px;
  background: linear-gradient(90deg, var(--gold), var(--gold-deep));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 6px; }
.champion-avatar { position: relative; margin: 16px auto 6px; width: 128px; height: 128px; }
.champion-avatar .crown { position: absolute; top: -24px; left: 50%; transform: translateX(-50%) rotate(-8deg); font-size: 44px; animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateX(-50%) rotate(-8deg) translateY(0);} 50% { transform: translateX(-50%) rotate(-8deg) translateY(-7px);} }
.avatar-big { width: 128px; height: 128px; border-radius: 50%; display: grid; place-items: center; font-size: 66px;
  border: 3.5px solid var(--gold); box-shadow: var(--clay), 0 0 36px rgba(252,211,77,0.5); }
.champion-badge { display: inline-flex; align-items: center; gap: 6px; margin: 12px auto 4px; }
.champion-badge .laurel { font-size: 24px; }
.champion-badge .rank-num { font-family: "Baloo 2", sans-serif; font-weight: 700; color: var(--gold-deep); font-size: 19px; }
.champion-name { font-family: "Baloo 2", sans-serif; font-size: 24px; font-weight: 700; margin-top: 8px; }
.champion-score { color: var(--pos); font-weight: 800; font-size: 17px; margin-top: 4px; }
.champion-score .arrow { font-size: 11px; }
.champion-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.btn-gradient {
  min-height: var(--tap); padding: 14px; border: none; border-radius: var(--radius-md); cursor: pointer;
  font-family: "Baloo 2", sans-serif; font-weight: 700; font-size: 17px; color: #fff;
  background: linear-gradient(135deg, var(--violet-bright), var(--pink));
  box-shadow: var(--clay), 0 8px 18px rgba(168,85,247,0.35);
  transition: transform var(--t-fast) var(--bounce); }
.btn-gradient:active { transform: translateY(1px) scale(0.98); box-shadow: var(--clay-press); }
.btn-gradient.ghost { background: var(--card); color: var(--text); border: var(--border-w) solid var(--card-line); box-shadow: var(--clay); }

/* Edit card */
.edit-card { position: relative; width: 100%; max-width: 364px; padding: 28px 24px 22px; border-radius: 28px;
  background: var(--frame-grad); border: var(--border-w) solid var(--card-line); box-shadow: var(--clay), 0 24px 60px rgba(0,0,0,0.4); }
.edit-card h2 { font-weight: 700; font-size: 22px; margin-bottom: 18px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 7px; font-weight: 800; }
.form-group input[type="text"], .form-group input[type="number"] {
  width: 100%; min-height: var(--tap); padding: 12px 14px; background: var(--card-2);
  border: var(--border-w) solid var(--card-line); border-radius: var(--radius-sm); color: var(--text); font-size: 16px; font-family: inherit; }
.form-group input:focus { outline: none; border-color: var(--violet-bright); box-shadow: var(--focus-ring); }
.picker { display: flex; flex-wrap: wrap; gap: 8px; }
.picker .opt { min-width: var(--tap); min-height: var(--tap); border-radius: var(--radius-sm); display: grid; place-items: center; font-size: 21px; cursor: pointer;
  border: var(--border-w) solid transparent; background: var(--card-2); transition: transform var(--t-fast) var(--bounce); }
.picker .opt.selected { border-color: var(--violet-bright); transform: scale(1.08); }
.color-picker .opt { border-radius: 50%; }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; min-height: var(--tap); padding: 11px; border-radius: var(--radius-sm); cursor: pointer;
  border: var(--border-w) solid var(--card-line); background: var(--card-2); color: var(--muted); font-weight: 800; font-size: 14px; font-family: inherit; }
.seg button.on { color: var(--text); border-color: var(--violet-bright); background: color-mix(in srgb, var(--violet-bright) 18%, transparent); }
.edit-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; }
.edit-actions .btn-primary { margin-top: 0; flex: 1; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 104px; transform: translateX(-50%) translateY(20px); z-index: var(--z-toast);
  background: linear-gradient(135deg, var(--violet-bright), var(--pink)); color: #fff; font-weight: 800; font-size: 15px;
  padding: 13px 24px; border-radius: 999px; box-shadow: var(--clay), 0 10px 30px rgba(0,0,0,0.4);
  opacity: 0; transition: all var(--t-med) var(--bounce); pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: block; }

/* ---------- Inline SVG icons (Lucide) ---------- */
.icon-btn svg, .close-x svg, .edit-pencil svg, .nav-btn svg, .theme-icon svg { display: block; }
.theme-icon { display: grid; place-items: center; }
.nav-btn span { display: grid; place-items: center; height: 24px; }

/* ---------- Accessibility: visible focus + reduced motion ---------- */
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
.rank-row:focus-visible, .kid-chip:focus-visible, .behavior-card:focus-visible { transform: translateY(-2px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
}

/* ========================================================================
   DESKTOP MODE — bi-modal layout (>= 900px)
   Below this width the phone frame above is used unchanged. Here the SAME
   nav element becomes a left sidebar (via grid areas — no JS / DOM change)
   and content spreads into the available width with multi-column lists.
   ======================================================================== */
@media (min-width: 900px) {
  body { padding: 24px; align-items: center; justify-content: center; }

  .app-frame {
    width: 100%; max-width: 1120px;
    min-height: 0; height: calc(100vh - 48px); max-height: 940px;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "nav  top"
      "nav  main";
    border-radius: 28px;
    border: var(--border-w) solid var(--card-line);
    overflow: hidden;
  }

  /* ---- Sidebar (reuses .bottom-nav) ---- */
  .bottom-nav {
    grid-area: nav;
    position: static; flex-direction: column; justify-content: flex-start;
    gap: 6px; padding: 22px 14px;
    border-top: none; border-right: var(--border-w) solid var(--card-line);
  }
  .nav-brand {
    display: flex; align-items: center; gap: 11px;
    padding: 6px 12px 20px; margin-bottom: 4px;
  }
  .nav-brand-name {
    font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 18px;
    letter-spacing: 0.2px; color: var(--text);
  }
  .nav-btn {
    flex-direction: row; justify-content: flex-start; gap: 14px;
    width: 100%; padding: 12px 16px; font-size: 15px;
    border-radius: var(--radius-md);
  }
  .nav-btn span { font-size: 22px; }
  .nav-btn:hover { color: var(--text); background: var(--card); }

  /* ---- Top bar (current view title) ---- */
  .topbar { grid-area: top; padding: 22px 32px 14px; }
  .topbar .brand-mark { display: none; }  /* logo lives in the sidebar now */
  .topbar h1 { font-size: 26px; }

  /* ---- Main scroll area ---- */
  .views { grid-area: main; padding: 12px 32px 36px; }
  .view.active { max-width: 920px; }

  /* Use the width: multi-column lists + denser behavior grid */
  .behavior-grid { grid-template-columns: repeat(3, 1fr); }
  .rank-list,
  .manage-list,
  .activity-list {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
  }
  .podium { max-width: 560px; margin-inline: auto; }
  .ranking-head { max-width: 920px; }
  .chip-row { flex-wrap: wrap; overflow-x: visible; }
  .btn-primary { width: 100%; max-width: 320px; }
}

/* ========================================================================
   v2 — Auth gate, account/profile, login history
   ======================================================================== */

/* ---- Auth gate ---- */
.auth-gate {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 24px;
  background: var(--page-grad); overflow-y: auto;
}
.auth-gate[hidden] { display: none; }
.auth-card {
  width: 100%; max-width: 380px; padding: 32px 26px 26px;
  background: var(--frame-grad); border: var(--border-w) solid var(--card-line);
  border-radius: 28px; box-shadow: var(--clay), 0 24px 60px rgba(0,0,0,0.4);
  text-align: center;
}
.auth-logo .brand-mark {
  width: 54px; height: 54px; font-size: 26px; margin: 0 auto 14px;
}
.auth-title { font-size: 26px; font-weight: 800; }
.auth-sub { color: var(--muted); font-size: 14.5px; margin: 6px 0 22px; line-height: 1.5; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
  width: 100%; min-height: var(--tap); padding: 13px 15px;
  background: var(--card-2); border: var(--border-w) solid var(--card-line);
  border-radius: var(--radius-md); color: var(--text); font-size: 15px;
  font-family: "Nunito", sans-serif;
}
.auth-form input:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.auth-form .btn-primary { margin-top: 4px; }
.auth-toggle-hint { font-size: 14px; color: var(--muted); margin: 16px 0 0; }
.auth-link {
  background: none; border: none; cursor: pointer; padding: 0;
  color: var(--violet-bright); font-weight: 800; font-size: inherit;
  font-family: inherit;
}
.auth-link:hover { text-decoration: underline; }
.auth-divider {
  display: flex; align-items: center; gap: 12px; margin: 20px 0 16px;
  color: var(--muted-2); font-size: 12.5px; font-weight: 700;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--card-line), transparent);
}
.auth-provider {
  width: 100%; min-height: var(--tap); margin-bottom: 10px; padding: 12px 16px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--card); border: var(--border-w) solid var(--card-line);
  border-radius: var(--radius-md); color: var(--text); cursor: pointer;
  font-family: "Baloo 2", sans-serif; font-weight: 600; font-size: 15px;
  box-shadow: var(--clay); transition: transform var(--t-fast) var(--bounce);
}
.auth-provider:hover { transform: translateY(-2px); }
.auth-provider:active { transform: translateY(1px) scale(0.99); box-shadow: var(--clay-press); }
.auth-msg { min-height: 20px; margin-top: 14px; font-size: 13.5px; font-weight: 700; }
.auth-msg.error { color: var(--neg); }
.auth-msg.success { color: var(--pos); }
.auth-msg.info { color: var(--muted); }

/* ---- Account button (topbar) ---- */
.account-btn { font-size: 20px; line-height: 1; }

/* ---- Account view ---- */
.account-card {
  background: var(--card); border: var(--border-w) solid var(--card-line);
  border-radius: var(--radius-lg); padding: 18px 16px; margin-bottom: 14px;
  box-shadow: var(--clay);
}
.account-card .form-group { margin-bottom: 14px; }
.account-card .form-group:last-of-type { margin-bottom: 16px; }
.account-card input:disabled { opacity: 0.6; cursor: not-allowed; }

.session-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.session-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-2); border: var(--border-w) solid var(--card-line);
  border-radius: var(--radius-md); padding: 10px 13px;
}
.session-row .s-ic {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center; color: var(--violet-bright);
  background: var(--card); border: var(--border-w) solid var(--card-line);
}
.session-row .s-when { font-weight: 800; font-size: 14px; }
.session-row .s-meta { font-size: 12.5px; color: var(--muted); text-transform: capitalize; }

.btn-logout {
  width: 100%; min-height: var(--tap); padding: 13px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: none; border: var(--border-w) solid var(--neg);
  border-radius: var(--radius-md); color: var(--neg); cursor: pointer;
  font-family: "Baloo 2", sans-serif; font-weight: 700; font-size: 15px;
  transition: background var(--t-fast), transform var(--t-fast) var(--bounce);
}
.btn-logout:hover { transform: translateY(-2px); }
.btn-logout svg { stroke: var(--neg); }

/* Account view on desktop: two-column cards */
@media (min-width: 900px) {
  #view-account #accountBody {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; align-items: start;
  }
  #view-account .btn-logout { grid-column: 1 / -1; max-width: 320px; }
}

/* ========================================================================
   v2 — Admin (manage all users)
   ======================================================================== */
.admin-tag {
  display: inline-block; font-family: "Baloo 2", sans-serif; font-weight: 800;
  font-size: 11px; letter-spacing: 0.3px; padding: 2px 8px; border-radius: 999px;
  color: #fff; background: linear-gradient(135deg, var(--violet-bright), var(--pink));
  vertical-align: middle;
}
.you-tag {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px;
  border-radius: 999px; color: var(--muted); background: var(--card-2);
  border: var(--border-w) solid var(--card-line); vertical-align: middle;
}
.field-note { font-size: 12px; color: var(--muted-2); margin-top: 6px; }

.admin-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.admin-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: var(--border-w) solid var(--card-line);
  border-radius: var(--radius-md); padding: 11px 14px; box-shadow: var(--clay);
}
.admin-row .au-av {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center; font-size: 22px;
  background: var(--card-2); border: var(--border-w) solid var(--card-line);
}
.admin-row .au-info { flex: 1; min-width: 0; }
.admin-row .au-name { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.admin-row .au-meta { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row .au-sub { font-size: 12.5px; color: var(--muted-2); margin-top: 2px; }
.admin-row .au-actions { display: flex; gap: 6px; flex-shrink: 0; }
.edit-pencil.danger { color: var(--neg); }
.edit-pencil.danger:hover { color: var(--neg); transform: translateY(-2px); }

@media (min-width: 900px) {
  .admin-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
}

/* ========================================================================
   v2 — Award CRUD (admin): tabs, award rows, inline actions
   ======================================================================== */
.admin-tabs { margin-bottom: 16px; max-width: 320px; }

/* inline edit/delete in the activity feed */
.activity-row .a-actions { display: flex; gap: 6px; flex-shrink: 0; margin-left: 8px; }
.edit-pencil.sm { min-width: 34px; min-height: 34px; font-size: 14px; border-radius: var(--radius-sm); }

/* admin award rows reuse .admin-row; points chip */
.aw-pts { font-weight: 800; color: var(--pos); font-size: 14px; }
.aw-pts.neg { color: var(--neg); }

/* select used in the Add-award modal */
.select-input {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  background: var(--card-2); border: var(--border-w) solid var(--card-line);
  border-radius: var(--radius-md); color: var(--text);
  font-family: "Nunito", sans-serif; font-size: 15px; cursor: pointer;
}
.select-input:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ========================================================================
   v2 — Blog (list, reader, WYSIWYG editor, comments, status badges)
   ======================================================================== */
.blog-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.blog-card {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  background: var(--card); border: var(--border-w) solid var(--card-line);
  border-radius: var(--radius-md); padding: 12px 14px; box-shadow: var(--clay);
  transition: transform var(--t-fast) var(--bounce);
}
.blog-card:hover { transform: translateY(-2px); }
.blog-card .bc-cover {
  width: 52px; height: 52px; flex-shrink: 0; border-radius: 14px;
  display: grid; place-items: center; font-size: 26px; box-shadow: var(--clay);
}
.blog-card .bc-body { flex: 1; min-width: 0; }
.blog-card .bc-title { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 16px; }
.blog-card .bc-excerpt { font-size: 13px; color: var(--muted); margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blog-card .bc-meta { font-size: 12px; color: var(--muted-2); }

@media (min-width: 900px) {
  .blog-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
}

/* Reader */
.post-card {
  position: relative; width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  padding: 30px 26px 26px; border-radius: 28px;
  background: var(--frame-grad); border: var(--border-w) solid var(--card-line);
  box-shadow: var(--clay), 0 24px 60px rgba(0,0,0,0.4);
}
.post-cover { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 34px; box-shadow: var(--clay); margin-bottom: 14px; }
.post-title { font-size: 28px; font-weight: 800; line-height: 1.2; }
.post-meta { font-size: 13px; color: var(--muted-2); margin: 6px 0 18px; }
.post-body { font-size: 15.5px; line-height: 1.7; color: var(--text); }
.post-body h2 { font-size: 21px; margin: 18px 0 8px; }
.post-body h3 { font-size: 18px; margin: 16px 0 6px; }
.post-body p { margin: 0 0 12px; }
.post-body ul, .post-body ol { margin: 0 0 12px 22px; }
.post-body a { color: var(--violet-bright); text-decoration: underline; }
.post-body blockquote { border-left: 3px solid var(--card-line); padding-left: 12px; color: var(--muted); margin: 0 0 12px; }
.post-body code { background: var(--card-2); padding: 1px 6px; border-radius: 6px; font-size: 13px; }

/* Comments */
.comment-list { list-style: none; display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.comment-row { background: var(--card-2); border: var(--border-w) solid var(--card-line); border-radius: var(--radius-md); padding: 10px 13px; }
.comment-row .cm-head { font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.comment-row .cm-when { color: var(--muted-2); font-size: 12px; }
.comment-row .cm-body { font-size: 14px; margin-top: 4px; line-height: 1.5; white-space: pre-wrap; }
.comment-box { display: flex; flex-direction: column; gap: 10px; }
.comment-box textarea {
  width: 100%; min-height: 80px; padding: 12px 14px; resize: vertical;
  background: var(--card-2); border: var(--border-w) solid var(--card-line);
  border-radius: var(--radius-md); color: var(--text); font-family: "Nunito", sans-serif; font-size: 14px;
}
.comment-box textarea:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* WYSIWYG editor */
.post-editor-card {
  position: relative; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  padding: 28px 24px 22px; border-radius: 28px;
  background: var(--frame-grad); border: var(--border-w) solid var(--card-line);
  box-shadow: var(--clay), 0 24px 60px rgba(0,0,0,0.4);
}
.wysiwyg-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.wysiwyg-toolbar button {
  min-width: 38px; min-height: 36px; padding: 4px 10px; cursor: pointer;
  background: var(--card-2); border: var(--border-w) solid var(--card-line);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px; font-weight: 700;
}
.wysiwyg-toolbar button:hover { background: var(--card); }
.wysiwyg-body {
  min-height: 180px; max-height: 320px; overflow-y: auto; padding: 12px 14px;
  background: var(--card-2); border: var(--border-w) solid var(--card-line);
  border-radius: var(--radius-md); color: var(--text); font-size: 15px; line-height: 1.6;
}
.wysiwyg-body:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.wysiwyg-body:empty::before { content: attr(data-placeholder); color: var(--muted-2); }
.wysiwyg-body h2 { font-size: 20px; margin: 10px 0 6px; }

/* Status badges + link buttons (admin blog console) */
.status-tag {
  display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: 0.3px;
  padding: 1px 8px; border-radius: 999px; text-transform: capitalize; vertical-align: middle;
}
.status-tag.pending   { background: rgba(245,158,11,0.18); color: var(--gold-deep); border: 1.5px solid rgba(245,158,11,0.4); }
.status-tag.published { background: rgba(74,222,128,0.16); color: var(--pos); border: 1.5px solid rgba(74,222,128,0.4); }
.status-tag.rejected  { background: rgba(251,113,133,0.16); color: var(--neg); border: 1.5px solid rgba(251,113,133,0.4); }
.link-btn {
  background: none; border: none; cursor: pointer; padding: 4px 6px;
  color: var(--violet-bright); font-weight: 800; font-size: 13px; font-family: "Baloo 2", sans-serif;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--neg); }
