/* Flashcard Tutor site styles.
   One stylesheet for the tutor (chat + deck pages), the document pages
   (about, feedback, privacy) and the Memory Match game. Plain CSS: no build step. */

:root {
    --ink: #0f172a;
    --muted: #6b6250;
    --line: #d6c08c;
    --bg: #e6d6a9;
    --surface: #ffffff;
    --accent: #1e40af;
    --accent-strong: #1e3a8a;
    --accent-tint: #dde5f6;
    --accent-light: #3b82f6;
    --danger: #b42318;
    --danger-tint: #fdecea;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 28px rgba(15, 23, 42, 0.08);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: 'Source Serif 4', 'Source Serif Pro', Georgia, 'Times New Roman', serif;
    --column: 780px;
}

[hidden] {
    display: none !important;
}

/* ---------- Base (tutor and document pages) ---------- */

body.app,
body.doc {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

body.app *,
body.doc * {
    box-sizing: border-box;
}

:where(body.app, body.doc) :where(h1, h2, p) {
    margin: 0;
}

body.app button,
body.app input,
body.app textarea,
body.doc button,
body.doc input,
body.doc textarea {
    font-family: inherit;
}

:focus-visible {
    outline: 3px solid rgba(30, 64, 175, 0.45);
    outline-offset: 2px;
}

/* ---------- Site header ---------- */

.site-header {
    flex-shrink: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.site-header-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-mark svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linejoin: round;
}

.brand-tagline {
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--muted);
    margin-left: 6px;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 8px 10px;
    border-radius: 8px;
}

.nav-link:hover {
    color: var(--ink);
    background: var(--bg);
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-strong);
}

.btn-secondary {
    background: var(--surface);
    color: var(--accent);
    border-color: var(--accent);
}

.btn-secondary:hover {
    background: var(--accent-tint);
}

.btn-quiet {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line);
}

