:root {
    --green: #2e8b57;
    --green-dark: #246c44;
    --orange: #f0932b;
    --ink: #2d3436;
    --muted: #7b8794;
    --line: #e3e8ee;
    --bg: #f5f7fa;
    --danger: #c0392b;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
        "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.7;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 20px; }

/* ===== Public header ===== */
.site-header {
    background: #fff;
    border-bottom: 3px solid var(--green);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    flex-wrap: wrap;
    gap: 8px;
}
.brand { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
.brand-name { font-size: 20px; font-weight: 700; color: var(--green); letter-spacing: .02em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.brand-link { color: var(--green-dark); text-decoration: none; font-size: 14px; font-weight: 600; }
.brand-link:hover { text-decoration: underline; }

/* ===== Main ===== */
.main { flex: 1; padding: 32px 20px; }
.admin-main { flex: 1; padding: 28px 20px; }

.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card-narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.page-title { font-size: 20px; margin: 0 0 18px; color: var(--ink); }
.lead { color: #444; margin-bottom: 22px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* ===== Form ===== */
.form .field { margin-bottom: 18px; }
.form label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.form input[type="text"],
.form input[type="tel"],
.form input[type="email"],
.form input[type="password"],
.form input[type="date"],
.form input[type="file"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
}
.form input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(46,139,87,.12); }
.req { color: #fff; background: var(--orange); font-size: 11px; padding: 1px 7px; border-radius: 4px; vertical-align: middle; margin-left: 4px; }
.field-check label { font-weight: 400; }

.form-inline-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
}
.form-inline-grid .field-submit { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-inline-grid { grid-template-columns: 1fr; } }

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    background: #eef1f5;
    color: var(--ink);
    transition: background .15s;
}
.btn:hover { background: #e2e7ee; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-block { width: 100%; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-link { background: none; color: #fff; padding: 6px 10px; }
.btn-link:hover { background: rgba(255,255,255,.15); }

/* ===== Alerts ===== */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.alert ul { margin: 0; padding-left: 20px; }
.alert-error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6cb; }
.alert-success { background: #eafaf1; color: var(--green-dark); border: 1px solid #b7e4c7; }

/* ===== Admin ===== */
.admin-header { background: var(--green-dark); color: #fff; }
.admin-header-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; flex-wrap: wrap; gap: 10px; }
.admin-title { font-weight: 700; font-size: 17px; }
.admin-nav { display: flex; align-items: center; gap: 6px; }
.admin-nav a { color: #d9f2e4; text-decoration: none; padding: 6px 12px; border-radius: 6px; font-size: 14px; }
.admin-nav a:hover, .admin-nav a.active { background: rgba(255,255,255,.16); color: #fff; }
.logout-form { margin: 0; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { background: #f7f9fb; font-size: 13px; color: #555; white-space: nowrap; }
.table .num { text-align: right; }
.link-label { font-weight: 600; }
.share-url input { width: 100%; min-width: 220px; font-size: 12px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: #f7f9fb; color: #333; margin: 4px 0; }

.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; margin-left: 4px; display: inline-block; }
.badge-ok { background: #e3f7ec; color: var(--green-dark); }
.badge-muted { background: #eceff3; color: var(--muted); }
.badge-danger { background: #fdecea; color: var(--danger); }

details > summary { display: inline-block; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.edit-panel { background: #f7f9fb; border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-top: 10px; min-width: 240px; }
.delete-form { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }

.pagination { margin-top: 18px; }

/* ===== Error pages ===== */
.error-card { text-align: center; max-width: 560px; margin: 24px auto; padding: 48px 32px; }
.error-code {
    font-size: 84px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: .02em;
    background: linear-gradient(135deg, var(--green) 0%, var(--orange) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--green);
}
.error-title { font-size: 22px; margin: 14px 0 10px; color: var(--ink); }
.error-message { color: #555; margin: 0 auto 28px; max-width: 420px; }
@media (max-width: 640px) { .error-code { font-size: 64px; } .error-card { padding: 36px 20px; } }

/* ===== Footer ===== */
.site-footer { background: #fff; border-top: 1px solid var(--line); padding: 20px; margin-top: auto; }
.footer-inner { text-align: center; font-size: 13px; color: var(--muted); }
.footer-inner a { color: var(--green-dark); text-decoration: none; }
.footer-inner a:hover { text-decoration: underline; }
.footer-inner .sep { margin: 0 8px; color: var(--line); }
.copyright { margin-top: 6px; color: var(--muted); }

/* ========================================================================
   公開（ユーザー閲覧）ページ専用テーマ — StudentMypageLite ブランド配色
   admin (body.admin) には影響させない
   ======================================================================== */
:root {
    --sml-navy: #11267d;
    --sml-blue: #1b9bd8;
    --sml-teal: #14a699;
}

/* --- Header with logo --- */
.brand-logo { height: 44px; width: auto; display: block; }
.site-header { box-shadow: 0 2px 14px rgba(17,38,125,.06); border-bottom: none; }
body:not(.admin) .brand-link {
    color: var(--sml-blue);
    border: 1px solid #d4ebf7;
    background: #f3fafe;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    transition: all .15s;
}
body:not(.admin) .brand-link:hover { background: var(--sml-blue); color: #fff; text-decoration: none; border-color: var(--sml-blue); }

/* --- Hero --- */
.hero {
    position: relative;
    background: linear-gradient(125deg, var(--sml-navy) 0%, var(--sml-blue) 58%, var(--sml-teal) 100%);
    padding: 60px 0 104px;
    overflow: hidden;
    text-align: center;
}
.hero-inner { position: relative; z-index: 2; }
.hero-eyebrow {
    display: inline-block;
    color: rgba(255,255,255,.85);
    letter-spacing: .28em;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 10px;
}
.hero-title { color: #fff; font-size: 34px; font-weight: 800; margin: 0 0 12px; letter-spacing: .03em; }
.hero-lead { color: rgba(255,255,255,.95); font-size: 16px; margin: 0; padding: 0 16px; }
.hero-bg { position: absolute; inset: 0; z-index: 1; }
.blob { position: absolute; border-radius: 50%; background: rgba(255,255,255,.10); filter: blur(2px); }
.blob-1 { width: 220px; height: 220px; top: -70px; right: -40px; }
.blob-2 { width: 140px; height: 140px; bottom: 10px; left: -30px; background: rgba(255,255,255,.08); }
.blob-3 { width: 90px; height: 90px; top: 40px; left: 16%; background: rgba(255,255,255,.07); }
.hero-wave {
    position: absolute; left: 0; right: 0; bottom: -1px; height: 54px; z-index: 2;
    background: var(--bg);
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}
@media (max-width: 640px) { .hero-title { font-size: 26px; } .hero { padding: 44px 0 84px; } }

/* --- Download card overlapping hero --- */
body:not(.admin) .main { padding-top: 0; }
.download-card {
    max-width: 640px;
    margin: -60px auto 8px;
    position: relative;
    z-index: 3;
    padding: 36px 36px 30px;
    border: none;
    border-radius: 16px;
    box-shadow: 0 18px 50px -12px rgba(17,38,125,.22);
}
@media (max-width: 640px) { .download-card { padding: 26px 20px; } }

/* --- Document banner --- */
.doc-banner {
    display: flex; align-items: center; gap: 14px;
    background: linear-gradient(120deg, #eef7fc 0%, #e8f6f3 100%);
    border: 1px solid #dceef6;
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 22px;
}
.doc-banner-icon {
    flex: none; width: 46px; height: 46px; border-radius: 11px;
    background: linear-gradient(135deg, var(--sml-blue), var(--sml-teal));
    color: #fff; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 14px -4px rgba(27,155,216,.5);
}
.doc-banner-label { font-size: 11px; color: var(--sml-blue); font-weight: 700; letter-spacing: .08em; }
.doc-banner-name { font-size: 18px; font-weight: 700; color: var(--sml-navy); margin-top: 2px; }

.form-note { color: #555; font-size: 14px; margin: 0 0 18px; }
.req-note { color: var(--muted); font-size: 12px; margin-left: 6px; }
.privacy-note { color: var(--muted); font-size: 12px; text-align: center; margin: 14px 0 0; }

/* --- Public form polish (scoped) --- */
body:not(.admin) .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 560px) { body:not(.admin) .field-row { grid-template-columns: 1fr; } }
body:not(.admin) .form label { color: var(--sml-navy); }
body:not(.admin) .req { background: var(--sml-blue); }
body:not(.admin) .form input { padding: 12px 14px; border-radius: 10px; background: #fbfdff; }
body:not(.admin) .form input:focus { border-color: var(--sml-blue); box-shadow: 0 0 0 3px rgba(27,155,216,.15); background: #fff; }

/* --- Primary button (public): gradient + icon --- */
body:not(.admin) .btn-primary {
    background: linear-gradient(120deg, var(--sml-navy), var(--sml-blue) 60%, var(--sml-teal));
    box-shadow: 0 10px 24px -8px rgba(20,71,160,.55);
}
body:not(.admin) .btn-primary:hover { filter: brightness(1.06); }
.btn-lg { padding: 15px 20px; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; border-radius: 12px; }

/* --- State (error) blocks --- */
.state { text-align: center; padding: 22px 8px; }
.state-icon {
    width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px; font-weight: 800; color: #fff;
}
.state-error .state-icon { background: linear-gradient(135deg, #ff8a5c, var(--orange)); }
.state h2 { font-size: 19px; color: var(--ink); margin: 0 0 8px; }
.state p { color: #666; margin: 0; }

/* --- Footer with logos (public) --- */
body:not(.admin) .site-footer {
    background: #fff;
    border-top: 1px solid var(--line);
    padding: 36px 20px 30px;
    box-shadow: 0 -2px 14px rgba(17,38,125,.04);
}
body:not(.admin) .footer-inner { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.footer-logo { height: 56px; width: auto; display: block; }
.footer-logo-link { display: inline-block; }
.footer-desc { font-size: 13px; color: #667; margin: 0; max-width: 460px; }
body:not(.admin) .footer-desc a { color: var(--sml-blue); font-weight: 600; }
body:not(.admin) .copyright { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* --- Error pages: switch accent to SML brand on public --- */
body:not(.admin) .error-code { background: linear-gradient(135deg, var(--sml-navy), var(--sml-blue) 55%, var(--sml-teal)); -webkit-background-clip: text; background-clip: text; }
body:not(.admin) .error-card .btn-primary { background: linear-gradient(120deg, var(--sml-navy), var(--sml-blue) 60%, var(--sml-teal)); }

/* ========================================================================
   アニメーション（公開ページ） — prefers-reduced-motion で自動オフ
   ======================================================================== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { 0% { opacity: 0; transform: scale(.8); } 60% { transform: scale(1.06); } 100% { opacity: 1; transform: scale(1); } }
@keyframes floatY { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-22px); } }
@keyframes floatY2 { 0%,100% { transform: translateY(0); } 50% { transform: translateY(16px); } }
@keyframes gradientShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes shimmer { 0% { background-position: -180% 0; } 100% { background-position: 180% 0; } }
@keyframes iconBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* 動くグラデーション背景 */
.hero {
    background: linear-gradient(125deg, var(--sml-navy) 0%, var(--sml-blue) 42%, var(--sml-teal) 72%, var(--sml-blue) 100%);
    background-size: 220% 220%;
    animation: gradientShift 14s ease infinite;
}
/* ヒーロー内テキストの順次フェードアップ */
.hero-eyebrow { animation: fadeUp .7s ease both; }
.hero-title   { animation: fadeUp .7s ease .12s both; }
.hero-lead    { animation: fadeUp .7s ease .24s both; }

/* 浮遊する装飾ブロブ */
.blob-1 { animation: floatY 9s ease-in-out infinite; }
.blob-2 { animation: floatY2 7s ease-in-out infinite; }
.blob-3 { animation: floatY 11s ease-in-out infinite .5s; }

/* カード本体の登場 */
.download-card { animation: fadeUp .7s ease .3s both; }

/* 資料バナー：アイコンふわふわ＋ラベルのシマー */
.doc-banner { animation: fadeIn .6s ease .5s both; }
.doc-banner-icon { animation: iconBob 3.2s ease-in-out infinite; }

/* 入力欄を順次登場（公開のみ） */
body:not(.admin) .form .field { animation: fadeUp .55s ease both; }
body:not(.admin) .form .field:nth-of-type(1) { animation-delay: .42s; }
body:not(.admin) .form .field-row { animation: fadeUp .55s ease both; }
body:not(.admin) .form .field-row:nth-of-type(1) { animation-delay: .5s; }
body:not(.admin) .form .field-row:nth-of-type(2) { animation-delay: .58s; }
body:not(.admin) .form .btn-lg { animation: fadeUp .55s ease .66s both; }

/* 全インタラクションを滑らかに */
body:not(.admin) .form input { transition: border-color .18s ease, box-shadow .18s ease, background .18s ease, transform .18s ease; }
body:not(.admin) .form input:focus { transform: translateY(-1px); }

/* プライマリボタン：ホバーで浮上＋光沢スイープ */
body:not(.admin) .btn-primary { position: relative; overflow: hidden; transition: transform .18s ease, box-shadow .18s ease, filter .18s ease; }
body:not(.admin) .btn-primary::after {
    content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.38) 50%, transparent 70%);
    background-size: 220% 100%; background-position: -180% 0;
}
body:not(.admin) .btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 30px -8px rgba(20,71,160,.6); }
body:not(.admin) .btn-primary:hover::after { animation: shimmer 1.1s ease; }
body:not(.admin) .btn-primary:active { transform: translateY(0); }
body:not(.admin) .btn-lg svg { transition: transform .25s ease; }
body:not(.admin) .btn-primary:hover .btn-lg svg, body:not(.admin) .btn-lg:hover svg { transform: translateY(2px); }

/* ヘッダーロゴ・サービスリンクのホバー */
.brand-logo { transition: transform .25s ease; }
.brand:hover .brand-logo { transform: scale(1.04); }

/* エラー状態アイコンの登場 */
.state-icon { animation: popIn .5s ease both; }
.state h2 { animation: fadeUp .5s ease .1s both; }
.state p  { animation: fadeUp .5s ease .18s both; }

/* エラーページ番号の登場 */
.error-code { animation: popIn .6s ease both; }
.error-title { animation: fadeUp .6s ease .15s both; }
.error-message { animation: fadeUp .6s ease .25s both; }
.error-card .btn { animation: fadeUp .6s ease .35s both; }

/* フッターロゴのホバー */
.footer-logo { transition: transform .25s ease; }
.footer-logo-link:hover .footer-logo { transform: scale(1.05) rotate(-1deg); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- プライバシーポリシー同意チェック（公開） --- */
.agree-box {
    display: flex; align-items: center; justify-content: center; gap: 0;
    background: #f7fafd; border: 1px solid #e2edf5; border-radius: 12px;
    padding: 15px 16px; margin: 4px 0 20px; cursor: pointer;
    transition: border-color .18s ease, background .18s ease;
}
.agree-box:hover { border-color: #c6e2f2; background: #f2f9fe; }
.agree-input {
    flex: none;
    width: 20px; height: 20px;
    margin: 0 12px 0 0;
    accent-color: var(--sml-teal);
    cursor: pointer;
}
.agree-text { font-size: 14px; color: #445; line-height: 1.4; cursor: pointer; }
.agree-text a { color: var(--sml-blue); font-weight: 700; text-decoration: underline; }
.agree-text a:hover { color: var(--sml-navy); }
body:not(.admin) .form .agree-box { animation: fadeUp .55s ease .64s both; }

/* --- ダウンロード完了（お礼）画面 --- */
.complete-card { text-align: center; padding: 40px 36px 34px; }
.complete-check {
    width: 84px; height: 84px; border-radius: 50%; margin: 4px auto 22px;
    display: flex; align-items: center; justify-content: center; color: #fff;
    background: linear-gradient(135deg, var(--sml-blue), var(--sml-teal));
    box-shadow: 0 14px 30px -8px rgba(20,150,140,.5);
    animation: popIn .55s ease both;
}
.complete-title { font-size: 23px; font-weight: 800; color: var(--sml-navy); margin: 0 0 12px; animation: fadeUp .55s ease .1s both; }
.complete-lead { color: #556; margin: 0 0 26px; animation: fadeUp .55s ease .18s both; }
.complete-btn { max-width: 420px; margin: 0 auto; animation: fadeUp .55s ease .26s both; }
.complete-help {
    margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line);
    animation: fadeIn .6s ease .4s both;
}
.complete-help p { font-size: 14px; color: #667; margin: 0; }
.complete-help a { color: var(--sml-blue); font-weight: 700; text-decoration: underline; }
.complete-help a:hover { color: var(--sml-navy); }
@media (max-width: 640px) { .complete-card { padding: 30px 20px; } .complete-title { font-size: 20px; } }

/* --- 折り返さないテーブル（ダウンロード記録など） --- */
.table-nowrap th,
.table-nowrap td { white-space: nowrap; }
.table-nowrap td { vertical-align: middle; }
