/* AI Learning Base — 全站統一主題（對齊 index.html） */
:root {
    --brand: #6366F1;
    --brand-dark: #4f46e5;
    --brand-light: #818cf8;
    --bg-dark: #0f172a;
    --card-bg: #ffffff;
    --soft: rgba(99, 102, 241, .12);
    --stroke: rgba(99, 102, 241, .18);
    --stroke-light: rgba(226, 232, 240, .9);
    --text: #0f172a;
    --weak: #64748b;
    --shadow: 0 12px 40px rgba(15, 23, 42, .12);
    --radius-xl: 22px;
    --radius-lg: 16px;
    --radius-md: 14px;
    --header-h: 52px;
    /* 兼容舊變量名 */
    --bg: #f8fafc;
    --card1: #ffffff;
    --card2: #ffffff;
    --text-weak: #64748b;
    --accent: #6366F1;
    --accent1: #6366F1;
    --accent2: #818cf8;
    --primary1: #6366F1;
    --primary2: #818cf8;
    --cyan: #6366F1;
    --mint: #6366F1;
    --mint2: #818cf8;
    --panel: #ffffff;
    --border: rgba(226, 232, 240, .9);
    --muted: #64748b;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    background:
        radial-gradient(900px 700px at 90% -5%, rgba(99, 102, 241, .35), transparent 55%),
        radial-gradient(700px 600px at 0% 30%, rgba(139, 92, 246, .22), transparent 50%),
        linear-gradient(180deg, #0f172a 0%, #1e293b 22%, #334155 32%, #eef2ff 42%, #f8fafc 100%);
    background-attachment: fixed;
    -webkit-tap-highlight-color: transparent;
}

/* 主容器 */
.page,
.wrap {
    min-height: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: calc(10px + env(safe-area-inset-top)) 16px calc(80px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: transparent;
}

.page-nobottom {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

/* 浮動膠囊頂欄 */
.topbar,
.top {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px 0 12px;
    background: rgba(255, 255, 255, .92);
    border-radius: 999px;
    box-shadow: 0 8px 32px rgba(15, 23, 42, .18), 0 0 0 1px rgba(255, 255, 255, .6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 8px;
    z-index: 40;
    flex-shrink: 0;
}

.topbar .title,
.topbar .tb-title,
.top .title,
.topbar h1 {
    flex: 1;
    text-align: center;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: .06em;
    color: var(--text);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar .group { display: flex; align-items: center; gap: 10px; flex: 1; }
.topbar .group .title { text-align: left; }

.back,
.tb-btn,
.iconbtn,
.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    background: var(--soft);
    border: 1px solid var(--stroke);
    color: var(--text);
    text-decoration: none;
    font-size: 18px;
    flex-shrink: 0;
    padding: 0;
}

.back svg,
.tb-btn svg,
.iconbtn svg,
.btn-icon svg {
    fill: var(--brand);
    width: 18px;
    height: 18px;
}

.bell {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--soft);
    border: 1px solid var(--stroke);
    cursor: pointer;
}

.bell svg { fill: var(--brand); }

.badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px #fff;
}

/* 卡片 */
.card,
.panel {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    border: 1px solid var(--stroke-light);
    padding: 14px 16px;
}

.card h3,
.panel h3 {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: .04em;
    color: var(--text);
}

/* 區塊標題 */
.block-head,
.section-title {
    margin: 0;
    padding: 16px 18px;
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--shadow);
    border: 1px solid var(--stroke-light);
    border-left: 4px solid var(--brand);
}

.block-head h3,
.section-title h3 {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: .04em;
    color: var(--text);
}

.block-head p,
.section-title h4 {
    margin: 0;
    font-size: 13px;
    line-height: 1.55;
    color: var(--weak);
    font-weight: 500;
}

.desc {
    margin: 0;
    color: var(--weak);
    line-height: 1.65;
    font-size: 14px;
}

/* 按鈕 */
.btn,
button.btn-primary,
.detail-close {
    height: 48px;
    padding: 0 16px;
    border: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    font-weight: 800;
    letter-spacing: .06em;
    cursor: pointer;
    font-size: 15px;
    box-shadow: 0 8px 24px rgba(99, 102, 241, .3);
    transition: transform .1s, box-shadow .2s;
}

.btn:active,
.detail-close:active {
    transform: translateY(1px);
}

.btn.ghost,
.btn-ghost {
    background: #fff;
    color: var(--brand);
    border: 2px solid var(--brand);
    box-shadow: none;
}

.btn.primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
}

/* 模式切換 */
.mode-switch {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 0 auto 12px;
    padding: 4px;
    border-radius: 999px;
    background: var(--soft);
    border: 1px solid var(--stroke);
    max-width: 280px;
}

.mode-btn {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 999px;
    border: 0;
    background: transparent;
    color: var(--weak);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    cursor: pointer;
    white-space: nowrap;
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--brand), var(--brand-light));
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, .3);
}

/* 表格 */
.table {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--stroke-light);
    background: #fff;
}

.thead {
    background: var(--soft);
}

.tbody .row:nth-child(odd) {
    background: rgba(99, 102, 241, .03);
}

.tbody .row + .row {
    border-top: 1px solid rgba(226, 232, 240, .8);
}

.row.clickable:hover {
    background: rgba(99, 102, 241, .08);
}

/* 進度條 */
.prog {
    height: 8px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.prog > i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--brand), var(--brand-light));
    transition: width .35s ease;
}

/* 表單 */
.input,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="tel"],
select,
textarea {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    font-size: 16px;
    color: var(--text);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

textarea {
    height: auto;
    min-height: 80px;
    padding: 12px 14px;
}

.input:focus,
input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .12);
}

label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--weak);
    margin-bottom: 6px;
    letter-spacing: .04em;
}

/* 彈窗 */
.detail-mask {
    position: fixed;
    inset: 0;
    z-index: 120;
    background: rgba(15, 23, 42, .4);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-modal {
    width: min(90vw, 360px);
    border-radius: 20px;
    padding: 18px 18px 16px;
    background: #fff;
    border: 1px solid var(--stroke-light);
    box-shadow: var(--shadow);
    color: var(--text);
    font-size: 14px;
}

.detail-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: .06em;
    margin-bottom: 12px;
    text-align: center;
    color: var(--text);
}

.detail-close {
    min-width: 120px;
    height: 44px;
    font-size: 14px;
}

/* Hero 深色區（me 等頁可用） */
.hero-inner {
    background: linear-gradient(145deg, #1e1b4b 0%, #312e81 45%, #4338ca 100%);
    border-radius: 24px;
    padding: 20px 18px;
    color: #fff;
    box-shadow: 0 20px 50px rgba(49, 46, 129, .45);
    position: relative;
    overflow: hidden;
}

.spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(99, 102, 241, .2);
    border-top-color: var(--brand);
    animation: app-spin .9s linear infinite;
}

@keyframes app-spin {
    to { transform: rotate(360deg); }
}

.hidden { display: none !important; }