.btn-quiet:hover {
    border-color: var(--muted);
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ---------- Tutor layout ---------- */

body.app {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-main {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: var(--column);
    margin: 0 auto;
    padding: 16px 16px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ---------- Deck header ---------- */

.deck-head {
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px 20px;
}

.deck-head-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 14px;
}

.deck-head-text {
    flex: 1 1 260px;
    min-width: 0;
}

.eyebrow {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
}

.deck-title {
    font-size: 1.6rem;
    line-height: 1.2;
    font-weight: 750;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.deck-meta {
    margin-top: 4px;
    font-size: 0.92rem;
    color: var(--muted);
}

.deck-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.progress {
    margin-top: 12px;
    height: 6px;
    border-radius: 999px;
    background: var(--accent-tint);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: var(--accent);
    transition: width 0.3s ease;
}

.share-panel {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.share-panel-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.share-row {
    display: flex;
    gap: 8px;
}

.share-row input {
    flex: 1;
    min-width: 0;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
    color: var(--ink);
    font-size: 0.95rem;
}

.share-note {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--muted);
}

/* ---------- Study mode tabs (decks that carry their own cards) ---------- */

.mode-tabs {
    flex-shrink: 0;
    display: flex;
    gap: 4px;
    padding: 4px;
    background: #e9edea;
    border-radius: 12px;
}

.mode-tab {
    flex: 1;
    min-height: 38px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.mode-tab.active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
}

/* ---------- Flip card study view ---------- */

.card-study {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-bottom: 16px;
}

.fc-stage {
    flex: 1;
    min-height: 220px;
    max-height: 420px;
    perspective: 1400px;
}

.fc-card {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    text-align: center;
    border-radius: var(--radius-lg);
}

.fc-inner {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.3, 0.7, 0.3, 1);
}

.fc-card.is-flipped .fc-inner {
    transform: rotateY(180deg);
}

.fc-card.no-anim .fc-inner {
    transition: none;
}

.fc-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 28px 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    overflow: hidden;
}

.fc-back {
    transform: rotateY(180deg);
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.fc-side {
    position: absolute;
    top: 16px;
    left: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
}

.fc-back .fc-side {
    color: rgba(255, 255, 255, 0.85);
}

.fc-text {
    font-size: clamp(1.5rem, 5vw, 2.4rem);
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
    max-height: 100%;
    overflow-y: auto;
}

.fc-text.is-long {
    font-size: clamp(1.1rem, 3.4vw, 1.5rem);
    font-weight: 600;
}

.fc-hint {
    position: absolute;
    bottom: 14px;
    left: 0;
    right: 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.fc-back .fc-hint {
    color: rgba(255, 255, 255, 0.8);
}

.fc-status {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.92rem;
    color: var(--muted);
}

.fc-status .progress {
    flex: 1;
    margin-top: 0;
}

.fc-count {
    font-weight: 600;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.fc-controls {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 8px;
}

.fc-controls .btn {
    min-height: 48px;
}

.fc-secondary {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    gap: 8px;
}

/* ---------- Chat ---------- */

.chat-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0 -8px;
    padding: 4px 8px 22px;
}

.message {
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.bot {
    align-items: flex-start;
}

.message.user {
    align-items: flex-end;
}

.message-content {
    max-width: 100%;
    padding: 12px 16px;
    border-radius: 16px;
    overflow-wrap: anywhere;
    line-height: 1.55;
}

.message.bot .message-content {
    background: var(--surface);
    border: 1px solid var(--line);
    border-bottom-left-radius: 6px;
}

.message.user .message-content {
    max-width: 80%;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.message-content small {
    color: var(--muted);
}

.md-h1 {
    font-size: 1.2em;
}

.md-h2 {
    font-size: 1.1em;
}

.hover-word {
    border-bottom: 1px dotted var(--accent);
    cursor: help;
}

.topic-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.topic-chip,
.recent-topic-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.topic-chip:hover,
.recent-topic-btn:hover {
    border-color: var(--accent);
    background: var(--accent-tint);
    color: var(--accent-strong);
}

.recent-topics {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.recent-topics-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 8px;
}

.recent-topics-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.recent-topic-btn .topic-stats {
    font-size: 0.8rem;
    color: var(--muted);
}

.studio-links {
    max-width: 600px;
    margin: 4px auto 14px;
    padding: 0 10px;
    text-align: center;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--muted);
}

.studio-links a {
    color: var(--accent);
    text-decoration: none;
}

.studio-links a:hover {
    text-decoration: underline;
}

.illustration-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 14px 22px;
    background: var(--accent-tint);
    border-radius: var(--radius);
}

.emoji-illustration {
    font-size: 3.2rem;
    line-height: 1;
}

.math-illustration {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent-strong);
    text-align: center;
}

.music-notation {
    display: block;
    min-height: 80px;
    margin: 10px 0;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.music-notation img {
    max-width: 250px;
    height: auto;
    display: block;
}

.typing-indicator {
    display: none;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    border-bottom-left-radius: 6px;
    width: fit-content;
}

.typing-indicator.show {
    display: block;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    background: #9aa59f;
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    animation: bounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

.chat-input {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 10px 0 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.chat-input input {
    flex: 1;
    min-width: 0;
    height: 48px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    font-size: 16px;
    outline: none;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-input input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15);
}

.chat-input .btn {
    min-height: 48px;
    padding: 0 20px;
    border-radius: 12px;
}

/* ---------- Quiz question, shown as a card that flips to the answer ---------- */

.quiz-card {
    width: 100%;
    margin-top: 8px;
    perspective: 1400px;
}

.quiz-inner {
    display: grid;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.3, 0.7, 0.3, 1);
}

.quiz-card.is-flipped .quiz-inner {
    transform: rotateY(180deg);
}

.quiz-card.is-answered {
    cursor: pointer;
}

.quiz-face {
    grid-area: 1 / 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(16, 24, 20, 0.05), 0 5px 14px rgba(16, 24, 20, 0.08);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.quiz-back {
    transform: rotateY(180deg);
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.quiz-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
}

.quiz-back .quiz-label {
    color: rgba(255, 255, 255, 0.85);
}

.quiz-question {
    font-size: 1.3rem;
    line-height: 1.3;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.quiz-option {
    min-height: 48px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.quiz-option:hover {
    border-color: var(--accent);
    background: var(--accent-tint);
}

.quiz-option.disabled {
    pointer-events: none;
    color: var(--muted);
}

.quiz-option.correct {
    border-color: var(--accent);
    background: var(--accent-tint);
    color: var(--accent-strong);
    font-weight: 700;
}

.quiz-option.incorrect {
    border-color: var(--danger);
    background: var(--danger-tint);
    color: var(--danger);
    font-weight: 700;
}

.quiz-emoji {
    font-size: 3.2rem;
    line-height: 1.1;
}

.quiz-word {
    font-size: 1.7rem;
    line-height: 1.2;
    font-weight: 750;
    overflow-wrap: anywhere;
}

.quiz-feedback {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    font-size: 0.9rem;
    font-weight: 700;
}

.quiz-back-question {
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.85);
}

/* ---------- Modal ---------- */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 20, 0.55);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.modal-header h2 {
    font-size: 1.3rem;
    letter-spacing: -0.01em;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
}

.modal-close:hover {
    background: var(--bg);
    color: var(--ink);
}

.deck-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.92rem;
    font-weight: 600;
}

.deck-form input[type="text"],
.deck-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 16px;
    color: var(--ink);
    background: var(--surface);
}

.deck-form textarea {
    min-height: 120px;
    resize: vertical;
}

.deck-form input[type="text"]:focus,
.deck-form textarea:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15);
}

