/* Guildin shared look. Every page loads this. Pillars only set --accent. */
:root {
  --bg: #0B0B16;
  --bg2: #11112a;
  --card: rgba(255, 255, 255, .055);
  --card-solid: #171730;
  --line: rgba(255, 255, 255, .09);
  --text: #F5F5FC;
  --muted: #A3A3C2;
  --accent: #7C6CFF;
  --accent2: #C16BFF;
  --good: #22D39A;
  --warn: #FFB547;
  --bad: #FF5D73;
  --r: 22px;
  --nav-h: 68px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 85% -10%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 60%),
    radial-gradient(700px 500px at -10% 20%, color-mix(in srgb, var(--accent2) 18%, transparent), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100dvh;
}
body.theme-attendance { --accent: #7C6CFF; --accent2: #C16BFF; }
body.theme-study      { --accent: #14C99A; --accent2: #3BA9FF; }
body.theme-tests      { --accent: #FF7A59; --accent2: #FFB547; }
body.theme-games      { --accent: #3BA9FF; --accent2: #7C6CFF; }
body.theme-home       { --accent: #FF5FA2; --accent2: #7C6CFF; }

.app { max-width: 480px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
.app.no-nav { padding-bottom: 28px; }
.hidden { display: none !important; }

h1 { font-size: 26px; line-height: 1.15; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grad-text { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px;
  box-shadow: 0 18px 40px -22px rgba(0, 0, 0, .7);
}
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* buttons */
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700; color: #fff;
  border-radius: 16px; padding: 14px 18px; width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 14px 28px -12px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: transform .12s, opacity .2s, filter .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: var(--card); border: 1px solid var(--line); box-shadow: none; color: var(--text); }
.btn.small { padding: 9px 14px; font-size: 13px; width: auto; border-radius: 12px; }
.btn.danger { background: linear-gradient(135deg, #ff5d73, #ff8a5d); }

/* inputs */
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.input, select.input {
  width: 100%; font: inherit; color: var(--text); background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; outline: none; transition: border .2s, background .2s;
}
.input:focus { border-color: var(--accent); background: rgba(255, 255, 255, .09); }
.input::placeholder { color: #7a7a9c; }
input[type="date"].input, input[type="time"].input { color-scheme: dark; }

/* chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  appearance: none; font: inherit; font-weight: 700; font-size: 13.5px; cursor: pointer;
  color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 16px; transition: all .15s;
}
.chip.on { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #fff; }

/* avatar */
.avatar {
  --s: 44px; width: var(--s); height: var(--s); border-radius: 50%; flex: none;
  display: inline-grid; place-items: center; font-weight: 700; font-size: calc(var(--s) * .38);
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); background-size: cover; background-position: center;
  border: 2px solid rgba(255, 255, 255, .15);
}

/* bottom nav */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; justify-content: space-around; align-items: center;
  background: rgba(14, 14, 32, .97);
  border-top: 0; box-shadow: none;
}
.bottom-nav a {
  flex: 1; display: grid; justify-items: center; gap: 2px; text-decoration: none; color: var(--muted);
  font-size: 11px; font-weight: 600; padding: 8px 0; transition: color .2s, transform .2s;
}
.bottom-nav a .ic { font-size: 21px; filter: grayscale(1) opacity(.7); transition: all .2s; }
.bottom-nav a.on { color: var(--text); }
.bottom-nav a.on .ic { filter: none; transform: translateY(-2px) scale(1.12); }

/* toast */
#toasts { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 0; right: 0; z-index: 200; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
  background: #20203f; border: 1px solid var(--line); color: var(--text); padding: 11px 16px; border-radius: 14px;
  font-size: 13.5px; font-weight: 600; max-width: 90vw; box-shadow: 0 14px 30px rgba(0, 0, 0, .5);
  animation: pop .3s ease both;
}
.toast.error { border-color: var(--bad); }
.toast.success { border-color: var(--good); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all .3s; }
@keyframes pop { from { opacity: 0; transform: translateY(-10px) scale(.96); } }

/* loading skeleton */
.skeleton { background: linear-gradient(90deg, rgba(255,255,255,.05), rgba(255,255,255,.11), rgba(255,255,255,.05)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 14px; min-height: 60px; }
@keyframes sk { to { background-position: -200% 0; } }

.fade-in { animation: fadeIn .45s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* bottom sheet */
.modal { position: fixed; inset: 0; z-index: 150; background: rgba(5,5,14,.82); display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .25s both; }
.modal .sheet { width: 100%; max-width: 480px; max-height: 90dvh; overflow: auto; background: #14142c; border-top-left-radius: 28px; border-top-right-radius: 28px; border: 1px solid var(--line); padding: 20px 18px calc(24px + env(safe-area-inset-bottom)); }
.modal .handle { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: -6px auto 14px; }
/* segmented tabs */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 5px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.seg button { font: inherit; font-weight: 700; font-size: 13.5px; color: var(--muted); background: transparent; border: 0; padding: 11px 6px; border-radius: 12px; cursor: pointer; }
.seg button.on { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.empty { text-align: center; padding: 22px 14px; }
.empty .em { font-size: 34px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.link { background: none; border: 0; padding: 0; font: inherit; font-size: 12px; font-weight: 700; color: var(--accent); cursor: pointer; }
textarea.input { resize: vertical; min-height: 84px; }
.back { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; padding: 6px 0; }

/* date/time inputs: mobile Chrome draws these taller than their box and they overlapped the next row */
input[type="datetime-local"].input, input[type="date"].input, input[type="time"].input {
  display: block; width: 100%; box-sizing: border-box; min-height: 52px; height: auto;
  -webkit-appearance: none; appearance: none; color-scheme: dark; line-height: 1.3;
}
.field { align-content: start; }
.stack > label.btn { display: block; text-align: center; box-sizing: border-box; }

/* battery / heat: nothing animates forever while the app is in the background or if the phone asks for less motion */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
html.ph-hidden *, html.ph-hidden *::before, html.ph-hidden *::after { animation-play-state: paused !important; }

/* global back arrow (added by core.js on inner pages that have none) */
.ph-back { position: fixed; z-index: 60; top: max(10px, env(safe-area-inset-top)); left: 10px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(20, 20, 44, .9); color: var(--text); display: grid; place-items: center; cursor: pointer; padding: 0; }
.ph-back:active { transform: scale(.94); }
/* thick, centred back arrow (drawn, so it never sits low like the text arrow did) */
svg.arw { width: 24px; height: 24px; display: block; fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
button.arw-btn, .ph-back { display: inline-grid !important; place-items: center; padding: 0; line-height: 1; }
body.has-ph-back .app > header:first-child { padding-left: 50px; }
/* unread badges (filled by notify.js) */
[data-badge] { display: none; }
[data-badge].on { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--bad, #ff4d6d); color: #fff; font-size: 11px; font-weight: 800; line-height: 1; }
[data-badge].badge-dot.on { min-width: 10px; width: 10px; height: 10px; padding: 0; font-size: 0; }

/* sheet handle: bigger touch area so it can be pulled down */
.modal .handle { position: relative; touch-action: none; cursor: grab; }
.modal .handle::before { content: ''; position: absolute; left: -60px; right: -60px; top: -22px; bottom: -16px; }
.modal .sheet { will-change: transform; }

/* loading screen */
.ph-boot { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; background: radial-gradient(700px 480px at 50% 35%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 70%), var(--bg); transition: opacity .35s; }
.ph-boot.out { opacity: 0; pointer-events: none; }
.ph-boot .bt { display: grid; justify-items: center; gap: 14px; text-align: center; padding: 24px; }
.ph-boot .bootlogo { width: 150px; height: 150px; overflow: visible; }
.ph-boot p { color: var(--muted); font-size: 14px; font-weight: 600; letter-spacing: .3px; }

/* profile photo cropper */
.ph-crop { position: fixed; inset: 0; z-index: 9000; background: #000; display: flex; flex-direction: column; color: #fff; }
.pc-top { display: flex; align-items: center; justify-content: space-between; padding: max(12px, env(safe-area-inset-top)) 14px 10px; } .pc-top b { font-size: 16px; } .pc-top span { width: 60px; }
.pc-x { background: none; border: 0; color: #fff; font: inherit; font-size: 15px; font-weight: 700; padding: 8px; cursor: pointer; width: 60px; text-align: left; }
.pc-stage { position: relative; flex: 1; overflow: hidden; touch-action: none; background: #111; } .pc-stage img { position: absolute; max-width: none; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.pc-ring { position: absolute; border-radius: 50%; box-shadow: 0 0 0 100vmax rgba(0,0,0,.62); border: 2px solid rgba(255,255,255,.9); pointer-events: none; }
.pc-bar { display: flex; align-items: center; gap: 14px; padding: 14px 18px calc(16px + env(safe-area-inset-bottom)); } .pc-bar input { flex: 1; accent-color: var(--accent); } .pc-bar .btn { width: auto; padding: 12px 28px; }

/* Code mode: the "save this?" question that must be answered */
.ph-modal-lock { position: fixed; inset: 0; z-index: 10000; background: rgba(5,5,14,.88); display: grid; place-items: center; padding: 22px; }
.ph-modal-lock .box { width: min(420px, 100%); background: var(--card-solid, #171730); border: 1px solid var(--line); border-radius: 24px; padding: 22px; text-align: center; }
.ph-modal-lock h2 { font-size: 20px; margin-bottom: 8px; } .ph-modal-lock p { color: var(--text); line-height: 1.45; margin-bottom: 6px; } .ph-modal-lock p.sm { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
