:root {
    --blue: #3099ef;
    --blue-dark: #1978c9;
    --blue-soft: #e8f5ff;
    --teal: #68b92e;
    --teal-soft: #edf9e5;
    --amber: #1978c9;
    --amber-soft: #e8f5ff;
    --rose: #be123c;
    --rose-soft: #ffe4e6;
    --ink: #0f172a;
    --muted: #64748b;
    --subtle: #94a3b8;
    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --page: #f7f9fc;
    --shadow: 0 14px 30px -20px rgb(30 64 175 / 0.28);
    --radius: 14px;
    --container: min(1180px, calc(100vw - 32px));
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    min-height: 100vh;
    color: var(--ink);
    background: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

button,
input { font: inherit; }

button {
    border: 0;
    background: none;
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid #eef2f7;
}

.topbar-inner {
    width: var(--container);
    min-height: 66px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    color: #ffffff;
    background: linear-gradient(135deg, #3099ef, #67c7ff);
    flex: 0 0 auto;
}

.brand-title {
    font-size: 18px;
    font-weight: 850;
    white-space: nowrap;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.nav {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
}

.nav a {
    color: var(--muted);
    border-radius: var(--radius);
    padding: 9px 11px;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.nav a:hover,
.nav a:focus-visible {
    color: var(--blue-dark);
    background: var(--blue-soft);
    outline: none;
}

/* --- ユーザーメニュー（ログイン者表示・ログアウト） ------------------ */
.userbox {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.userbox .who {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
    min-width: 0;
}

.userbox .who .name {
    font-size: 13px;
    font-weight: 850;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.userbox .who .email {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.btn-ghost {
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--muted);
    padding: 7px 11px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.btn-ghost:hover { color: var(--blue-dark); border-color: rgb(37 99 235 / 0.4); }

.btn-admin {
    border: 1px solid rgb(37 99 235 / 0.28);
    border-radius: var(--radius);
    background: var(--blue-soft);
    color: var(--blue-dark);
    padding: 7px 11px;
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
}

.hero {
    width: var(--container);
    margin: 0 auto;
    padding: 38px 0 12px;
    position: relative;
}

.hero::after {
    content: "";
    position: absolute;
    width: 300px;
    height: 225px;
    right: 3%;
    top: 6px;
    border-radius: 12px;
    background: url("../img/portal-illust-top.png") center / contain no-repeat;
    pointer-events: none;
}

.sidebar-col {
    display: block;
    position: sticky;
    top: 82px;
    align-self: start;
}

.sidebar-illust {
    display: block;
    width: 100%;
    height: auto;
    margin-top: 22px;
    border-radius: 12px;
}

@media (max-width: 720px) {
    .hero::after { display: none; }
}

.kicker {
    color: var(--teal);
    font-size: 12px;
    font-weight: 900;
    margin-bottom: 7px;
}

h1 {
    max-width: 13em;
    font-size: clamp(32px, 4vw, 46px);
    line-height: 1.12;
    letter-spacing: 0;
    margin-bottom: 10px;
}

.hero p {
    max-width: 680px;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.8;
}

/* 学習動画への導線（ヘッド付近・目立つ・モバイルでも見える） */
.video-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 13px 22px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3099ef, #55b7f6);
    color: #ffffff;
    font-size: 16px;
    font-weight: 900;
    box-shadow: var(--shadow);
}

.video-cta:hover,
.video-cta:focus-visible { filter: brightness(1.06); outline: none; }

.video-note {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

.stats {
    min-width: 330px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.05);
}

.stat strong {
    display: block;
    font-size: 23px;
    line-height: 1;
}

.stat span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    margin-top: 6px;
    white-space: nowrap;
}

.shell {
    width: var(--container);
    margin: 0 auto 42px;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.panel {
    background: var(--surface);
    border: 1px solid #eef2f7;
    border-radius: 18px;
    box-shadow: 0 16px 36px -26px rgb(30 64 175 / 0.3);
    overflow: hidden;
}

.sidebar {
    position: static;
}

.panel-head {
    padding: 18px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #ffffff, #fbfdff);
}

.panel-title {
    font-size: 18px;
    font-weight: 850;
    margin-bottom: 12px;
}

.search {
    position: relative;
    margin-bottom: 12px;
}

.search svg {
    position: absolute;
    left: 12px;
    top: 50%;
    color: var(--subtle);
    transform: translateY(-50%);
    pointer-events: none;
}

.search input {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--ink);
    outline: none;
    padding: 12px 12px 12px 38px;
    font-size: 15px;
}

.search input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.14);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.chip {
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #ffffff;
    padding: 8px 11px;
    font-size: 13px;
    font-weight: 800;
}

.chip.active {
    color: var(--blue-dark);
    border-color: rgb(37 99 235 / 0.28);
    background: var(--blue-soft);
}

/* --- 学習進捗パネル ---------------------------------------------------- */
.progress-box {
    padding: 14px 16px 16px;
    border-bottom: 1px solid var(--line);
}

.progress-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 9px;
}

.progress-top .pct {
    font-size: 24px;
    font-weight: 900;
    color: var(--blue-dark);
    line-height: 1;
}

.progress-top .label {
    font-size: 12px;
    font-weight: 800;
    color: var(--muted);
}

.progress-bar {
    height: 9px;
    border-radius: 999px;
    background: var(--blue-soft);
    overflow: hidden;
}

.progress-bar > span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--blue), var(--teal));
    transition: width 0.3s ease;
}

