/* HSClarity student app (/app/*). Builds on /style.css tokens. */

.app-main { background: var(--grey-50); min-height: 70vh; padding: 2.5rem 0 4rem; }
.app-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.75rem; }
.app-head h1 { font-size: 2rem; margin-bottom: 0.25rem; }
.app-head p { margin: 0; color: var(--text-light); }
.app-head .crumb { font-size: 0.85rem; margin-bottom: 0.35rem; }
.app-head-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.85rem; }
.btn-ghost { background: var(--white); color: var(--navy); border: 1px solid var(--grey-200); }
.btn-ghost:hover { background: var(--grey-100); color: var(--navy); }
.btn-danger { background: var(--white); color: #C62828; border: 1px solid #F3C5C5; }
.btn-danger:hover { background: #FDECEC; color: #B71C1C; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.link-btn { background: none; border: none; color: var(--blue); font: inherit; font-size: 0.9rem; cursor: pointer; padding: 0; }
.link-btn:hover { color: var(--blue-hover); text-decoration: underline; }

.panel { background: var(--white); border: 1px solid var(--grey-200); border-radius: 10px; padding: 1.5rem; }
.panel + .panel { margin-top: 1.25rem; }
.panel h2 { font-size: 1.2rem; margin-bottom: 1rem; }
.auth-panel { max-width: 440px; margin: 0 auto; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem; background: var(--grey-100); padding: 0.25rem; border-radius: 8px; margin-bottom: 1.5rem; }
.auth-tabs button { border: none; background: transparent; padding: 0.55rem; border-radius: 6px; font: inherit; font-weight: 600; font-size: 0.9rem; color: var(--grey-600); cursor: pointer; }
.auth-tabs button[aria-selected="true"] { background: var(--white); color: var(--navy); box-shadow: var(--shadow-sm); }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.msg { border-radius: 6px; padding: 0.75rem 1rem; font-size: 0.9rem; margin-bottom: 1rem; }
.msg-error { background: #FDECEC; color: #8E1B1B; border: 1px solid #F3C5C5; }
.msg-ok { background: #E8F5E9; color: #1B5E20; border: 1px solid #C8E6C9; }
.msg-info { background: var(--blue-light); color: var(--grey-800); border: 1px solid #BBDEFB; }
.msg:empty { display: none; }

.coming-soon { max-width: 560px; margin: 1rem auto; text-align: center; padding: 2.5rem 2rem; }
.coming-soon .card-icon { margin: 0 auto 1rem; }
.coming-soon h2 { margin-bottom: 0.6rem; }
.coming-soon p { color: var(--text-light); }
.coming-soon .hero-actions { margin: 1.5rem 0 0; }

.app-loading { text-align: center; color: var(--text-light); padding: 3rem 0; }

/* Dashboard */
.tile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.tile { display: block; background: var(--white); border: 1px solid var(--grey-200); border-radius: 10px; padding: 1.75rem; color: var(--text); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); color: var(--text); }
.tile h2 { font-size: 1.3rem; margin-bottom: 0.4rem; }
.tile p { color: var(--text-light); font-size: 0.92rem; margin-bottom: 1rem; }
.tile-stat { font-size: 0.85rem; font-weight: 600; color: var(--blue); }
.account-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; font-size: 0.9rem; color: var(--text-light); }

/* Toolbar / filters */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 1.25rem; }
.toolbar select, .toolbar input[type="search"] { padding: 0.5rem 0.7rem; border: 1px solid var(--grey-200); border-radius: 6px; font: inherit; font-size: 0.9rem; background: var(--white); color: var(--text); }
.toolbar .check-inline { margin: 0; font-size: 0.9rem; align-items: center; }
.toolbar .check-inline input { margin-top: 0; }
.toolbar .count { margin-left: auto; font-size: 0.85rem; color: var(--text-light); }

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group textarea.short { min-height: 70px; }

/* Drop zone */
.dropzone { border: 2px dashed var(--grey-200); border-radius: 10px; background: var(--grey-50); padding: 1.5rem; text-align: center; cursor: pointer; color: var(--text-light); font-size: 0.9rem; position: relative; }
.dropzone:hover, .dropzone.drag { border-color: var(--blue); background: var(--blue-light); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone strong { color: var(--navy); }
.preview-img { max-height: 260px; margin: 0.75rem auto 0; border-radius: 6px; border: 1px solid var(--grey-200); }

/* Mistakes list */
.subject-group { margin-bottom: 2rem; }
.subject-group > h2 { font-size: 1.25rem; margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.6rem; }
.topic-group > h3 { font-size: 0.95rem; color: var(--grey-600); text-transform: uppercase; letter-spacing: 0.05em; margin: 1rem 0 0.6rem; }
.mistake-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.mistake { background: var(--white); border: 1px solid var(--grey-200); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.mistake.mastered { opacity: 0.8; }
.mistake-img { background: var(--grey-100); display: block; width: 100%; border: none; padding: 0; cursor: zoom-in; }
.mistake-img img { width: 100%; max-height: 220px; object-fit: contain; background: var(--white); }
.mistake-img .ph { padding: 2.5rem 1rem; color: var(--grey-400); font-size: 0.85rem; }
.mistake-body { padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.mistake-body .meta { font-size: 0.78rem; color: var(--text-light); }
.mistake-body .field { font-size: 0.88rem; white-space: pre-wrap; word-break: break-word; margin: 0; }
.mistake-body .field b { color: var(--grey-800); font-weight: 600; }
.mistake-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-top: auto; padding-top: 0.5rem; }
.status-toggle { border: 1px solid var(--grey-200); border-radius: 999px; padding: 0.3rem 0.8rem; font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; background: #FFF8E1; color: #8D6E00; border-color: #FFE082; }
.status-toggle.done { background: #E8F5E9; color: #1B5E20; border-color: #C8E6C9; }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-light); }
.empty h3 { margin-bottom: 0.4rem; }

/* Dialog */
dialog.app-dialog { margin: auto; border: none; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); box-shadow: 0 20px 50px rgba(13,27,42,0.3); }
dialog.app-dialog::backdrop { background: rgba(13,27,42,0.55); }
.dialog-inner { padding: 1.5rem; }
.dialog-inner h2 { font-size: 1.2rem; margin-bottom: 1rem; }
.dialog-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
dialog.img-dialog { width: min(1100px, calc(100vw - 1rem)); background: var(--white); }
dialog.img-dialog img { width: 100%; height: auto; }

/* Flashcards: decks */
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.deck { background: var(--white); border: 1px solid var(--grey-200); border-radius: 10px; padding: 1.25rem; display: flex; flex-direction: column; gap: 0.4rem; }
.deck h3 { font-size: 1.1rem; word-break: break-word; }
.deck .meta { font-size: 0.85rem; color: var(--text-light); }
.deck .due { font-weight: 600; color: var(--blue); }
.deck-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: auto; padding-top: 0.6rem; }

.card-list { display: flex; flex-direction: column; gap: 0.6rem; }
.fc-row { background: var(--white); border: 1px solid var(--grey-200); border-radius: 8px; padding: 0.9rem 1rem; display: grid; grid-template-columns: 1fr 1fr auto; gap: 1rem; align-items: start; }
.fc-row .side { font-size: 0.9rem; white-space: pre-wrap; word-break: break-word; }
.fc-row .side small { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--grey-400); font-weight: 600; }
.fc-row .row-actions { display: flex; gap: 0.4rem; }
.fc-row .box-tag { font-size: 0.72rem; color: var(--text-light); }

/* Revise mode */
.revise { max-width: 720px; margin: 0 auto; }
.revise-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.progress { height: 6px; background: var(--grey-200); border-radius: 999px; overflow: hidden; margin-bottom: 1.25rem; }
.progress > span { display: block; height: 100%; background: var(--blue); width: 0; transition: width 0.2s ease; }
.flashcard { background: var(--white); border: 1px solid var(--grey-200); border-radius: 14px; box-shadow: var(--shadow-md); min-height: 280px; padding: 2rem 1.75rem; display: flex; flex-direction: column; justify-content: center; text-align: center; cursor: pointer; user-select: text; }
.flashcard .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--grey-400); font-weight: 700; margin-bottom: 0.75rem; }
.flashcard .text { font-size: 1.25rem; color: var(--navy); white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.flashcard .back { border-top: 1px dashed var(--grey-200); margin-top: 1.5rem; padding-top: 1.5rem; }
.revise-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-top: 1.25rem; }
.revise-controls .btn { width: 100%; }
.rate-again { background: #FDECEC; color: #8E1B1B; }
.rate-again:hover { background: #F9D6D6; color: #8E1B1B; }
.rate-good { background: var(--blue); color: var(--white); }
.rate-good:hover { background: var(--blue-hover); color: var(--white); }
.rate-easy { background: #E8F5E9; color: #1B5E20; }
.rate-easy:hover { background: #D3ECD5; color: #1B5E20; }
.kbd-hint { text-align: center; font-size: 0.8rem; color: var(--text-light); margin-top: 0.9rem; }
kbd { font-family: inherit; font-size: 0.75rem; border: 1px solid var(--grey-200); border-bottom-width: 2px; border-radius: 4px; padding: 0 0.35rem; background: var(--white); }

.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--navy); color: var(--white); padding: 0.7rem 1.2rem; border-radius: 8px; font-size: 0.9rem; z-index: 3000; box-shadow: var(--shadow-md); max-width: calc(100vw - 2rem); }
.toast.error { background: #8E1B1B; }

[hidden] { display: none !important; }

@media (max-width: 768px) {
    .tile-grid { grid-template-columns: 1fr; }
    .form-row-2 { grid-template-columns: 1fr; }
    .fc-row { grid-template-columns: 1fr; }
    .app-head h1 { font-size: 1.6rem; }
    .flashcard { min-height: 220px; padding: 1.5rem 1.25rem; }
    .flashcard .text { font-size: 1.1rem; }
    .toolbar .count { margin-left: 0; width: 100%; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