.dupe-match{padding:16px 0 0}
.dupe-match-lede{font-weight:600;margin:0 0 10px}
.dupe-match-card{display:block;padding:14px 16px;border:1px solid #d0d0d6;border-radius:10px;background:#fafafd;color:inherit;text-decoration:none;margin:0 0 14px}
.dupe-match-card:hover{border-color:var(--accent)}
.dupe-match-name{font-weight:600;margin:0 0 4px}
.dupe-match-sub{font-size:.85rem;color:#667;margin:0}
.dupe-match-actions{display:flex;flex-direction:column;gap:8px}
.dupe-match-cancel{background:none;border:none;color:#667;font-size:.9rem;padding:8px;cursor:pointer;text-decoration:underline}
.dupe-match-cancel:hover{color:#334}

.deck-type-toggle {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 14px;
    background: #e9edea;
    border-radius: 12px;
}

.toggle-btn {
    flex: 1;
    min-height: 38px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.toggle-btn.active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
}

.file-upload-area {
    border: 2px dashed var(--line);
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    margin-bottom: 14px;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
    background: var(--bg);
}

.file-upload-area:hover,
.file-upload-area.dragover {
    border-color: var(--accent);
    background: var(--accent-tint);
}

.file-upload-area input[type="file"] {
    display: none;
}

.file-upload-area .upload-icon {
    font-size: 1.8rem;
    margin-bottom: 6px;
}

.file-upload-area .upload-text {
    color: var(--ink);
    font-size: 0.92rem;
}

.file-upload-area .upload-formats {
    color: var(--muted);
    font-size: 0.8rem;
    margin-top: 4px;
}

.deck-option {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 10px;
}

.deck-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.deck-option label {
    margin: 0;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.deck-option .option-desc {
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 400;
}

/* ---------- Toast ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 88px;
    transform: translateX(-50%);
    z-index: 3000;
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--ink);
    color: #fff;
    font-size: 0.92rem;
    font-weight: 500;
    box-shadow: var(--shadow);
}

/* ---------- Document pages (about, feedback, privacy) ---------- */

body.doc {
    min-height: 100vh;
}

.page {
    max-width: var(--column);
    margin: 0 auto;
    padding: 28px 16px 56px;
}

.page-narrow {
    max-width: 620px;
}

.page-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 36px;
}

.page-card h1 {
    font-size: 2rem;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: 14px;
}

.page-card h2 {
    font-size: 1.2rem;
    letter-spacing: -0.01em;
    margin: 30px 0 10px;
}

.page-card p {
    color: var(--ink);
    line-height: 1.7;
    margin-bottom: 14px;
}

.page-card ul {
    color: var(--ink);
    line-height: 1.7;
    margin: 0 0 14px;
    padding-left: 22px;
}

.page-card a:not(.btn) {
    color: var(--accent);
}

.page-card .page-note {
    font-size: 0.9rem;
    color: var(--muted);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    margin-top: 28px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px;
    margin: 16px 0;
}

.category-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.category-card .emoji {
    font-size: 1.5rem;
    line-height: 1;
}

.category-card .name {
    font-weight: 600;
}

.form-field {
    display: block;
    margin-bottom: 18px;
}

.form-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.92rem;
    font-weight: 600;
}

.form-field input,
.form-field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font-size: 16px;
}

.form-field textarea {
    min-height: 150px;
    resize: vertical;
}

.form-field input:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15);
}

