/* ============================================================
   STUDY AI — shared base styles (all pages)
   ============================================================ */
:root {
  --ink: #1c2547; --ink2: #424d78; --mut: #75809f; --line: #e2e7fa;
  --bg: #f4f6ff; --card: #ffffff; --soft: #eef1ff;
  --blue: #3b82ff; --sky: #36c5f0; --purple: #7c5cff; --pink: #ff5fa2;
  --orange: #ff8a3d; --yellow: #ffcf33; --green: #1fbf83; --red: #ff5468;
  --g-main: linear-gradient(135deg, #7c5cff 0%, #3b82ff 55%, #36c5f0 100%);
  --g-sun: linear-gradient(135deg, #ff8a3d 0%, #ffcf33 100%);
  --g-grass: linear-gradient(135deg, #1fbf83 0%, #7be07a 100%);
  --g-pink: linear-gradient(135deg, #ff5fa2 0%, #ff8a3d 100%);
  --r: 18px; --r-sm: 12px; --shadow: 0 10px 30px rgba(60, 80, 160, .12); --shadow-lg: 0 24px 60px rgba(40, 50, 120, .22);
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --head: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --gutter: 20px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: auto; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 500 16px/1.6 var(--font); overflow-x: hidden; }
img, svg { max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--head); line-height: 1.15; margin: 0 0 .4em; font-weight: 800; letter-spacing: .2px; }
h1 { font-size: clamp(2rem, 6vw, 3.6rem); } h2 { font-size: clamp(1.6rem, 4.4vw, 2.6rem); } h3 { font-size: 1.3rem; } h4 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--blue); text-decoration: none; } a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); }
.row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; } .spacer { flex: 1; }
.center { text-align: center; } .mut { color: var(--mut); } .small { font-size: .88rem; }
.up { color: var(--green); } .down { color: var(--red); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer; font: 800 1rem/1 var(--head); letter-spacing: .3px; padding: 14px 24px; border-radius: 999px; color: var(--ink); background: #fff; box-shadow: 0 3px 0 rgba(30, 40, 100, .14), 0 8px 20px rgba(30, 40, 100, .10); transition: transform .12s, box-shadow .12s, filter .12s; text-decoration: none !important; white-space: nowrap; min-height: 48px; }
.btn:hover { transform: translateY(-2px); filter: brightness(1.03); } .btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(30, 40, 100, .14); }
.btn[disabled], .btn.disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--g-main); color: #fff; box-shadow: 0 4px 0 #4a3fc4, 0 12px 24px rgba(92, 80, 220, .35); }
.btn-sun { background: var(--g-sun); color: #4a2a00; box-shadow: 0 4px 0 #d9822a, 0 12px 24px rgba(255, 160, 40, .35); }
.btn-green { background: var(--g-grass); color: #053a22; box-shadow: 0 4px 0 #17a06d, 0 12px 24px rgba(31, 191, 131, .3); }
.btn-pink { background: var(--g-pink); color: #fff; box-shadow: 0 4px 0 #c93d78, 0 12px 24px rgba(255, 95, 162, .3); }
.btn-ghost { background: transparent; box-shadow: none; border: 2px solid var(--line); } .btn-ghost:hover { border-color: var(--blue); }
.btn-red { background: #fff0f2; color: #c4283b; box-shadow: none; border: 2px solid #ffd0d6; }
.btn-sm { padding: 9px 16px; font-size: .88rem; min-height: 38px; box-shadow: 0 2px 0 rgba(30, 40, 100, .14); }
.btn-lg { padding: 18px 34px; font-size: 1.15rem; min-height: 58px; }
.btn-block { width: 100%; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; background: #fff; color: var(--ink); box-shadow: var(--shadow); display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; flex: none; }
.icon-btn:hover { transform: scale(1.08); }

/* ---------- forms ---------- */
label { display: block; font-weight: 800; font-size: .92rem; margin: 0 0 6px; color: var(--ink2); }
.field { margin-bottom: 16px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; font: 600 1rem var(--font); color: var(--ink); background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 13px 15px; outline: none; transition: border-color .15s, box-shadow .15s; min-height: 48px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(59, 130, 255, .15); }
.pw { position: relative; } .pw button { position: absolute; right: 8px; top: 8px; border: 0; background: var(--soft); border-radius: 10px; padding: 7px 12px; font: 800 .8rem var(--font); cursor: pointer; color: var(--ink2); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; font-size: .92rem; } .check input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--purple); }
.msg { padding: 12px 14px; border-radius: 12px; font-weight: 700; font-size: .93rem; margin: 10px 0; }
.msg.err { background: #fff0f2; color: #c4283b; border: 1px solid #ffd0d6; } .msg.ok { background: #e9fbf3; color: #107a52; border: 1px solid #bff0db; } .msg.info { background: #eef4ff; color: #2b4fb3; border: 1px solid #cfdcff; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--mut); font-weight: 700; font-size: .85rem; margin: 18px 0; } .divider::before, .divider::after { content: ""; flex: 1; height: 2px; background: var(--line); }

/* ---------- cards / bits ---------- */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 22px; border: 1px solid var(--line); }
.card + .card { margin-top: 18px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font: 800 .8rem var(--font); background: var(--soft); color: var(--ink2); }
.pill.ok { background: #e3f9ef; color: #0f7a4f; } .pill.warn { background: #fff4d9; color: #8a5a00; } .pill.bad { background: #ffe5e9; color: #b3243a; } .pill.blue { background: #e5eeff; color: #2850b8; } .pill.purple { background: #efe9ff; color: #5b3fd0; }
.bar { height: 12px; border-radius: 999px; background: var(--soft); overflow: hidden; } .bar > i { display: block; height: 100%; border-radius: 999px; background: var(--g-main); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.bar.green > i { background: var(--g-grass); } .bar.sun > i { background: var(--g-sun); } .bar.pink > i { background: var(--g-pink); }
.empty { text-align: center; color: var(--mut); padding: 28px 12px; font-weight: 700; }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; } .tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; border: 0; cursor: pointer; padding: 11px 20px; border-radius: 999px; font: 800 .95rem var(--head); background: #fff; color: var(--ink2); box-shadow: 0 2px 0 rgba(30, 40, 100, .1); border: 2px solid transparent; }
.tab.on { background: var(--g-main); color: #fff; box-shadow: 0 3px 0 #4a3fc4; }
table.t { width: 100%; border-collapse: collapse; font-size: .93rem; } table.t th { text-align: left; color: var(--mut); font: 800 .78rem var(--font); text-transform: uppercase; letter-spacing: .6px; padding: 10px 8px; border-bottom: 2px solid var(--line); white-space: nowrap; } table.t td { padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- avatar ---------- */
.av { width: 56px; height: 56px; border-radius: 50%; overflow: hidden; flex: none; background: #fff; border: 3px solid #fff; box-shadow: 0 4px 14px rgba(40, 50, 120, .25); display: inline-flex; align-items: center; justify-content: center; }
.av img, .av svg { width: 100%; height: 100%; object-fit: cover; object-position: center 25%; display: block; }
.av.lg { width: 88px; height: 88px; } .av.sm { width: 38px; height: 38px; border-width: 2px; } .av.xl { width: 120px; height: 120px; border-width: 4px; }
.av-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 10px; }
.av-pick button { border: 3px solid transparent; border-radius: 50%; padding: 0; background: none; cursor: pointer; width: 62px; height: 62px; } .av-pick button.on { border-color: var(--purple); transform: scale(1.1); } .av-pick .av { width: 100%; height: 100%; border-width: 2px; box-shadow: none; }

/* ---------- modal / toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20, 24, 60, .55); backdrop-filter: blur(4px); z-index: 5000; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-back.open { display: flex; animation: fadeIn .2s; }
.modal { background: #fff; border-radius: 24px; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; padding: 26px; box-shadow: var(--shadow-lg); animation: popIn .28s cubic-bezier(.2, 1.2, .3, 1); position: relative; }
.modal.wide { max-width: 860px; } .modal h3 { padding-right: 40px; }
.modal .x { position: absolute; right: 14px; top: 14px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--soft); cursor: pointer; font-size: 1.1rem; font-weight: 800; color: var(--ink2); }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; z-index: 6000; display: flex; flex-direction: column; gap: 10px; align-items: center; width: calc(100% - 32px); pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 13px 20px; border-radius: 16px; font-weight: 800; box-shadow: var(--shadow-lg); animation: popIn .3s; max-width: 440px; text-align: center; } .toast.ok { background: #0f8a5c; } .toast.err { background: #c4283b; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes popIn { from { opacity: 0; transform: scale(.88) translateY(14px) } to { opacity: 1; transform: none } }
@keyframes floaty { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-12px) } }
@keyframes wiggle { 0%, 100% { transform: rotate(-4deg) } 50% { transform: rotate(4deg) } }
@keyframes shake { 0%, 100% { transform: translateX(0) } 20% { transform: translateX(-9px) } 40% { transform: translateX(9px) } 60% { transform: translateX(-6px) } 80% { transform: translateX(6px) } }
@keyframes bounceIn { 0% { transform: scale(.3); opacity: 0 } 60% { transform: scale(1.12); opacity: 1 } 100% { transform: scale(1) } }
@keyframes spin { to { transform: rotate(360deg) } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(124, 92, 255, .5) } 70% { box-shadow: 0 0 0 16px rgba(124, 92, 255, 0) } 100% { box-shadow: 0 0 0 0 rgba(124, 92, 255, 0) } }

/* ---------- notification bell ---------- */
.bell-wrap { position: relative; }
.bell { width: 46px; height: 46px; border-radius: 50%; border: 0; background: #fff; color: var(--ink); cursor: pointer; box-shadow: var(--shadow); display: inline-flex; align-items: center; justify-content: center; position: relative; }
.bell svg { width: 22px; height: 22px; } .bell .dot { position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: var(--red); color: #fff; font: 800 .72rem/22px var(--font); text-align: center; border: 2px solid #fff; }
.dropdown { position: absolute; right: 0; top: 54px; width: 360px; max-width: calc(100vw - 24px); background: #fff; border-radius: 20px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); display: none; z-index: 4500; overflow: hidden; }
.dropdown.open { display: block; animation: popIn .22s; }
.dropdown .dh { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 2px solid var(--line); } .dropdown .dh h4 { margin: 0; } .dropdown .dh button { border: 0; background: none; color: var(--blue); font: 800 .82rem var(--font); cursor: pointer; }
#bell-list { max-height: 60vh; overflow-y: auto; }
.nitem { padding: 13px 16px; border-bottom: 1px solid var(--line); } .nitem.unread { background: #f3f0ff; } .nitem-link { cursor: pointer; } .nitem b { display: block; font-size: .95rem; } .nitem p { margin: 2px 0 4px; font-size: .88rem; color: var(--ink2); } .nitem time { font-size: .75rem; color: var(--mut); }

/* ---------- language switch / sound button ---------- */
.lang { position: relative; } .lang-btn { height: 44px; padding: 0 14px; border-radius: 999px; border: 0; background: #fff; box-shadow: var(--shadow); cursor: pointer; font: 800 .9rem var(--head); color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.lang-menu { position: absolute; right: 0; top: 50px; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); display: none; min-width: 170px; overflow: hidden; z-index: 4500; border: 1px solid var(--line); } .lang-menu.open { display: block; }
.lang-menu button { display: flex; width: 100%; justify-content: space-between; border: 0; background: none; padding: 12px 16px; font: 700 .95rem var(--font); cursor: pointer; } .lang-menu button.on, .lang-menu button:hover { background: var(--soft); }
#sa-mute { position: fixed; left: 16px; bottom: 16px; z-index: 4200; width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer; background: var(--g-main); color: #fff; font-size: 1.6rem; box-shadow: 0 6px 0 #4a3fc4, 0 14px 30px rgba(60, 50, 180, .4); display: flex; align-items: center; justify-content: center; transition: transform .15s; }
#sa-mute:hover { transform: scale(1.08); } #sa-mute.off { background: linear-gradient(135deg, #8d93b8, #b5bad6); box-shadow: 0 6px 0 #6e7399, 0 14px 30px rgba(60, 60, 120, .3); }
#sa-mute .eq { position: absolute; inset: -6px; border-radius: 50%; border: 3px solid rgba(124, 92, 255, .45); animation: pulse 2.2s infinite; pointer-events: none; } #sa-mute.off .eq { display: none; }

/* ---------- sound consent gate ---------- */
#sa-gate { position: fixed; inset: 0; z-index: 9000; background: radial-gradient(circle at 50% 30%, #3b2a9a 0%, #17123f 70%); display: flex; align-items: center; justify-content: center; padding: 20px; color: #fff; }
#sa-gate .box { background: rgba(255, 255, 255, .1); backdrop-filter: blur(12px); border: 2px solid rgba(255, 255, 255, .25); border-radius: 32px; padding: 34px 28px; max-width: 480px; width: 100%; text-align: center; animation: popIn .5s cubic-bezier(.2, 1.2, .3, 1); }
#sa-gate .mascot { width: 150px; height: 150px; margin: 0 auto 8px; animation: floaty 3s infinite ease-in-out; } #sa-gate h2 { color: #fff; font-size: 1.9rem; } #sa-gate p { color: #d9d4ff; margin-bottom: 22px; } #sa-gate .btn + .btn { margin-top: 12px; }

/* ---------- page shells shared by auth pages ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: radial-gradient(circle at 15% 10%, #dfe6ff 0, transparent 45%), radial-gradient(circle at 90% 90%, #ffe9d6 0, transparent 45%), var(--bg); }
.auth-card { width: 100%; max-width: 460px; background: #fff; border-radius: 28px; box-shadow: var(--shadow-lg); padding: 32px 28px; position: relative; border: 1px solid var(--line); }
.auth-card .logo { display: flex; align-items: center; gap: 10px; justify-content: center; font: 800 1.5rem var(--head); color: var(--ink); margin-bottom: 6px; } .auth-card .logo svg { width: 46px; height: 46px; }
.auth-card h1 { font-size: 1.7rem; text-align: center; margin-bottom: .3em; } .auth-card .sub { text-align: center; color: var(--mut); margin-bottom: 22px; font-weight: 700; }
.auth-top { position: absolute; top: 14px; right: 14px; }
.tagline { text-align: center; font-weight: 800; color: var(--purple); font-size: .92rem; margin-top: 18px; }

/* ---------- device helpers ---------- */
@media (max-width: 640px) { :root { --gutter: 16px; } .hide-m { display: none !important; } .modal { padding: 22px 18px; border-radius: 22px; } .dropdown { position: fixed; left: 10px; right: 10px; top: 70px; width: auto; max-width: none; } }
@media (min-width: 641px) and (max-width: 1023px) { .hide-t { display: none !important; } }
@media (min-width: 1024px) { .hide-d { display: none !important; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; } }
@media print { #sa-mute, #sa-gate, .no-print, #toasts, .sa-chat-btn, #sa-chat-btn, #sa-chat, .bell-wrap, nav, header.top { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }
