/* ==========================================================================
   Medhabi — mobile-first student app
   ========================================================================== */

:root {
	--bg: #FFF8EC;
	--bg-2: #E8F6FF;
	--card: #FFFFFF;
	--ink: #2B2D42;
	--ink-2: #6B6F80;
	--line: #EFE6D8;
	--primary: #FF8A3D;
	--primary-dark: #E56F1F;
	--yellow: #FFB703;
	--green: #22B573;
	--green-dark: #17935B;
	--red: #FF5A5F;
	--blue: #3D8BFF;
	--purple: #9B5DE5;
	--pink: #F15BB5;
	--radius: 20px;
	--radius-sm: 14px;
	--shadow: 0 4px 0 rgba(43, 45, 66, .08), 0 8px 24px rgba(43, 45, 66, .06);
	--shadow-press: 0 1px 0 rgba(43, 45, 66, .1);
	--font: "Baloo Da 2", "Noto Sans Bengali", system-ui, -apple-system, "Segoe UI", sans-serif;
	--font-body: "Noto Sans Bengali", "Baloo Da 2", system-ui, sans-serif;
	--nav-h: 68px;
	--safe-b: env(safe-area-inset-bottom, 0px);
	--app-w: 560px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	font-family: var(--font-body);
	font-size: 17px;
	line-height: 1.55;
	color: var(--ink);
	background: var(--bg);
	-webkit-tap-highlight-color: transparent;
}
body.medhabi-app {
	min-height: 100vh;
	min-height: 100dvh;
	background:
		radial-gradient(circle at 10% 0%, #FFE8C2 0, transparent 40%),
		radial-gradient(circle at 100% 30%, var(--bg-2) 0, transparent 45%),
		var(--bg);
	overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
button:disabled { cursor: default; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { font-family: var(--font); line-height: 1.25; margin: 0; }
p { margin: 0 0 .6em; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.app { max-width: var(--app-w); margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative; }

/* ---------- splash / loading / empty ---------- */
.splash { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.splash__mascot { font-size: 84px; animation: bounce 1.2s ease-in-out infinite; }
.splash__title { font-family: var(--font); font-weight: 800; font-size: 28px; }
.splash__dots { display: flex; gap: 6px; justify-content: center; }
.splash__dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); animation: dot 1s infinite ease-in-out; }
.splash__dots span:nth-child(2) { animation-delay: .15s; background: var(--yellow); }
.splash__dots span:nth-child(3) { animation-delay: .3s; background: var(--green); }
.noscript { text-align: center; padding: 40px 16px; }
.loading, .empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 40px 16px; color: var(--ink-2); }
.empty p { max-width: 320px; font-size: 18px; }

/* ---------- buttons ---------- */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-height: 48px; padding: 10px 20px; border-radius: 999px;
	font-family: var(--font); font-weight: 700; font-size: 17px; line-height: 1.2;
	background: #fff; color: var(--ink); box-shadow: var(--shadow);
	transition: transform .08s ease, box-shadow .08s ease, background .2s;
	text-align: center;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: var(--shadow-press); }
.btn:disabled { opacity: .55; }
.btn--primary { background: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-dark), 0 8px 18px rgba(255, 138, 61, .3); }
.btn--success { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-dark), 0 8px 18px rgba(34, 181, 115, .25); }
.btn--ghost { background: #fff; border: 2px solid var(--line); box-shadow: none; }
.btn--danger-ghost { background: #fff; color: var(--red); border: 2px solid #FFD6D7; box-shadow: none; }
.btn--big { min-height: 58px; font-size: 20px; padding: 12px 28px; }
.btn--block { display: flex; width: 100%; }
.btn--small { min-height: 38px; padding: 6px 14px; font-size: 15px; }
.btn--flag { width: 52px; padding: 0; background: #fff; border: 2px solid var(--line); box-shadow: none; filter: grayscale(1); opacity: .6; }
.btn--flag.is-on { filter: none; opacity: 1; border-color: var(--yellow); background: #FFF6DA; }
.icon-btn { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: #fff; box-shadow: var(--shadow); }
.icon-btn:active { transform: translateY(2px); box-shadow: var(--shadow-press); }
.link-btn { color: var(--blue); font-weight: 600; font-size: 15px; }
.card-btn { display: block; width: 100%; text-align: left; transition: transform .1s ease, box-shadow .1s ease; }
.card-btn:active:not(:disabled) { transform: translateY(3px) scale(.99); box-shadow: var(--shadow-press); }

/* ---------- cards & common ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card__title { font-size: 19px; margin-bottom: 12px; }
.lead { font-size: 17px; color: var(--ink-2); margin: 4px 2px 14px; }
.hint { color: var(--ink-2); font-size: 15px; margin: 10px 0 0; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 12px; border-radius: 999px; background: #F3EEE6; font-size: 14px; font-weight: 600; }
.tag--good { background: #DDF7EA; color: var(--green-dark); }
.tag--bad { background: #FFE3E3; color: #D63B40; }
.acc { font-weight: 700; color: var(--ink-2); }
.acc.is-good { color: var(--green-dark); }
.acc.is-mid { color: #C98900; }
.acc.is-low { color: #E0474C; }
.bar { display: block; height: 10px; background: #F1EADF; border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--yellow), var(--primary)); transition: width .6s ease; }
.bar.is-good > span { background: linear-gradient(90deg, #5BD69A, var(--green)); }
.bar.is-mid > span { background: linear-gradient(90deg, #FFD166, var(--yellow)); }
.bar.is-low > span { background: linear-gradient(90deg, #FF9A8B, var(--red)); }
.bar--thin { height: 6px; }

.ring {
	--p: 0; --c: var(--primary);
	width: 64px; height: 64px; border-radius: 50%; flex: 0 0 auto;
	display: grid; place-items: center;
	background: conic-gradient(var(--c) calc(var(--p) * 1%), #F1EADF 0);
}
.ring > span { width: 78%; height: 78%; border-radius: 50%; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; line-height: 1.1; }

/* ---------- layout: screen, topbar, bottom nav ---------- */
.screen { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px); }
.screen--nonav { padding-bottom: calc(24px + var(--safe-b)); }
.topbar {
	position: sticky; top: 0; z-index: 20;
	display: flex; align-items: center; gap: 8px;
	padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
	background: rgba(255, 248, 236, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.topbar__me { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); font-size: 26px; display: grid; place-items: center; }
.topbar__title { flex: 1; min-width: 0; font-family: var(--font); font-weight: 800; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-flex; align-items: center; gap: 3px; padding: 5px 10px; border-radius: 999px; background: #fff; box-shadow: var(--shadow); font-size: 15px; white-space: nowrap; }
.chip b { font-family: var(--font); }
.chip--fire.is-off { filter: grayscale(1); opacity: .6; }
.chip.bump { animation: bump .4s ease; }
.main { padding: 6px 16px 16px; }

.bottomnav {
	position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 30;
	width: 100%; max-width: var(--app-w);
	display: flex; justify-content: space-around;
	height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
	background: #fff; border-radius: 22px 22px 0 0;
	box-shadow: 0 -4px 24px rgba(43, 45, 66, .1);
}
.bottomnav__item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.bottomnav__icon { font-size: 24px; line-height: 1.1; transition: transform .2s; }
.bottomnav__item.is-active { color: var(--primary); }
.bottomnav__item.is-active .bottomnav__icon { transform: translateY(-3px) scale(1.15); }

/* ---------- welcome / forms ---------- */
.welcome { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 32px 16px calc(24px + var(--safe-b)); }
.welcome__art { position: relative; margin-top: 8px; }
.welcome__logo { width: 64px; height: 64px; border-radius: 16px; position: absolute; left: -40px; top: 0; }
.welcome__title { font-size: 34px; font-weight: 800; margin-top: 8px; }
.welcome__tag { color: var(--ink-2); font-size: 18px; }
.welcome__who { font-size: 22px; margin: 18px 0 12px; }
.welcome__actions { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 360px; margin-top: auto; padding-top: 24px; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 12px; width: 100%; }
.profile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 6px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.profile:active { transform: translateY(3px); box-shadow: var(--shadow-press); }
.profile__emoji { font-size: 46px; line-height: 1.1; }
.profile__name { font-family: var(--font); font-weight: 700; font-size: 18px; }
.profile__class { font-size: 13px; color: var(--ink-2); }

.form-screen { padding: 16px 16px calc(24px + var(--safe-b)); position: relative; }
.form-screen__back { position: absolute; left: 16px; top: 16px; }
.form-screen__head { display: flex; flex-direction: column; align-items: center; text-align: center; margin: 4px 0 14px; }
.form-screen__head h1 { font-size: 26px; }
.form-screen__head p { color: var(--ink-2); }
.form { padding: 20px 16px; }
.field { display: block; margin-bottom: 18px; }
.field__label { display: block; font-family: var(--font); font-weight: 700; font-size: 18px; margin-bottom: 8px; }
.input { width: 100%; min-height: 54px; padding: 10px 16px; border: 2px solid var(--line); border-radius: var(--radius-sm); background: #FFFCF7; font-size: 19px; }
.input:focus { outline: none; border-color: var(--primary); background: #fff; }
.input--code { text-transform: lowercase; letter-spacing: .08em; font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { min-height: 46px; min-width: 52px; padding: 8px 16px; border-radius: 999px; background: #FFFCF7; border: 2px solid var(--line); font-weight: 700; font-family: var(--font); font-size: 17px; transition: all .15s; }
.chip-btn.is-on { background: var(--primary); border-color: var(--primary); color: #fff; transform: scale(1.04); box-shadow: 0 3px 0 var(--primary-dark); }
.avatar-pick .chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.avatar-pick .chip-btn { padding: 6px 0; min-height: 64px; border-radius: 18px; }
.avatar-emoji { font-size: 36px; line-height: 1; }
.avatar-pick .chip-btn.is-on { background: #FFF1E3; color: inherit; box-shadow: 0 0 0 3px var(--primary); }
.form__error { background: #FFE8E8; color: #C62F35; padding: 10px 14px; border-radius: 12px; font-weight: 600; }
.form__hint { text-align: center; color: var(--ink-2); font-size: 15px; margin: 14px 0 0; }

.code-screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 24px 16px calc(24px + var(--safe-b)); }
.code-screen h1 { font-size: 28px; }
.code-screen p { max-width: 340px; font-size: 17px; }
.code-card { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 18px 22px; margin: 10px 0 18px; border: 3px dashed var(--primary); border-radius: var(--radius); background: #FFF7EE; }
.code-card__emoji { font-size: 40px; }
.code-card__code { font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; font-size: 32px; font-weight: 800; letter-spacing: .06em; color: var(--primary-dark); }
.code-card--small { margin: 0; padding: 12px 16px; justify-content: space-between; }
.code-card--small .code-card__code { font-size: 24px; }

/* ---------- home ---------- */
.hello { display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, #FFF3DE, #fff 70%); }
.hello__text { flex: 1; min-width: 0; }
.hello__text small { color: var(--ink-2); font-size: 15px; }
.hello__text h1 { font-size: 26px; margin-bottom: 6px; }
.level { display: flex; gap: 10px; align-items: center; }
.level__icon { font-size: 32px; }
.level__info { flex: 1; min-width: 0; }
.level__info b { font-family: var(--font); font-size: 16px; }
.level__info small { color: var(--ink-2); font-size: 14px; }

.daily { display: flex; align-items: center; gap: 12px; background: linear-gradient(120deg, var(--yellow), var(--primary)); color: #fff; }
.daily b { display: block; font-family: var(--font); font-size: 20px; }
.daily small { opacity: .95; font-size: 15px; }
.daily > div { flex: 1; }
.daily__icon { font-size: 40px; animation: wiggle 2.4s ease-in-out infinite; }
.daily__go { background: #fff; color: var(--primary-dark); font-family: var(--font); font-weight: 800; padding: 6px 14px; border-radius: 999px; }
.daily--done { background: #E7F8EF; color: var(--green-dark); }
.daily--done .daily__icon { animation: none; }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.mode { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding: 14px; min-height: 120px; border-radius: var(--radius); box-shadow: var(--shadow); text-align: left; color: var(--ink); }
.mode__icon { font-size: 34px; line-height: 1.2; margin-bottom: 4px; }
.mode b { font-family: var(--font); font-size: 18px; }
.mode small { color: rgba(43, 45, 66, .7); font-size: 14px; line-height: 1.3; }
.mode__badge { position: absolute; top: 10px; right: 10px; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 99px; background: var(--red); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center; }
.c-orange { background: #FFE8D6; }
.c-blue { background: #DDEBFF; }
.c-yellow { background: #FFF2C6; }
.c-pink { background: #FFE0F1; }
.c-purple { background: #EDE1FF; }
.c-green { background: #DAF5E8; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: #FFFAF3; border: 2px solid var(--line); }
.list-item__icon { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; background: #F3EEE6; }
.list-item__body { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.list-item__body b { font-family: var(--font); }
.list-item__body small { color: var(--ink-2); font-size: 14px; }
.list-item__go { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 14px; }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 4px; }
.stat { text-align: center; padding: 12px 6px; margin-bottom: 10px; }
.stat span { font-size: 24px; display: block; }
.stat b { display: block; font-family: var(--font); font-size: 24px; line-height: 1.2; }
.stat small { color: var(--ink-2); font-size: 13px; }

/* ---------- practice ---------- */
.subject-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.subject {
	position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
	padding: 16px 14px; min-height: 170px; border-radius: var(--radius);
	background: #fff;
	border: 2px solid var(--line);
	background: linear-gradient(160deg, color-mix(in srgb, var(--sc) 22%, #fff), #fff 80%);
	box-shadow: var(--shadow); border: 2px solid color-mix(in srgb, var(--sc) 30%, #fff);
}
.subject__icon { font-size: 42px; line-height: 1.2; }
.subject__name { font-family: var(--font); font-size: 20px; }
.subject small { color: var(--ink-2); font-size: 13px; line-height: 1.3; }
.subject .ring { position: absolute; right: 12px; top: 12px; width: 48px; height: 48px; }
.subject .ring > span { font-size: 12px; }

.chapter-list { display: flex; flex-direction: column; gap: 10px; }
.chapter { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.chapter:disabled { opacity: .6; }
.chapter__no { width: 46px; height: 46px; flex: 0 0 46px; border-radius: 14px; display: grid; place-items: center; font-family: var(--font); font-weight: 800; font-size: 20px; color: #fff; background: var(--sc); }
.chapter__body { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.chapter__body b { font-family: var(--font); font-size: 17px; }
.chapter__body small { color: var(--ink-2); font-size: 14px; }
.chapter__body .bar > span { background: var(--sc); }
.chapter__play { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; display: grid; place-items: center; background: #F3EEE6; background: color-mix(in srgb, var(--sc) 15%, #fff); color: var(--sc); font-size: 15px; }

/* ---------- exams ---------- */
.exam__title { font-size: 20px; margin-bottom: 8px; }
.exam__meta { display: flex; flex-wrap: wrap; gap: 8px 14px; font-weight: 600; margin-bottom: 8px; }
.exam__subjects { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.rules ul { list-style: none; padding: 0; margin: 0 0 18px; }
.rules li { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 17px; }

/* ---------- quiz ---------- */
.quiz__bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(255, 248, 236, .94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.quiz__progress { flex: 1; height: 14px; background: #F1EADF; border-radius: 99px; overflow: hidden; }
.quiz__progress span { display: block; height: 100%; background: linear-gradient(90deg, #5BD69A, var(--green)); border-radius: 99px; transition: width .4s ease; }
.quiz__progress--exam { flex: none; height: 8px; margin-bottom: 12px; }
.quiz__main { padding-top: 4px; }
.quiz__meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.quiz__count { font-family: var(--font); font-weight: 800; font-size: 17px; color: var(--primary-dark); white-space: nowrap; }
.quiz__title { color: var(--ink-2); font-size: 14px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quiz__stage { display: flex; align-items: flex-end; gap: 8px; }
.quiz__mascot { flex: 0 0 auto; margin-bottom: 12px; }
.quiz__stage .qcard { flex: 1; }
.qcard { position: relative; padding: 20px 18px; min-height: 110px; display: flex; flex-direction: column; justify-content: center; }
.qcard__q { font-family: var(--font); font-weight: 700; font-size: 22px; line-height: 1.45; margin: 0; }
.qcard__q.is-long { font-size: 19px; }
.qcard__img { display: block; margin: 12px auto 0; border-radius: 12px; max-height: 220px; width: auto; }
.qtimer { position: relative; height: 26px; background: #F1EADF; border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.qtimer span { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, #7CC6FF, var(--blue)); border-radius: 99px; transition: width .1s linear; }
.qtimer b { position: relative; display: block; text-align: center; font-family: var(--font); font-size: 15px; line-height: 26px; }
.qtimer.is-hurry span { background: linear-gradient(90deg, #FF9A8B, var(--red)); }
.qtimer.is-hurry b { animation: bump .5s infinite; }

.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
	display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px;
	padding: 10px 14px; text-align: left;
	background: #fff; border: 3px solid var(--line); border-radius: 18px;
	box-shadow: 0 4px 0 var(--line);
	font-size: 19px; font-weight: 600;
	transition: transform .08s ease, box-shadow .08s ease, border-color .15s, background .15s;
}
.opt:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.opt__letter { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 12px; display: grid; place-items: center; font-family: var(--font); font-weight: 800; background: #F6F0E6; color: var(--ink-2); }
.opt__text { flex: 1; min-width: 0; line-height: 1.35; }
.opt.is-picked { border-color: var(--blue); background: #EEF5FF; box-shadow: 0 4px 0 #B9D4FF; }
.opt.is-picked .opt__letter { background: var(--blue); color: #fff; }
.opt.is-waiting { animation: pulse .7s ease-in-out infinite; }
.opt.is-correct { border-color: var(--green); background: #E6F9EF; box-shadow: 0 4px 0 #A9E6C7; animation: pop .35s ease; }
.opt.is-correct .opt__letter { background: var(--green); color: #fff; }
.opt.is-wrong { border-color: var(--red); background: #FFECEC; box-shadow: 0 4px 0 #FFC2C4; animation: shake .4s ease; }
.opt.is-wrong .opt__letter { background: var(--red); color: #fff; }
.opt.is-dim { opacity: .55; }
.opt:disabled { cursor: default; }

.feedback {
	position: fixed; left: 50%; bottom: 0; z-index: 40;
	width: 100%; max-width: var(--app-w);
	padding: 18px 16px calc(16px + var(--safe-b));
	border-radius: 26px 26px 0 0;
	transform: translate(-50%, 110%); transition: transform .3s cubic-bezier(.2, .9, .3, 1.2);
	box-shadow: 0 -8px 30px rgba(43, 45, 66, .15);
}
.feedback.is-in { transform: translate(-50%, 0); }
.feedback--good { background: #DDF7EA; }
.feedback--bad { background: #FFE8E8; }
.feedback__head { font-family: var(--font); font-weight: 800; font-size: 24px; margin-bottom: 4px; }
.feedback--good .feedback__head { color: var(--green-dark); }
.feedback--bad .feedback__head { color: #D63B40; }
.feedback__answer { font-size: 17px; margin-bottom: 6px; }
.feedback__exp { background: rgba(255, 255, 255, .7); border-radius: 12px; padding: 8px 12px; font-size: 16px; margin-bottom: 10px; }
.feedback .btn { margin-top: 8px; }
.combo { display: inline-block; background: #fff; color: var(--primary-dark); font-family: var(--font); font-weight: 800; padding: 2px 12px; border-radius: 99px; margin-bottom: 6px; animation: pop .4s ease; }

.quiz--exam .quiz__bar { justify-content: space-between; }
.exam-timer { font-family: var(--font); font-weight: 800; font-size: 20px; padding: 4px 14px; border-radius: 999px; background: #fff; box-shadow: var(--shadow); }
.exam-timer.is-hurry { background: var(--red); color: #fff; animation: bump .8s infinite; }
.quiz--exam .main { padding-bottom: calc(96px + var(--safe-b)); }
.exam-nav {
	position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 30;
	width: 100%; max-width: var(--app-w);
	display: flex; gap: 10px; padding: 12px 16px calc(12px + var(--safe-b));
	background: rgba(255, 248, 236, .96); box-shadow: 0 -4px 16px rgba(43, 45, 66, .08);
}
.exam-nav .btn:first-child, .exam-nav .btn:last-child { flex: 1; }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; max-height: 50vh; overflow-y: auto; padding: 4px; }
.palette__item { height: 48px; border-radius: 12px; background: #F3EEE6; font-family: var(--font); font-weight: 700; font-size: 17px; position: relative; }
.palette__item.is-done { background: var(--green); color: #fff; }
.palette__item.is-flag::after { content: "🚩"; position: absolute; top: -6px; right: -4px; font-size: 14px; }
.palette__item.is-current { box-shadow: 0 0 0 3px var(--blue); }
.palette__legend { display: flex; gap: 14px; justify-content: center; margin-top: 12px; font-size: 14px; color: var(--ink-2); }
.palette__legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 4px; background: #F3EEE6; margin-right: 4px; vertical-align: -1px; }
.palette__legend .is-done::before { background: var(--green); }
.palette__legend .is-flag::before { background: var(--yellow); }

/* ---------- result ---------- */
.result { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 20px; background: linear-gradient(180deg, #FFF3DE, #fff 60%); }
.result__head { font-size: 25px; margin-top: 4px; }
.result__title { color: var(--ink-2); margin: 2px 0 10px; }
.result__ring .ring { width: 140px; height: 140px; }
.result__ring .ring b { font-family: var(--font); font-size: 34px; }
.result__ring .ring small { font-size: 15px; color: var(--ink-2); font-weight: 600; }
.result__chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 14px 0 8px; }
.result__stars { font-family: var(--font); font-size: 22px; font-weight: 700; color: var(--primary-dark); }
.result__stars b { font-size: 30px; }
.result__actions { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 20px; }
.sbar { margin-bottom: 10px; }
.sbar__top { display: flex; justify-content: space-between; font-size: 16px; }
.review__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.review__head h2 { font-size: 21px; }
.seg { display: inline-flex; background: #F1EADF; border-radius: 999px; padding: 3px; }
.seg__btn { padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 14px; }
.seg__btn.is-on { background: #fff; box-shadow: var(--shadow); }
.review.only-wrong .rq.is-ok { display: none; }
.rq { border-left: 6px solid var(--green); }
.rq.is-bad { border-left-color: var(--red); }
.rq__q { font-family: var(--font); font-weight: 700; font-size: 18px; display: flex; gap: 10px; margin-bottom: 8px; }
.rq__n { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #F3EEE6; font-size: 15px; }
.rq__opts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rq__opts li { display: flex; gap: 8px; padding: 6px 10px; border-radius: 10px; background: #FAF6F0; font-size: 16px; }
.rq__opts li span { font-weight: 700; color: var(--ink-2); }
.rq__opts li.is-correct { background: #E3F8EC; color: var(--green-dark); font-weight: 700; }
.rq__opts li.is-wrong { background: #FFE6E6; color: #D63B40; text-decoration: line-through; }
.rq__note { color: var(--ink-2); font-size: 14px; margin: 6px 0 0; }
.rq__exp { background: #FFF8E6; border-radius: 10px; padding: 8px 10px; font-size: 15px; margin: 8px 0 0; }

/* ---------- progress ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart__grid { stroke: #F1EADF; stroke-width: 1; }
.chart__label { font-size: 10px; fill: var(--ink-2); }
.chart__area { fill: rgba(255, 138, 61, .15); }
.chart__line { fill: none; stroke: var(--primary); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart__dot { fill: #fff; stroke: var(--primary); stroke-width: 3; }
.chart__val { font-size: 12px; font-weight: 700; fill: var(--primary-dark); text-anchor: middle; }
.subj { border-bottom: 1px dashed var(--line); padding: 6px 0; }
.subj:last-child { border-bottom: 0; }
.subj summary { display: flex; align-items: center; gap: 12px; list-style: none; cursor: pointer; padding: 4px 0; }
.subj summary::-webkit-details-marker { display: none; }
.subj__icon { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; }
.subj__body { flex: 1; min-width: 0; }
.subj__body b { font-family: var(--font); }
.subj__body small { color: var(--ink-2); font-size: 14px; }
.subj__chapters { list-style: none; margin: 6px 0 4px 56px; padding: 0; }
.subj__chapters li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 15px; }
.banner { padding: 14px 16px; font-size: 16px; text-align: left; }
.recent { list-style: none; margin: 0; padding: 0; }
.recent li { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.recent li:last-child { border-bottom: 0; }
.recent__mode { font-size: 13px; color: var(--ink-2); grid-column: 1; }
.recent__title { font-weight: 600; grid-column: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent__score { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-family: var(--font); font-size: 18px; }
.recent small { grid-column: 1 / -1; color: var(--ink-2); font-size: 13px; }

/* ---------- badges, levels, leaderboard ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.badge { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 12px 6px; border-radius: 16px; background: #F6F2EC; opacity: .7; }
.badge.is-on { background: linear-gradient(160deg, #FFF1C9, #FFE2C6); opacity: 1; box-shadow: var(--shadow); }
.badge__icon { font-size: 34px; line-height: 1.2; }
.badge b { font-family: var(--font); font-size: 14px; line-height: 1.25; }
.badge small { font-size: 12px; color: var(--ink-2); line-height: 1.3; }
.levels { list-style: none; margin: 0; padding: 0; }
.levels li { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; opacity: .6; }
.levels li span { font-size: 26px; }
.levels li small { color: var(--ink-2); }
.levels li.is-done { opacity: 1; }
.levels li.is-current { opacity: 1; background: #FFF1DE; box-shadow: inset 0 0 0 2px var(--primary); }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 10px 0 18px; }
.podium__col { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.podium__emoji { font-size: 44px; line-height: 1.1; }
.podium__col b { font-family: var(--font); font-size: 17px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium__col small { color: var(--ink-2); }
.podium__block { width: 100%; margin-top: 6px; border-radius: 16px 16px 6px 6px; display: grid; place-items: center; font-size: 32px; box-shadow: var(--shadow); }
.podium__col--1 .podium__block { height: 110px; background: linear-gradient(180deg, #FFE27A, var(--yellow)); }
.podium__col--2 .podium__block { height: 80px; background: linear-gradient(180deg, #E9EEF5, #C9D3E0); }
.podium__col--3 .podium__block { height: 60px; background: linear-gradient(180deg, #FFD3B0, #F2A66E); }
.podium__col.is-me b { color: var(--primary-dark); }
.leader-list { list-style: none; padding: 6px 12px; }
.leader-list li { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px dashed var(--line); }
.leader-list li:last-child { border-bottom: 0; }
.leader-list li.is-me { background: #FFF1DE; border-radius: 12px; }
.leader-list__rank { width: 28px; text-align: center; font-family: var(--font); font-weight: 800; color: var(--ink-2); }
.leader-list__emoji { font-size: 28px; }
.leader-list li b { flex: 1; font-family: var(--font); }
.leader-list__stars { font-weight: 700; }

/* ---------- profile ---------- */
.me { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 22px; }
.me__avatar { position: relative; width: 108px; height: 108px; border-radius: 50%; background: #FFF1DE; font-size: 64px; display: grid; place-items: center; box-shadow: var(--shadow); margin-bottom: 8px; }
.me__avatar span { position: absolute; right: 0; bottom: 4px; width: 34px; height: 34px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); font-size: 16px; display: grid; place-items: center; }
.me h1 { font-size: 24px; }
.me p { color: var(--ink-2); }
.me__actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.settings { padding: 6px 16px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; font-weight: 600; cursor: pointer; }
.toggle + .toggle { border-top: 1px dashed var(--line); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { position: relative; width: 54px; height: 32px; flex: 0 0 54px; border-radius: 99px; background: #E3DCD1; transition: background .2s; }
.toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s; }
.toggle input:checked + i { background: var(--green); }
.toggle input:checked + i::after { transform: translateX(22px); }
.toggle input:focus-visible + i { outline: 3px solid var(--blue); outline-offset: 2px; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.avatar-grid__item { height: 72px; border-radius: 18px; background: #F6F0E6; font-size: 40px; }
.avatar-grid__item.is-on { box-shadow: 0 0 0 3px var(--primary); background: #FFF1DE; }

/* ---------- sheets, toasts, celebrations ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(43, 45, 66, .45); opacity: 0; transition: opacity .25s; }
.sheet {
	position: relative; width: 100%; max-width: var(--app-w); max-height: 88vh; overflow-y: auto;
	background: #fff; border-radius: 26px 26px 0 0;
	padding: 10px 18px calc(20px + var(--safe-b));
	transform: translateY(100%); transition: transform .3s cubic-bezier(.2, .9, .3, 1.1);
}
.sheet-wrap.is-in .sheet-backdrop { opacity: 1; }
.sheet-wrap.is-in .sheet { transform: none; }
.sheet__handle { width: 44px; height: 5px; border-radius: 99px; background: #E3DCD1; margin: 0 auto 12px; }
.sheet__title { font-size: 21px; margin-bottom: 14px; text-align: center; }
.sheet-wrap--center { align-items: center; padding: 16px; }
.sheet-wrap--center .sheet { border-radius: 26px; padding: 22px 18px; transform: scale(.85); opacity: 0; transition: transform .25s cubic-bezier(.2, .9, .3, 1.3), opacity .2s; }
.sheet-wrap--center.is-in .sheet { transform: none; opacity: 1; }
.sheet .loading { padding: 16px; }
.confirm { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.confirm h3 { font-size: 22px; }
.confirm p { color: var(--ink-2); font-size: 17px; }
.confirm__btns { display: flex; gap: 10px; width: 100%; margin-top: 8px; }
.confirm__btns .btn { flex: 1; }
.celebrate { text-align: center; }
.celebrate__big { font-size: 84px; line-height: 1.1; animation: pop .6s ease, wiggle 2s 0.6s ease-in-out infinite; }
.celebrate h2 { font-size: 28px; color: var(--primary-dark); }
.celebrate p { font-size: 18px; margin: 6px 0 16px; }

.toast {
	position: fixed; left: 50%; top: 14px; z-index: 200;
	max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 16px;
	background: var(--ink); color: #fff; font-weight: 600; text-align: center;
	transform: translate(-50%, -150%); transition: transform .3s cubic-bezier(.2, .9, .3, 1.2);
	box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.toast.is-in { transform: translate(-50%, 0); }
.toast--error { background: #D63B40; }

.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 150; }
.fly-star { position: fixed; z-index: 160; transform: translate(0, 0); margin: -14px 0 0 -24px; font-family: var(--font); font-weight: 800; font-size: 22px; color: var(--primary-dark); pointer-events: none; transition: transform .7s cubic-bezier(.5, -0.3, .7, 1), opacity .7s ease-in; }

/* ---------- mascot ---------- */
.mascot { width: var(--m-size, 96px); height: var(--m-size, 96px); flex: 0 0 auto; }
.mascot svg { width: 100%; height: 100%; display: block; overflow: visible; }
.mascot .m-body { transform-origin: 60px 100px; }
.mascot .m-mouth-sad { display: none; }
.mascot--idle .m-body { animation: breathe 3s ease-in-out infinite; }
.mascot--wave .m-body { animation: sway 2.2s ease-in-out infinite; }
.mascot--happy .m-body { animation: hop .6s ease; }
.mascot--cheer .m-body { animation: cheer 1s ease-in-out infinite; }
.mascot--think .m-body { animation: tilt 2.4s ease-in-out infinite; }
.mascot--think .m-pupil { transform: translate(2px, -2px); }
.mascot--sad .m-body { animation: droop .6s ease forwards; }
.mascot--sad .m-mouth-happy { display: none; }
.mascot--sad .m-mouth-sad { display: inline; }
.mascot .m-eyes { animation: blink 4s infinite; transform-origin: 60px 58px; }

/* ---------- keyframes ---------- */
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes dot { 0%, 80%, 100% { transform: scale(.6); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }
@keyframes bump { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
@keyframes pop { 0% { transform: scale(.9); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .6; } }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-12deg); } 90% { transform: rotate(12deg); } 95% { transform: rotate(-6deg); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03, .98); } }
@keyframes sway { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
@keyframes hop { 0% { transform: translateY(0); } 40% { transform: translateY(-16px) scale(1.05); } 70% { transform: translateY(0) scale(1.05, .95); } 100% { transform: none; } }
@keyframes cheer { 0%, 100% { transform: translateY(0) rotate(0); } 25% { transform: translateY(-14px) rotate(-6deg); } 50% { transform: translateY(0) rotate(0); } 75% { transform: translateY(-14px) rotate(6deg); } }
@keyframes tilt { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-8deg); } }
@keyframes droop { 0% { transform: none; } 30% { transform: translateX(-4px) rotate(-4deg); } 60% { transform: translateX(4px) rotate(4deg); } 100% { transform: translateY(3px) rotate(-3deg); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }

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

/* ---------- small phones ---------- */
@media (max-width: 360px) {
	body { font-size: 16px; }
	.main { padding-left: 12px; padding-right: 12px; }
	.topbar { padding-left: 12px; padding-right: 12px; gap: 6px; }
	.chip { padding: 4px 8px; font-size: 14px; }
	.qcard__q { font-size: 20px; }
	.opt { font-size: 17px; min-height: 56px; }
	.mode { min-height: 108px; padding: 12px; }
	.quiz__mascot { display: none; }
}

/* ---------- larger screens: show the app as a centered phone-like column ---------- */
@media (min-width: 600px) {
	body.medhabi-app { background-attachment: fixed; }
	.app { box-shadow: 0 0 0 1px rgba(43, 45, 66, .04), 0 20px 60px rgba(43, 45, 66, .08); background: rgba(255, 248, 236, .65); }
	.subject-grid, .mode-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- regular WordPress pages ---------- */
.medhabi-page { background: var(--bg); }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; max-width: 760px; margin: 0 auto; padding: 14px 16px; }
.page-header__brand { font-family: var(--font); font-weight: 800; font-size: 22px; color: var(--ink); text-decoration: none; }
.page-header .btn { text-decoration: none; }
.page-main { max-width: 760px; margin: 0 auto; padding: 0 16px 32px; }
.page-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.page-card__title { font-size: 28px; margin-bottom: 12px; }
.page-card a { color: var(--primary-dark); }
.page-footer { text-align: center; color: var(--ink-2); padding: 20px 16px 32px; }

/* ---------- leaderboard extras ---------- */
.seg--wide { display: flex; width: 100%; margin-bottom: 14px; }
.seg--wide .seg__btn { flex: 1; padding: 10px; font-size: 16px; }
.my-rank { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: linear-gradient(120deg, #FFF1DE, #fff); border: 2px solid var(--yellow); }
.my-rank__emoji { font-size: 44px; line-height: 1; }
.my-rank__body { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.my-rank__body b { font-family: var(--font); font-size: 30px; color: var(--primary-dark); }
.my-rank__body small { color: var(--ink-2); font-size: 14px; }
.my-rank__next { width: 100%; background: #fff; border-radius: 12px; padding: 6px 12px; font-weight: 600; font-size: 15px; text-align: center; }
.podium__crown { font-size: 26px; line-height: 1; animation: bounce 1.6s ease-in-out infinite; }
.podium__block { flex-direction: column; gap: 0; }
.podium__block span { font-size: 30px; line-height: 1.1; }
.podium__block em { font-style: normal; font-family: var(--font); font-weight: 800; font-size: 16px; color: rgba(43, 45, 66, .75); }
.list-head { font-size: 19px; margin: 6px 2px 10px; }
.leader-list__level { font-size: 18px; }
.leader-list__gap { justify-content: center; color: var(--ink-2); padding: 2px !important; border-bottom: 0 !important; }
.leader-list li.is-me { box-shadow: inset 0 0 0 2px var(--primary); padding-left: 8px; padding-right: 8px; }
.hint.center { text-align: center; margin-bottom: 8px; }