.notice {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-weight: 500;
}

.notice-success {
    background: var(--accent-tint);
    color: var(--accent-strong);
}

.notice-error {
    background: var(--danger-tint);
    color: var(--danger);
}

/* ---------- Memory Match game (page layout uses the Tailwind build) ---------- */

body.game {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
}

.game-link:hover,
.game-stat {
    color: var(--accent);
}

.game-btn-primary {
    background: var(--accent);
    color: #fff;
}

.game-btn-primary:hover:not(:disabled) {
    background: var(--accent-strong);
}

.game-btn-soft {
    background: var(--accent-tint);
    color: var(--accent-strong);
}

.game-btn-soft:hover {
    background: #d3ebe0;
}

.hex-grid {
    display: grid;
    gap: 8px;
    justify-content: center;
    padding: 20px;
}

.hex-grid.easy { grid-template-columns: repeat(4, 1fr); max-width: 400px; }
.hex-grid.medium { grid-template-columns: repeat(4, 1fr); max-width: 450px; }
.hex-grid.hard { grid-template-columns: repeat(6, 1fr); max-width: 550px; }

.hex-grid .card {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 12px;
    transition: transform 0.3s, background-color 0.3s;
    user-select: none;
    min-width: 60px;
    min-height: 60px;
    padding: 4px;
    text-align: center;
    line-height: 1.1;
}

.hex-grid .card.face-down {
    background: var(--accent);
    color: #fff;
}

.hex-grid .card.face-down:hover {
    transform: scale(1.05);
    background: var(--accent-strong);
}

.hex-grid .card.face-up {
    background: var(--surface);
    border: 2px solid var(--ink);
}

.hex-grid .card.matched {
    background: var(--accent-tint);
    border: 2px solid var(--accent);
    cursor: default;
}

.hex-grid .card.matched:hover {
    transform: none;
}

.subject-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.subject-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.subject-card.selected {
    border-color: var(--accent);
    background: var(--accent-tint);
}

.chem-structure {
    width: 50px;
    height: 50px;
}

.custom-pairs-input {
    width: 100%;
    min-height: 150px;
    font-family: monospace;
    font-size: 0.9rem;
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
    .site-header-inner {
        padding: 8px 12px;
    }

    .brand-tagline,
    .hide-sm {
        display: none;
    }

    .nav-link {
        padding: 8px 6px;
    }

    .site-nav .btn {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .app-main {
        padding: 10px 12px 0;
        gap: 10px;
    }

    .deck-head {
        padding: 12px 14px;
        border-radius: 16px;
    }

    .deck-title {
        font-size: 1.25rem;
    }

    .deck-meta {
        font-size: 0.85rem;
    }

    .deck-actions {
        width: 100%;
    }

    .deck-actions .btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 8px 6px;
        font-size: 0.875rem;
    }

    .deck-actions .btn svg {
        display: none;
    }

    .progress {
        margin-top: 10px;
    }

    .quiz-face {
        padding: 16px;
    }

    .quiz-question {
        font-size: 1.15rem;
    }

    .quiz-options {
        grid-template-columns: 1fr;
    }

    .chat-input {
        padding-top: 8px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .page {
        padding: 14px 12px 40px;
    }

    .page-card {
        padding: 22px 18px;
        border-radius: 16px;
    }

    .page-card h1 {
        font-size: 1.6rem;
    }

    .toast {
        bottom: 76px;
    }
}

@media (max-width: 380px) {
    .brand {
        font-size: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fc-inner,
    .quiz-inner,
    .progress-bar {
        transition: none;
    }

    .message {
        animation: none;
    }
}

/* ---------- Landing variant: allow scrolling, let hero breathe ---------- */

body.app.landing {
    height: auto;
    min-height: 100vh;
    overflow: visible;
}

body.app.landing .app-main {
    flex: 0 0 auto;
    padding-bottom: 24px;
}

/* ---------- Hero (landing, chat.blade.php) ---------- */

.hero {
    max-width: 1080px;
    margin: 0 auto;
    padding: 56px 24px 30px;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 420px);
    gap: 48px;
    align-items: center;
}

.hero-text {
    max-width: 560px;
}

.hero-text .hero-eyebrow {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--accent);
    margin-bottom: 14px;
}

