@font-face { font-family: Estedad; font-weight: 400; font-display: swap; src: url(../assets/fonts/estedad_regular.ttf); }
@font-face { font-family: Estedad; font-weight: 500; font-display: swap; src: url(../assets/fonts/estedad_medium.ttf); }
@font-face { font-family: Estedad; font-weight: 600; font-display: swap; src: url(../assets/fonts/estedad_semibold.ttf); }
@font-face { font-family: Estedad; font-weight: 700 800; font-display: swap; src: url(../assets/fonts/estedad_bold.ttf); }

:root {
  --navy: #0F2747; --navy-light: #2B4A73; --muted: #4A5D78; --line: #D3DCE7; --ice: #E8EDF3;
  --soft: #F4F7FA; --dash: #8FA3BC; --hint: #7A8BA2; --white: #FFFFFF; --error: #B3261E;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-h: 100dvh;
  color-scheme: light;
}
.kb-open { --safe-bottom: 0px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--navy); overflow: hidden; overscroll-behavior: none; position: fixed; inset: 0; width: 100%; }
body { font-family: Estedad, -apple-system, sans-serif; color: var(--navy); font-size: 14px; -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
button, input, textarea { font: inherit; color: inherit; }
input, textarea { -webkit-user-select: text; user-select: text; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

#app { position: fixed; top: 0; right: 0; left: 0; height: var(--app-h); overflow: hidden; background: var(--ice); }
#status-band { position: absolute; top: 0; right: 0; left: 0; height: var(--safe-top); background: var(--navy); z-index: 30; }
#stage { position: absolute; top: var(--safe-top); right: 0; left: 0; bottom: 0; background: var(--ice); }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--ice); }
.fade-in { animation: fade-in .7s both; z-index: 2; }
.fade-out { animation: fade-out .7s both; pointer-events: none; z-index: 1; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }

.t-ds { font-size: 34px; font-weight: 800; line-height: 1.2; }
.t-hs { font-size: 22px; font-weight: 800; line-height: 1.4; }
.t-tl { font-size: 19px; font-weight: 800; line-height: 1.4; }
.t-tm { font-size: 16px; font-weight: 700; line-height: 1.6; }
.t-ts { font-size: 14px; font-weight: 700; line-height: 1.6; }
.t-bl { font-size: 15px; font-weight: 400; line-height: 1.8; }
.t-bm { font-size: 14px; font-weight: 400; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.t-bs { font-size: 12px; font-weight: 400; line-height: 1.7; }
.t-ll { font-size: 14px; font-weight: 700; line-height: 1.6; }
.t-lm { font-size: 12px; font-weight: 600; line-height: 1.6; }
.t-lsm { font-size: 11px; font-weight: 500; line-height: 1.6; }

.row { display: flex; flex-direction: row; min-width: 0; }
.col { display: flex; flex-direction: column; min-width: 0; }
.grow { flex: 1 1 0; min-width: 0; }
.contents { display: contents; }
.center { display: flex; align-items: center; justify-content: center; }
.fill { flex: 1; min-height: 0; }
.nowrap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clamp { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.clamp-1 { -webkit-line-clamp: 1; line-clamp: 1; word-break: break-all; }
.clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }
.icon { display: inline-flex; flex: none; }
.icon svg { width: 100%; height: 100%; }
.press { transition: opacity .12s; cursor: pointer; }
.press:active { opacity: .72; }

.scroll { display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; min-height: 0; flex-basis: 0; }
.scroll > *, .scroll > .contents > * { flex: none; }
.hscroll { display: flex; overflow-x: auto; gap: 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin-inline: -20px; padding-inline: 20px; }
.hscroll::-webkit-scrollbar, .scroll::-webkit-scrollbar { display: none; }
.hscroll > * { flex: none; }

.card { display: flex; flex-direction: column; min-width: 0; }
.list-card { background: var(--white); border-radius: 22px; padding: 0 14px; }
.divider { height: 1px; background: var(--ice); }
.tap-row { display: flex; align-items: center; cursor: pointer; }

.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 16px; padding: 0 16px; font-size: 15px; font-weight: 700; flex: none; }
.btn-primary:disabled { opacity: .45; }
.btn-secondary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 14px; padding: 0 12px; font-size: 13px; font-weight: 700; background: var(--white); color: var(--navy); border: 1.5px solid var(--navy); min-width: 0; }
.btn-secondary:disabled { opacity: .5; }
.btn-text { padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.btn-text:disabled { cursor: default; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; border-radius: 14px; flex: none; }
.icon-plain { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-box { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 16px; padding: 0 14px; min-height: 56px; transition: border-color .12s; }
.field-box.focus { border-color: var(--navy); border-width: 2px; padding: 0 13px; }
.field input, .field textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 16px; line-height: 1.7; color: var(--navy); padding: 13px 0; resize: none; display: block; }
.field input::placeholder, .field textarea::placeholder { color: var(--hint); font-size: 14px; }
.field input[dir=auto]:placeholder-shown, .field textarea[dir=auto]:placeholder-shown { direction: rtl; }
.field input[dir=ltr]:placeholder-shown { text-align: right; }

.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; border-radius: 999px; padding: 4px 14px; font-size: 12px; line-height: 1.6; flex: none; max-width: 100%; }
.pill-click { min-height: 40px; }
.avatar { display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.grade { display: flex; align-items: center; justify-content: center; flex: none; }
.spinner { display: inline-block; border-style: solid; border-radius: 50%; animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.screen-header { display: flex; align-items: center; gap: 12px; padding: 20px 20px 10px; flex: none; }
.count { display: inline-flex; align-items: center; justify-content: center; min-height: 20px; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; flex: none; }
.segmented { display: flex; gap: 4px; border-radius: 16px; padding: 4px; flex: none; }
.segment { flex: 1 1 0; min-width: 0; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; }

.bottom-nav { flex: none; display: flex; gap: 4px; background: var(--white); border-radius: 26px 26px 0 0; padding: 10px 10px calc(12px + var(--safe-bottom)); box-shadow: 0 -6px 18px rgba(15,39,71,.1); position: relative; z-index: 3; }
.nav-item { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; border-radius: 16px; padding: 8px 0; font-size: 11px; }
.nav-icon { position: relative; display: inline-flex; }
.nav-dot { position: absolute; top: 0; left: 0; width: 9px; height: 9px; border-radius: 50%; background: var(--navy); border: 1.5px solid var(--white); }

.banner { display: flex; gap: 10px; border-radius: 16px; padding: 12px; flex: none; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 16px; }
.empty-icon { width: 56px; height: 56px; border-radius: 18px; background: var(--white); display: flex; align-items: center; justify-content: center; }
.pick-tile { flex: 1 1 0; height: 92px; border-radius: 20px; background: var(--soft); border: 1.5px dashed var(--dash); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--navy); }
.progress { height: 6px; border-radius: 6px; overflow: hidden; background: var(--white); }
.progress > div { height: 100%; background: var(--navy); border-radius: 6px; transition: width .15s; }
.file-row { display: flex; align-items: center; gap: 12px; background: var(--white); border-radius: 18px; padding: 10px; }
.thumb { position: relative; overflow: hidden; flex: none; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 2px; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.play-mark { display: flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(232,237,243,.92); color: var(--navy); position: relative; }
.grade-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; direction: ltr; }
.grade-cell { height: 50px; border-radius: 14px; font-size: 18px; font-weight: 800; }
.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { background: var(--white); border-radius: 18px; overflow: hidden; cursor: pointer; min-width: 0; }

.chat-list { display: flex; flex-direction: column; gap: 8px; padding: 16px; }
.bubble-wrap { display: flex; }
.bubble { max-width: min(290px, 82%); padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; -webkit-user-select: text; user-select: text; }
.day-chip { align-self: center; background: var(--line); color: var(--navy); border-radius: 999px; padding: 3px 12px; font-size: 11px; font-weight: 500; line-height: 1.6; }
.chat-input { display: flex; align-items: center; gap: 10px; padding: 6px 16px 10px; flex: none; }

#toast { position: absolute; left: 50%; bottom: calc(92px + var(--safe-bottom)); transform: translate(-50%, 12px); max-width: 86%; width: max-content; background: #323232; color: #fff; font-size: 13px; line-height: 1.7; padding: 8px 16px; border-radius: 18px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 60; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#dialogs { position: absolute; inset: 0; z-index: 50; pointer-events: none; }
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.32); display: flex; align-items: center; justify-content: center; padding: 24px; pointer-events: auto; animation: fade-in .15s both; }
.scrim.leaving { animation: fade-out .15s both; }
.dialog { background: var(--white); border-radius: 24px; padding: 22px 22px 12px; width: 100%; max-width: 340px; max-height: 88%; display: flex; flex-direction: column; gap: 14px; animation: dialog-in .15s both; }
.dialog.leaving { animation: fade-out .15s both; }
@keyframes dialog-in { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
.dialog-body { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 0; -webkit-overflow-scrolling: touch; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; flex: none; }
.dialog-row { display: flex; align-items: center; gap: 8px; padding: 10px 6px; border-radius: 12px; cursor: pointer; }
.radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--dash); display: flex; align-items: center; justify-content: center; flex: none; margin: 4px; }
.radio.on { border-color: var(--navy); }
.radio.on::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--navy); }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px 0; }
.cal-head { text-align: center; font-size: 11px; font-weight: 500; color: var(--muted); }
.cal-day { aspect-ratio: 1; border-radius: 50%; font-size: 14px; }

