/* 新首页 preview (App\Support\HomePreview, e537w28 only): partials/home-preview/{study,chat,switch}.
   Quiet and warm like the rest of Cerdek: off-white page, white cards with hairlines, one orange accent,
   no gradients. Light mode only for now (dark.css isn't regenerated for a one-account preview). */

.hp { --hp-ink: #1f1d1a; --hp-soft: #6b6760; --hp-line: #ebe7e1; --hp-card: #ffffff; --hp-accent: #f26a1b; --hp-accent-soft: #fff1e6;
    width: 100%; max-width: 640px; margin: 0 auto; padding: 8px 4px 24px; color: var(--hp-ink); }
.page-chat .chat-hero.hp-on { justify-content: flex-start; padding-top: 18px; }

/* ---------- the switch bar ---------- */
.hp-switch { position: fixed; top: 10px; left: 50%; z-index: 30; display: flex; gap: 2px; padding: 3px; border: 1px solid var(--border, #e3e4e8);
    border-radius: 999px; background: rgba(255, 255, 255, 0.92); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06); transform: translateX(-50%); font-size: 12.5px; }
.hp-switch a { padding: 5px 11px; border-radius: 999px; color: #6b6760; font-weight: 600; text-decoration: none; white-space: nowrap; }
.hp-switch a.is-on { background: #1f1d1a; color: #fff; }
@media (min-width: 721px) { .hp-switch { left: calc(50% + 130px); } }

/* ---------- A · 学习首页 ---------- */
.hp-hello { margin: 0 0 4px; color: var(--hp-soft); font-size: 15px; font-weight: 500; }
.hp-title { margin: 0 0 18px; font-size: 28px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.hp-h2 { margin: 26px 0 10px; color: var(--hp-soft); font-size: 13px; font-weight: 700; }

.hp-exam { display: flex; align-items: center; gap: 16px; padding: 16px 16px 16px 18px; border: 1px solid var(--hp-line); border-radius: 18px;
    background: var(--hp-card); color: inherit; text-decoration: none; transition: border-color 0.15s, transform 0.15s; }
.hp-exam:hover { border-color: #ddd6cd; }
.hp-exam:active { transform: scale(0.99); }
.hp-exam-count { display: flex; flex: none; flex-direction: column; align-items: center; justify-content: center; width: 72px; height: 72px; border-radius: 16px; background: var(--hp-accent-soft); color: #c2540f; }
.hp-exam-count b { font-size: 30px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.hp-exam-count b.is-word { font-size: 20px; }
.hp-exam-count small { margin-top: 3px; font-size: 11.5px; font-weight: 700; }
.hp-exam-body { display: flex; flex: 1; flex-direction: column; gap: 3px; min-width: 0; }
.hp-kicker { color: var(--hp-soft); font-size: 12.5px; font-weight: 600; }
.hp-exam-body strong { font-size: 17px; font-weight: 700; line-height: 1.3; }
.hp-exam-papers { overflow: hidden; color: var(--hp-soft); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.hp-chev { flex: none; color: #b9b3aa; }
.hp-exam-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 2px 0; color: var(--hp-soft); font-size: 13px; }
.hp-link { display: inline-flex; align-items: center; gap: 4px; color: #c2540f; font-weight: 700; text-decoration: none; }
.hp-link .material-symbols-outlined { --icon-size: 17px; font-size: 17px; }

.hp-list { display: flex; flex-direction: column; gap: 8px; }
.hp-continue { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--hp-line); border-radius: 16px; background: var(--hp-card); color: inherit; text-decoration: none; }
.hp-continue-text { display: flex; flex: 1; flex-direction: column; gap: 4px; min-width: 0; }
.hp-continue-text strong { overflow: hidden; font-size: 15px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.hp-continue-text small { color: var(--hp-soft); font-size: 12.5px; }
.hp-bar { display: block; height: 4px; margin-top: 4px; overflow: hidden; border-radius: 4px; background: #f1ede8; }
.hp-bar i { display: block; height: 100%; border-radius: 4px; background: var(--hp-accent); }
.hp-go { flex: none; padding: 7px 14px; border-radius: 999px; background: #1f1d1a; color: #fff; font-size: 13px; font-weight: 700; }

.hp-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hp-tile { display: flex; flex-direction: column; gap: 2px; padding: 14px; border: 1px solid var(--hp-line); border-radius: 16px; background: var(--hp-card); color: inherit; text-decoration: none; transition: border-color 0.15s, transform 0.15s; }
.hp-tile:hover { border-color: #ddd6cd; }
.hp-tile:active { transform: scale(0.98); }
.hp-ico { display: grid; place-items: center; width: 38px; height: 38px; margin-bottom: 8px; border-radius: 12px; --icon-size: 21px; font-size: 21px; }
.hp-ico.is-paper { background: #fff1e6; color: #c2540f; }
.hp-ico.is-speak { background: #eaf3ff; color: #2d63b8; }
.hp-ico.is-listen { background: #eef7ee; color: #2f7a3e; }
.hp-ico.is-essay { background: #f5effb; color: #6c46a6; }
.hp-tile strong { font-size: 15px; font-weight: 700; }
.hp-tile small { color: var(--hp-soft); font-size: 12.5px; }

.hp-streak { display: flex; align-items: center; gap: 6px; margin: 18px 2px 0; color: #c2540f; font-size: 13.5px; font-weight: 700; }
.hp-streak .material-symbols-outlined { --icon-size: 19px; font-size: 19px; }
.hp-ask-hint { margin: 22px 2px 0; color: #a39d94; font-size: 13px; text-align: center; }

/* ---------- B · 聊天首页精修版 ---------- */
.hp-chat { display: flex; flex-direction: column; align-items: center; text-align: center; }
.hp-ava { display: grid; place-items: center; width: 72px; height: 72px; margin: 8px 0 14px; overflow: hidden; border-radius: 50%; background: var(--tint, #ffe3c4); font-size: 34px; text-decoration: none; }
.hp-ava img { width: 100%; height: 100%; object-fit: cover; }
.hp-chat-title { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
.hp-chat-sub { margin: 6px 0 0; color: var(--hp-soft); font-size: 14.5px; }
.hp-input-slot { width: 100%; height: 0; }
.hp-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.hp-tool { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border: 1px solid var(--hp-line); border-radius: 999px; background: var(--hp-card);
    color: var(--hp-ink); font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; transition: border-color 0.15s, background-color 0.15s; }
.hp-tool:hover { border-color: #ddd6cd; background: #fdfcfb; }
.hp-tool .material-symbols-outlined { --icon-size: 18px; font-size: 18px; color: #c2540f; }
.hp-section { width: 100%; margin-top: 28px; text-align: left; }
.hp-label { margin: 0 0 8px 4px; color: var(--hp-soft); font-size: 13px; font-weight: 700; }
.hp-try, .hp-recent { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--hp-line); border-radius: 16px; background: var(--hp-card); }
.page-chat .hp-try .hp-try-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; max-width: none; margin: 0; padding: 13px 16px; border: 0; border-radius: 0;
    background: transparent; color: var(--hp-ink); font: inherit; font-size: 14.5px; text-align: left; cursor: pointer; box-shadow: none; }
.page-chat .hp-try .hp-try-item + .hp-try-item, .hp-recent-item + .hp-recent-item { border-top: 1px solid #f2eee9; }
.page-chat .hp-try .hp-try-item:hover, .hp-recent-item:hover { background: #fbfaf8; }
.hp-try-item .material-symbols-outlined { flex: none; color: #b9b3aa; --icon-size: 18px; font-size: 18px; }
.hp-recent-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--hp-ink); text-decoration: none; font-size: 14.5px; }
.hp-recent-item .material-symbols-outlined { flex: none; color: #b9b3aa; --icon-size: 18px; font-size: 18px; }
.hp-recent-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hp-recent-item small { flex: none; color: #a39d94; font-size: 12px; }

/* Wide screens, B: the box sits under the title while the page is empty, then slides down to the bottom. */
@media (min-width: 901px) {
    body.hp-variant-chat .hp-input-slot { height: 128px; margin-top: 22px; }
    body.hp-variant-chat .chat-input-area { transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.2s; }
    body.hp-variant-chat.hp-lifted .chat-input-area { background: transparent; }
}
@media (prefers-reduced-motion: reduce) { body.hp-variant-chat .chat-input-area { transition: none; } }
.page-chat .hp-try .hp-try-item > span:first-child { flex: 1; min-width: 0; }
@media (min-width: 901px) { .hp-tiles { grid-template-columns: repeat(4, 1fr); } }

/* ---------- C · App 布局 (owner's reference layout) ---------- */
/* All white. While the home is showing, the page scroll snaps between two places: the top (cards + entries) and the
   AI helper card, which then fills the screen as the chat page (js/home-preview.js sets its height and eases its
   corners / the cards as it rises). Once a conversation starts the snapping goes. */
body.hp-variant-app .chat-main { background: #fff; }
body.hp-variant-app:not(.hp-hero-off) .chat-scroll { padding: 0; scroll-snap-type: y mandatory; overscroll-behavior-y: contain; }
body.hp-variant-app .chat-hero.hp-on { padding: 0; }
.hp-app { max-width: 680px; padding: 0; }
.hpa-top { padding-top: 4px; scroll-snap-align: start; }
.hpa-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; padding: 0 16px; }
.hpa-card { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 3px 12px; border: 0; border-radius: 20px; color: #2a2733; font: inherit; font-size: 14.5px; font-weight: 700; text-decoration: none; cursor: pointer; transition: transform 0.15s; }
.hpa-card:active { transform: scale(0.96); }
.hpa-card-ico { display: block; width: 50px; height: 50px; margin: 5px 0 4px; }
.hpa-card-ico svg { display: block; width: 100%; height: 100%; }
/* One line per name in every language; js/home-preview.js shrinks it (down to 11px) when it still doesn't fit. */
.hpa-card-name { display: block; max-width: 100%; padding: 0; overflow: hidden; font-size: 14.5px; line-height: 1.25; white-space: nowrap; text-overflow: clip; }
.hpa-card.is-blue { background: #e9f1ff; }
.hpa-card.is-red { background: #fff0ea; }
.hpa-card.is-teal { background: #e5f7f3; }
.hpa-card.is-gold { background: #fff5dc; }

.hpa-entries { display: flex; margin-top: 16px; padding: 0; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.hpa-entries::-webkit-scrollbar { display: none; }
.hpa-page { display: flex; box-sizing: border-box; flex: 0 0 100%; justify-content: space-between; gap: 4px;
    /* Same side padding as the four cards: the first entry starts where the first card starts, the last ends where
       the last card ends, the rest spread evenly between. */
    padding: 0 16px; }
.hpa-page a, .hpa-page button { flex: 0 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0; border: 0; background: none; color: #3a3640; font: inherit; font-size: 13px; text-decoration: none; cursor: pointer; }
.hpa-page .material-symbols-outlined { --icon-size: 28px; font-size: 28px; color: #2a2733; }
.hpa-dots { display: flex; justify-content: center; gap: 4px; margin: 10px 0 0; }
.hpa-dots i { width: 6px; height: 4px; border-radius: 4px; background: #e2ddd6; transition: width 0.2s, background-color 0.2s; }
.hpa-dots i.is-on { width: 14px; background: #f26a1b; }

.hpa-helper { --p: 0; margin: 18px 0 0; padding: 20px 22px 200px; border-radius: calc(26px * (1 - var(--p))) calc(26px * (1 - var(--p))) 0 0; background: #fff;
    box-shadow: 0 -6px 22px rgba(31, 29, 26, calc(0.035 * (1 - var(--p)))), 0 -1px 0 rgba(31, 29, 26, calc(0.025 * (1 - var(--p)))); text-align: left; scroll-snap-align: start; }
/* As the card rises the cards and entries behind it sink back a little and fade. */
.hpa-top { opacity: calc(1 - 0.5 * var(--hpa-p, 0)); transform: translateY(calc(18px * var(--hpa-p, 0))) scale(calc(1 - 0.03 * var(--hpa-p, 0))); transform-origin: 50% 0; }
.hpa-hello { display: flex; align-items: center; gap: 12px; }
.hpa-ava { display: grid; flex: none; place-items: center; width: 40px; height: 40px; overflow: hidden; border-radius: 50%; background: var(--tint, #ffe3c4); font-size: 22px; text-decoration: none; object-fit: cover; }
.hpa-ava img { width: 100%; height: 100%; object-fit: cover; }
.hpa-line { margin: 0; font-size: 16.5px; font-weight: 500; line-height: 1.45; color: #2a2733; }
.hpa-qs { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 18px; }
.hpa-q { max-width: 100%; padding: 10px 16px; border: 0; border-radius: 14px; background: #f4f3f1; color: #2a2733; font: inherit; font-size: 15px; text-align: left; cursor: pointer; animation: hpaIn 0.3s ease both; }
.hpa-q:hover { background: #eeece9; }
@keyframes hpaIn { from { opacity: 0; transform: translateY(4px); } }

/* The quick tools above the chat box, and the box itself as a soft floating pill. */
body.hp-variant-app .chat-input-area { flex-direction: column; align-items: center; background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff 30%); }
@media (prefers-reduced-motion: reduce) { .hpa-q { animation: none; } }

/* Phones: the helper card is a full-width sheet, as in the layout. */
@media (max-width: 720px) {
    .hpa-cards { gap: 6px; padding: 0 16px; }
    .hpa-card { border-radius: 18px; }
    .hp-switch { font-size: 12px; }
    .hp-switch a { padding: 5px 9px; }
}
/* The home cards have no scrollbar gutter: .chat-scroll keeps `scrollbar-gutter: stable` (theme.css), which on
   browsers with classic scrollbars added 8px on the right only — the cards sat closer to the left edge. */
body.hp-variant-app:not(.hp-hero-off) .chat-scroll { scrollbar-gutter: auto; scrollbar-width: none; }
body.hp-variant-app:not(.hp-hero-off) .chat-scroll::-webkit-scrollbar { display: none; width: 0; }

/* 金刚区: five entries in one row, names on one line. */
.hpa-entries { overflow: visible; }
.hpa-entry-name { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; }

/* English and Malay names are longer: a size smaller to start with (the fit then rarely has to shrink them). */
.hpa-card-name:lang(en), .hpa-card-name:lang(ms) { font-size: 12.5px; letter-spacing: -0.005em; }
.hpa-entry-name:lang(en), .hpa-entry-name:lang(ms) { font-size: 12px; }

/* Names may take two lines (never more). If one name in a row needs two, the whole row reserves two, so the
   cards stay the same height and the names line up (js/home-preview.js sets .is-two). */
.hpa-card-name, .hpa-entry-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
    overflow: hidden; white-space: normal; line-height: 1.25; text-align: center; word-break: keep-all; overflow-wrap: normal; }
.hpa-cards.is-two .hpa-card-name, .hpa-page.is-two .hpa-entry-name { display: flex; align-items: center; justify-content: center; min-height: 2.5em; white-space: pre-line; }

/* Quick tools above the chat box (partials/home-preview/app-dock; owner kept them 2026-11-21). */
.hpa-dock { display: flex; gap: 5px; width: 100%; max-width: 640px; margin: 0 auto 10px; padding: 0 2px; overflow-x: auto; scrollbar-width: none; }
.hpa-dock::-webkit-scrollbar { display: none; }
.hpa-chip { display: inline-flex; flex: none; align-items: center; gap: 3px; height: 36px; padding: 0 8px; border: 0; border-radius: 12px; background: #f4f3f1; color: #2a2733; font: inherit; font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer; transition: filter 0.15s, transform 0.15s; }
.hpa-chip:active { transform: scale(0.97); }
.hpa-chip:hover { filter: brightness(0.97); }
.hpa-chip .material-symbols-outlined { --icon-size: 15px; font-size: 15px; }
/* Macaron colours, one per tool (pastel fill, the same hue deeper for the text and icon). */
/* Grey-white capsules (owner 2026-11-21: 改成灰白), like the old suggested-question pills. */
.hpa-tools .hpa-chip { background: #f4f3f1; color: #2a2733; font-weight: 500; }
.hpa-tools .hpa-chip:hover { background: #eeece9; filter: none; }
.hpa-tools .hpa-chip .material-symbols-outlined { color: #7a7480; }
body.hp-variant-app.hp-hero-off .hpa-dock { display: none; }

/* Swipe-up hint at the top of the chat card: the sheet's grip only (owner: no words), gone once the card is up. */
.hpa-helper { padding-top: 8px; }
.hpa-swipe { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; margin: 0 0 14px; padding: 2px 0 8px; border: 0; background: none;
    color: #a29c93; font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; opacity: max(0, calc(1 - 2.5 * var(--p))); -webkit-tap-highlight-color: transparent; }
.hpa-swipe-grip { width: 38px; height: 4px; border-radius: 999px; background: #e4e0da; }
body.hpa-up .hpa-swipe { visibility: hidden; }

/* ---------- Loading: the first screen paints at once; what arrives later has a skeleton ---------- */
/* Icons keep their final box from the start (before the font is in, an icon is an invisible word as wide as its name,
   and the row would jump when it arrives) … */
body.hp-variant-app .hpa-page .material-symbols-outlined { width: 28px; height: 28px; overflow: hidden; }
body.hp-variant-app .hpa-chip .material-symbols-outlined { width: 18px; height: 18px; overflow: hidden; }
body.hp-variant-app .chat-header .material-symbols-outlined { width: 24px; height: 24px; overflow: hidden; }
/* … and while the icon font loads (html.ms-wait, set in chat.blade.php) they shimmer as skeleton blocks. */
.ms-wait body.hp-variant-app .hpa-page .material-symbols-outlined,
.ms-wait body.hp-variant-app .hpa-chip .material-symbols-outlined,
.ms-wait body.hp-variant-app .chat-header .material-symbols-outlined {
    border-radius: 8px; background: #efede9; } /* still placeholders, no sweeping shimmer (owner: 不要波纹) */
.ms-wait body.hp-variant-app .hpa-chip .material-symbols-outlined { border-radius: 4px; background: rgba(255, 255, 255, 0.6); animation: none; }
/* The persona picture fades in over its tinted circle. */
.hpa-ava img { opacity: 0; transition: opacity 0.25s ease; }
.hpa-ava img.is-in { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .ms-wait body.hp-variant-app .material-symbols-outlined, .hpa-ava { animation: none !important; } }

/* Quick tools as capsules under the line (like the old suggested questions), side by side, wrapping when needed. */
.hpa-tools { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-top: 18px; } /* one line; wraps only when it must */
.hpa-tools .hpa-chip { height: auto; gap: 8px; padding: 10px 16px; border-radius: 14px; font-size: 15px; animation: hpaIn 0.3s ease both; }
.hpa-tools .hpa-chip .material-symbols-outlined { --icon-size: 18px; font-size: 18px; }
.hpa-tools + .hpa-qs { margin-top: 8px; }
.hpa-tools + .hpa-qs .hpa-q { font-weight: 500; }

/* ---------- 深色模式 (dark_mode_open: every signed-in student can pick it) ---------- */
:root[data-theme="dark"] body.hp-variant-app .chat-main { background: #141414; }
:root[data-theme="dark"] .hpa-card { color: #ecebf0; }
:root[data-theme="dark"] .hpa-card.is-gold { background: #2c2516; }
:root[data-theme="dark"] .hpa-card.is-red { background: #2e1f1a; }
:root[data-theme="dark"] .hpa-card.is-teal { background: #15291f; }
:root[data-theme="dark"] .hpa-card.is-blue { background: #182235; }
:root[data-theme="dark"] .hpa-page a, :root[data-theme="dark"] .hpa-page button { color: #c4c8d0; }
:root[data-theme="dark"] .hpa-page .material-symbols-outlined { color: #e6e8ee; }
:root[data-theme="dark"] .hpa-helper { background: #1c1c1d; box-shadow: 0 -1px 0 rgba(255, 255, 255, calc(0.06 * (1 - var(--p)))); }
:root[data-theme="dark"] .hpa-swipe-grip { background: #3a3a3e; }
:root[data-theme="dark"] .hpa-line { color: #e6e8ee; }
:root[data-theme="dark"] .hpa-q, :root[data-theme="dark"] .hpa-tools .hpa-chip { background: #29292c; color: #e6e8ee; }
:root[data-theme="dark"] .hpa-q:hover, :root[data-theme="dark"] .hpa-tools .hpa-chip:hover { background: #313135; }
:root[data-theme="dark"] .hpa-tools .hpa-chip .material-symbols-outlined { color: #a1a9b8; }
:root[data-theme="dark"] body.hp-variant-app .chat-input-area { background: linear-gradient(to bottom, rgba(28, 28, 29, 0), #1c1c1d 30%); }
:root[data-theme="dark"] .hpa-dots i { background: #3a3a3e; }
.ms-wait:root[data-theme="dark"] body.hp-variant-app .material-symbols-outlined { background: #262624; }

/* The new home's heading: there for search engines and screen readers only. */
.hpa-h1 { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