.hero-text h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 3.6vw, 2.7rem);
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin: 0 0 20px;
    color: var(--ink);
}

.hero-text h1 em {
    font-style: normal;
    color: var(--accent-light);
}

.hero-text .hero-sub {
    color: var(--muted);
    font-size: 1.1rem;
    max-width: 540px;
    margin-bottom: 26px;
    line-height: 1.55;
}

.hero-cta {
    display: inline-block;
    text-decoration: none;
    font-family: var(--font);
    font-weight: 600;
    font-size: 1.05rem;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    border: 0;
    border-radius: 12px;
    padding: 14px 30px;
    cursor: pointer;
}

.hero-cta:hover { opacity: 0.92; }

.hero-note {
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

/* Flashcard specimen: real card, hover-flip, real words */
.specimen {
    position: relative;
    perspective: 1200px;
}

.specimen-stack {
    position: relative;
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
    padding: 18px 10px 24px;
}

.specimen-card {
    position: relative;
    width: 100%;
    aspect-ratio: 5 / 3.1;
    border-radius: 20px;
    background: transparent;
    border: 0;
    padding: 0;
    transform-style: preserve-3d;
    transition: transform 0.65s cubic-bezier(.4,.02,.2,1);
    cursor: pointer;
    z-index: 2;
}

.specimen-card.flipped {
    transform: rotateY(180deg);
}

.specimen-card:hover:not(.flipped) {
    transform: translateY(-2px);
}

.specimen-face {
    position: absolute;
    inset: 0;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    text-align: center;
}

.specimen-face.back {
    transform: rotateY(180deg);
}

.specimen-side {
    position: absolute;
    top: 14px;
    left: 18px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--muted);
}

.specimen-word {
    font-family: var(--font-display);
    font-size: clamp(1.9rem, 3.8vw, 2.5rem);
    font-weight: 600;
    color: var(--ink);
    line-height: 1.15;
}

.specimen-pronounce {
    color: var(--muted);
    margin-top: 8px;
    font-size: 0.98rem;
}

.specimen-face.back .specimen-word {
    font-size: clamp(1rem, 1.6vw, 1.15rem);
    font-family: var(--font);
    font-weight: 500;
    line-height: 1.5;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ink);
    max-width: 320px;
}

.specimen-hint {
    position: absolute;
    bottom: 14px;
    right: 18px;
    font-size: 0.74rem;
    color: var(--muted);
    letter-spacing: 0.02em;
}

.specimen-stack::before,
.specimen-stack::after {
    content: '';
    position: absolute;
    aspect-ratio: 5 / 3.1;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    width: calc(100% - 28px);
    z-index: 1;
    pointer-events: none;
}

.specimen-stack::before {
    top: 32px;
    left: 24px;
    transform: rotate(3deg);
    opacity: 0.7;
}

.specimen-stack::after {
    top: 40px;
    left: -4px;
    transform: rotate(-4deg);
    opacity: 0.45;
}

@media (max-width: 760px) {
    .hero {
        grid-template-columns: 1fr;
        padding: 36px 20px 10px;
        gap: 26px;
    }
    .specimen { order: 2; }
    .specimen-stack { max-width: 320px; }
}

/* Chat entry-point label (above topic chips in bot greeting) */
.chat-entry-label {
    display: block;
    color: var(--muted);
    font-size: 0.95rem;
    margin: 10px 0 8px;
}

/* Apply Cinzel to doc-page headings for sibling feel */
.page-card h1 {
    font-family: var(--font-display);
    font-weight: 600;
}
.page-card h2 {
    font-family: var(--font-display);
    font-weight: 500;
}

/* Brand name uses Cinzel */
.brand-name {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.01em;
}