.progress-note {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 750;
    color: var(--muted);
}

.guide {
    padding: 14px 16px 16px;
    border-bottom: 1px solid var(--line);
}

.guide-title {
    color: var(--ink);
    font-size: 13px;
    font-weight: 850;
    margin-bottom: 8px;
}

.guide-list {
    color: var(--muted);
    display: grid;
    gap: 7px;
    font-size: 13px;
    list-style: none;
}

.guide-list li {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.guide-list li::before {
    content: "";
    width: 7px;
    height: 7px;
    margin-top: 8px;
    border-radius: 999px;
    background: var(--teal);
    flex: 0 0 auto;
}

.content {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.content-head {
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.content-title {
    font-size: 22px;
    font-weight: 850;
}

.count-pill {
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-soft);
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.sections {
    padding: 18px;
    display: grid;
    gap: 24px;
}

.section {
    border: 0;
    border-radius: 0;
    background: #ffffff;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 2px 12px;
    background: #fff;
    border-bottom: 0;
    border-radius: 13px;
    padding: 12px 15px;
}

.section-name {
    font-size: 18px;
    font-weight: 850;
}

.section.tone-blue .section-head { background: #2f9cf4; color: #fff; }
.section.tone-orange .section-head { background: #ff8b2c; color: #fff; }
.section.tone-green .section-head { background: #7fc832; color: #fff; }
.section.tone-yellow .section-head { background: #ffd13d; color: #493a00; }
.section.tone-blue .section-meta,
.section.tone-orange .section-meta,
.section.tone-green .section-meta { color: rgb(255 255 255 / 0.88); }
.section.tone-yellow .section-meta { color: rgb(73 58 0 / 0.78); }

.section-meta {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 16px 0 0;
}

.card {
    min-height: 132px;
    min-width: 0;
    border: 0;
    border-radius: 17px;
    background: #ffffff;
    padding: 14px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 11px;
    box-shadow: 0 13px 26px -20px rgb(15 23 42 / 0.42);
    overflow: hidden;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 32px -20px rgb(15 23 42 / 0.45);
}

.card.tone-blue,
.card.tone-orange,
.card.tone-green,
.card.tone-yellow { background: #fff; color: var(--ink); }
.card.tone-blue { border-top: 5px solid #2f9cf4; }
.card.tone-orange { border-top: 5px solid #ff8b2c; }
.card.tone-green { border-top: 5px solid #7fc832; }
.card.tone-yellow { border-top: 5px solid #ffd13d; }
.card .audience,
.card .done-toggle { color: var(--muted); }
.card .file-size { color: var(--subtle); }

/* 完成見本サムネイル: カード上辺いっぱいに 16:10 で表示（padding を打ち消す全幅）。
   グリッド内でも画像の固有幅に引っ張られないよう、枠幅をカード幅に明示固定する。 */
.card-thumb {
    margin: -14px -14px 0;
    width: calc(100% + 28px);
    min-width: 0;
    justify-self: start;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: #ffffff;
    border-bottom: 0;
    border-radius: 17px 17px 0 0;
}

.card-thumb img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 100%;
    min-width: 0;
    object-fit: contain;
}

/* 完了済みカードの視覚フィードバック */
.card.is-done {
    border-color: rgb(15 118 110 / 0.4);
    background: linear-gradient(180deg, #ffffff, var(--teal-soft));
}

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
    color: #475569;
    background: #f1f5f9;
}

.badge.docx,
.badge.pdf,
.badge.xlsx,
.badge.txt { color: #475569; background: #f1f5f9; }

.audience {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.card h3 {
    font-size: 17px;
    line-height: 1.5;
    letter-spacing: 0;
    font-weight: 850;
    overflow-wrap: anywhere;
}

.path {
    display: none;
}

/* 教材カードの一言メモ（例: 実証レポート「よかったらお役立てください」） */
.card-note {
    margin-top: 6px;
    color: #475569;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.45;
}

.card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.open-link {
    min-height: 40px;
    border-radius: var(--radius);
    background: #145fa8;
    color: #ffffff;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 850;
}

.card.tone-blue .open-link { background: #2f9cf4; }
.card.tone-orange .open-link { background: #ff8b2c; }
.card.tone-green .open-link { background: #69b828; }
.card.tone-yellow .open-link { background: #e3aa00; }

/* ドリルでは Word 作業を最優先にし、PDF は副導線にする。 */
.card.is-drill .open-link {
    background: #fff;
    color: var(--ink);
}
.card.is-drill.tone-blue .open-link { border: 1px solid #2f9cf4; color: #1978c9; }
.card.is-drill.tone-orange .open-link { border: 1px solid #ff8b2c; color: #c95b0b; }
.card.is-drill.tone-green .open-link { border: 1px solid #7fc832; color: #4c921f; }
.card.is-drill.tone-yellow .open-link { border: 1px solid #e3aa00; color: #8c6900; }

.open-link:hover,
.open-link:focus-visible {
    background: var(--blue-dark);
    outline: none;
}

.file-size {
    color: var(--subtle);
    font-size: 11px;
    font-weight: 750;
    white-space: nowrap;
}

/* 副導線（Wordで作業 / 本文を見る）。PDFを開く(open-link)とは別の控えめなボタン。 */
.act-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--line-strong);
    background: #ffffff;
    color: var(--ink);
    padding: 0 12px;
    font-size: 13px;
    font-weight: 850;
}

.card.tone-blue .act-link { border-color: #2f9cf4; color: #1978c9; }
.card.tone-orange .act-link { border-color: #ff8b2c; color: #c95b0b; }
.card.tone-green .act-link { border-color: #7fc832; color: #4c921f; }
.card.tone-yellow .act-link { border-color: #e3aa00; color: #8c6900; }

.card.tone-blue .word-link { background: #2f9cf4; border-color: #2f9cf4; color: #fff; }
.card.tone-orange .word-link { background: #ff8b2c; border-color: #ff8b2c; color: #fff; }
.card.tone-green .word-link { background: #69b828; border-color: #69b828; color: #fff; }
.card.tone-yellow .word-link { background: #e3aa00; border-color: #e3aa00; color: #fff; }

.act-link:hover,
.act-link:focus-visible {
    border-color: rgb(37 99 235 / 0.4);
    background: var(--blue-soft);
    outline: none;
}

.card.tone-blue .word-link:hover { background: #1978c9; border-color: #1978c9; }
.card.tone-orange .word-link:hover { background: #d96812; border-color: #d96812; }
.card.tone-green .word-link:hover { background: #4c921f; border-color: #4c921f; }
.card.tone-yellow .word-link:hover { background: #a97f00; border-color: #a97f00; }

/* 導線を左に寄せ、サイズ表示は右端へ */
.card-actions .file-size { margin-left: auto; }

/* 職員向けドリル上の利用者向け注意書き */
.staff-notice {
    border: 1px solid rgb(48 153 239 / 0.25);
    background: var(--blue-soft);
    color: var(--ink);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.75;
}

.staff-notice strong { font-weight: 900; color: var(--blue-dark); }

/* 完了チェック */
.done-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 800;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}

.done-toggle input {
    width: 18px;
    height: 18px;
    accent-color: var(--teal);
    cursor: pointer;
    background: #fff;
}

.done-toggle.checked { color: var(--teal); }

.empty {
    display: none;
    color: var(--muted);
    text-align: center;
    padding: 44px 20px;
    font-size: 14px;
    font-weight: 750;
}

.footer {
    width: var(--container);
    margin: 0 auto;
    padding: 0 0 34px;
    color: var(--subtle);
    text-align: center;
    font-size: 12px;
}

@media (max-width: 980px) {
    .hero,
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        top: auto;
    }

    .sidebar-col {
        position: static;
        top: auto;
    }
}

@media (max-width: 720px) {
    :root { --container: min(100vw - 22px, 1180px); }

    .topbar-inner {
        min-height: 0;
        flex-direction: column;
        align-items: flex-start;
        padding: 12px 0;
        gap: 8px;
    }

    .brand-title { font-size: 16px; white-space: normal; }
    .nav { width: 100%; padding-bottom: 2px; }
    .userbox { width: 100%; justify-content: space-between; }
    .hero { padding-top: 26px; }
    .stats { min-width: 0; width: 100%; }
    .cards { grid-template-columns: 1fr; }
    .content-head { align-items: flex-start; flex-direction: column; }
}

/* ===== ドリル動画: 再生ボタン / 準備中 / モーダル ===== */
.act-link.video-play,
.ac-open.video-play {
    color: #ffffff;
    background: var(--blue);
    border-color: var(--blue);
    cursor: pointer;
}
.act-link.video-play:hover,
.ac-open.video-play:hover {
    background: var(--blue-dark);
    border-color: var(--blue-dark);
}

/* 動画ボタンもカードのカテゴリ色へ統一する。 */
.card.tone-blue .act-link.video-play { background: #fff; border-color: #2f9cf4; color: #1978c9; }
.card.tone-orange .act-link.video-play { background: #fff; border-color: #ff8b2c; color: #c95b0b; }
.card.tone-green .act-link.video-play { background: #fff; border-color: #7fc832; color: #4c921f; }
.card.tone-yellow .act-link.video-play { background: #fff; border-color: #e3aa00; color: #8c6900; }

/* 動画が無いドリルの無効ボタン */
.act-link.is-disabled,
.ac-open.is-disabled {
    color: var(--subtle);
    background: var(--surface-soft);
    border-color: var(--line);
    cursor: not-allowed;
    pointer-events: none;
}

body.modal-open { overflow: hidden; }

.video-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgb(15 23 42 / 0.72);
}
.video-modal.is-open { display: flex; }

.video-modal-box {
    width: min(960px, 100%);
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.video-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: #0f172a;
    color: #fff;
}
.video-modal-title {
    font-size: 14px;
    font-weight: 850;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.video-modal-close {
    flex: none;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: rgb(255 255 255 / 0.12);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.video-modal-close:hover { background: rgb(255 255 255 / 0.24); }
.video-modal-player {
    display: block;
    width: 100%;
    max-height: 78vh;
    background: #000;
}

/* ===== カスタムチャット初級ドリル: 動画ライブラリ案内バナー ===== */
.video-lib-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 0 12px;
    padding: 12px 14px;
    border: 1px solid rgb(37 99 235 / 0.28);
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--blue-soft), #ffffff);
}
.video-lib-text {
    font-size: 13px;
    font-weight: 850;
    color: var(--blue-dark);
    line-height: 1.5;
}
.video-lib-link {
    flex: none;
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 16px;
    border-radius: var(--radius);
    background: var(--blue);
    color: #ffffff;
    font-size: 13px;
    font-weight: 850;
    white-space: nowrap;
}
.video-lib-link:hover,
.video-lib-link:focus-visible {
    background: var(--blue-dark);
    outline: none;
}

.section.tone-green .video-lib-banner {
    border-color: rgb(105 184 40 / 0.35);
    background: #ffffff;
}
.section.tone-green .video-lib-text { color: #4c921f; }
.section.tone-green .video-lib-link { background: #69b828; }
.section.tone-green .video-lib-link:hover,
.section.tone-green .video-lib-link:focus-visible { background: #4c921f; }