.drawer-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.32); z-index: 40; animation: fade-in .2s both; }
.drawer { position: absolute; top: 0; bottom: 0; right: 0; width: min(310px, 86%); background: var(--white); border-radius: 28px 0 0 28px; padding: calc(24px + var(--safe-top)) 18px calc(18px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px; z-index: 41; animation: drawer-in .25s both; }
.drawer.closing { animation: drawer-out .2s both; }
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: none; } }
@keyframes drawer-out { from { transform: none; } to { transform: translateX(100%); } }

.viewer { background: var(--navy); }
.viewer.light { background: var(--ice); }
.pager { flex: 1 1 0; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.pager::-webkit-scrollbar { display: none; }
.pager.locked { overflow-x: hidden; }
.page { flex: 0 0 100%; width: 100%; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; position: relative; display: flex; flex-direction: column; min-width: 0; }
.zoom-box { flex: 1; min-height: 0; overflow: hidden; touch-action: pan-x; padding: 0 14px 16px; display: flex; align-items: center; justify-content: center; }
.zoom-box img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; transform-origin: center; }
.video-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; }
.video-stage video { width: 100%; max-height: 100%; }
.video-btn { position: absolute; width: 68px; height: 68px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--navy); }
.seek { position: relative; height: 28px; direction: ltr; touch-action: none; display: flex; align-items: center; }
.seek i { position: absolute; left: 0; height: 5px; border-radius: 5px; display: block; }
.seek b { position: absolute; width: 15px; height: 15px; border-radius: 50%; background: var(--ice); margin-left: -7px; }
.pdf-list { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 20px 16px; display: flex; flex-direction: column; gap: 12px; -webkit-overflow-scrolling: touch; transform-origin: top center; }
.pdf-page { background: var(--white); border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; flex: none; position: relative; }
.pdf-page canvas { width: 100%; height: 100%; display: block; }

/* Login */
.login { background: var(--navy); }
.login-top { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 56px 0 40px; flex: none; }
.login-sheet { flex: 1 1 0; min-height: 0; background: var(--ice); border-radius: 32px 32px 0 0; overflow-y: auto; padding: 32px 24px calc(20px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 16px; -webkit-overflow-scrolling: touch; }
.login-sheet > * { flex: none; }
.preview-box { border: 1.5px dashed var(--dash); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }

/* Add to Home Screen */
.gate { position: absolute; inset: 0; background: var(--navy); display: flex; flex-direction: column; color: var(--ice); z-index: 20; }
.gate-top { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: calc(30px + var(--safe-top)) 24px 24px; flex: none; }
.gate-sheet { flex: 1 1 0; min-height: 0; background: var(--ice); color: var(--navy); border-radius: 32px 32px 0 0; padding: 24px 20px calc(16px + var(--safe-bottom)); overflow-y: auto; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.gate-sheet > * { flex: none; }
.step { display: flex; gap: 12px; background: var(--white); border-radius: 20px; padding: 13px; align-items: center; }
.step-num { width: 34px; height: 34px; border-radius: 11px; background: var(--navy); color: var(--white); display: flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.step-icon { width: 42px; height: 42px; border-radius: 13px; background: var(--ice); color: #0A84FF; display: flex; align-items: center; justify-content: center; flex: none; }
.en { font-weight: 700; direction: ltr; unicode-bidi: isolate; }
.gate-arrow { display: flex; justify-content: center; color: var(--navy); animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(7px); } }
