:root {
    --navy: #12365a;
    --navy-dark: #0a2642;
    --blue: #1677b8;
    --blue-pale: #eaf5fb;
    --green: #238a78;
    --ink: #173047;
    --muted: #66798b;
    --line: #dce6ed;
    --bg: #f4f7f9;
    --white: #fff;
    --danger: #b42318;
    --shadow: 0 14px 40px rgba(18, 54, 90, .09);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif; line-height: 1.7; }
button, input, select, textarea { font: inherit; }
a { color: var(--blue); }

.site-header { height: 72px; padding: 0 max(24px, calc((100vw - 1180px) / 2)); display: flex; align-items: center; justify-content: space-between; background: var(--white); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--navy); text-decoration: none; font-size: 19px; font-weight: 800; letter-spacing: .02em; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; color: white; background: linear-gradient(145deg, var(--blue), var(--green)); border-radius: 9px; font-size: 22px; font-weight: 800; }
.header-user { display: flex; align-items: center; gap: 20px; color: var(--muted); font-size: 14px; }
.header-user form { margin: 0; }
.text-button { border: 0; background: transparent; color: var(--blue); padding: 6px; cursor: pointer; }

.page-shell { width: min(1180px, calc(100% - 40px)); min-height: calc(100vh - 132px); margin: 0 auto; padding: 54px 0 70px; }
.site-footer { height: 60px; display: grid; place-items: center; color: #718393; font-size: 12px; }
.page-heading { margin-bottom: 30px; }
.page-heading.compact { max-width: 850px; }
.page-heading h1 { margin: 4px 0 8px; color: var(--navy-dark); font-size: clamp(28px, 4vw, 42px); line-height: 1.25; }
.page-heading p { margin: 0; color: var(--muted); }
.eyebrow { margin: 0 !important; color: var(--blue) !important; font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.back-link { display: inline-block; margin-bottom: 24px; font-size: 14px; text-decoration: none; }
.back-link::before { content: "←"; margin-right: 7px; }

.card { background: var(--white); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.login-grid { min-height: 620px; display: grid; grid-template-columns: 1.15fr .85fr; align-items: stretch; overflow: hidden; background: var(--white); border-radius: 24px; box-shadow: var(--shadow); }
.intro-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(42px, 7vw, 90px); color: white; background: radial-gradient(circle at 15% 20%, rgba(52, 179, 172, .6), transparent 34%), linear-gradient(145deg, #0b3558, #106e9f); }
.intro-panel .eyebrow { color: #b7eef0 !important; }
.intro-panel h1 { margin: 12px 0 24px; font-size: clamp(38px, 5.5vw, 64px); line-height: 1.15; letter-spacing: .02em; }
.intro-panel p:last-child { max-width: 520px; color: #e0f2fb; }
.login-card { align-self: center; margin: 46px; padding: 42px; box-shadow: none; }
.login-card h2, .card h2 { margin: 0 0 4px; color: var(--navy-dark); line-height: 1.4; }
.muted, .help-text { color: var(--muted); }
.help-text { margin: 0; font-size: 12px; }

.form-stack { display: grid; gap: 20px; margin-top: 28px; }
label { display: grid; gap: 7px; color: #334c60; font-size: 14px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #bdccd7; border-radius: 10px; background: white; padding: 12px 14px; color: var(--ink); outline: none; transition: border .2s, box-shadow .2s; }
textarea { resize: vertical; line-height: 1.65; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22, 119, 184, .14); }
.button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 10px; padding: 10px 20px; font-weight: 800; text-decoration: none; cursor: pointer; transition: transform .15s, opacity .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button-primary { color: white; background: linear-gradient(135deg, var(--blue), #0b5d91); }
.button-secondary { color: var(--navy); background: white; border-color: #b8c9d6; }
.alert { margin: 20px 0 0; padding: 12px 14px; border-radius: 9px; font-size: 14px; }
.alert-error { color: var(--danger); background: #fff1f0; border: 1px solid #ffd0cc; }

.feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.feature-card { min-height: 300px; padding: 38px; color: inherit; text-decoration: none; background: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; }
.feature-card:hover { transform: translateY(-3px); box-shadow: 0 18px 48px rgba(18, 54, 90, .14); }
.feature-icon { width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 26px; border-radius: 16px; color: white; font-size: 25px; font-weight: 900; }
.coaching-card .feature-icon { background: linear-gradient(145deg, var(--blue), #4ca7d3); }
.evaluation-card .feature-icon { background: linear-gradient(145deg, var(--green), #45ae9c); }
.history-card .feature-icon { background: linear-gradient(145deg, #6b5bb8, #9487da); }
.feature-card h2 { margin: 0 0 10px; color: var(--navy-dark); font-size: 25px; }
.feature-card p { color: var(--muted); }
.card-link { display: inline-block; margin-top: 18px; color: var(--blue); font-weight: 800; }

.chat-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 22px; align-items: start; }
.chat-sidebar { display: grid; gap: 18px; min-width: 0; }
.chat-settings { display: grid; gap: 18px; padding: 24px; }
.chat-settings h2 { font-size: 18px; }
.chat-panel { min-height: 640px; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.chat-header { padding: 21px 28px 18px; background: #fafcfd; border-bottom: 1px solid var(--line); }
.chat-title { color: var(--navy-dark); font-weight: 800; line-height: 1.5; }
.chat-messages { max-height: 570px; overflow: auto; padding: 28px; scroll-behavior: smooth; }
.empty-state { height: 440px; display: grid; place-content: center; gap: 6px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--navy); font-size: 18px; }
.message { max-width: 80%; margin: 0 0 18px; padding: 14px 17px; border-radius: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-ai { background: var(--blue-pale); border-bottom-left-radius: 4px; }
.message-user { margin-left: auto; color: white; background: var(--navy); border-bottom-right-radius: 4px; }
.message-system { max-width: 100%; padding: 10px; color: var(--muted); background: transparent; text-align: center; font-size: 13px; }
.chat-composer { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 18px; border-top: 1px solid var(--line); background: #fafcfd; }
.chat-composer textarea { min-height: 78px; }
.chat-composer .button { align-self: end; }
.chat-composer.is-disabled { opacity: .7; }
.coaching-history-panel { min-width: 0; padding: 0; overflow: hidden; box-shadow: none; }
.coaching-history-panel details { display: block; }
.coaching-history-panel summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 20px 22px; color: var(--navy-dark); font-weight: 800; cursor: pointer; list-style: none; }
.coaching-history-panel summary::-webkit-details-marker { display: none; }
.coaching-history-panel summary::after { content: "⌄"; color: var(--blue); }
.coaching-history-panel details[open] summary::after { transform: rotate(180deg); }
.coaching-history-panel summary span { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 700; }
.coaching-history-nav { max-height: 340px; overflow-y: auto; border-top: 1px solid var(--line); }
.coaching-history-link { display: block; min-width: 0; padding: 17px 20px 18px; color: inherit; border-bottom: 1px solid var(--line); text-decoration: none; overflow-wrap: anywhere; }
.coaching-history-link:last-child { border-bottom: 0; }
.coaching-history-link:hover, .coaching-history-link.is-current { background: var(--blue-pale); }
.history-link-title { display: block; color: var(--navy); font-size: 13px; font-weight: 800; line-height: 1.55; }
.history-link-meta { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.history-empty-text { color: var(--muted); font-size: 11px; }
.history-empty-text { margin: 0; padding: 0 20px 20px; }
.history-meta { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.is-hidden { display: none !important; }
.heading-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.heading-actions .back-link { margin-bottom: 0; }
.heading-actions a { font-size: 14px; text-decoration: none; }

.history-list { display: grid; gap: 16px; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px 28px; color: inherit; text-decoration: none; transition: transform .18s, box-shadow .18s; }
.history-item:hover { transform: translateY(-2px); box-shadow: 0 18px 48px rgba(18, 54, 90, .14); }
.history-item h2 { margin: 7px 0 2px; font-size: 20px; }
.history-item p { margin: 0; color: var(--muted); font-size: 13px; }
.history-arrow { flex: none; color: var(--blue); font-weight: 800; font-size: 14px; }
.status-badge { display: inline-block; padding: 3px 9px; color: var(--blue); background: var(--blue-pale); border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-完了 { color: #146b5d; background: #eaf8f4; }
.status-中断 { color: #8a5b11; background: #fff5df; }
.empty-history { max-width: 720px; padding: 38px; }
.empty-history .button { margin-top: 18px; }
.history-detail { max-width: 880px; padding: 30px; }
.history-detail .message:last-child { margin-bottom: 0; }

.narrow-card { max-width: 620px; padding: 34px; }
.evaluation-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, .6fr); gap: 24px; align-items: start; }
.summary-panel, .sticky-form, .result-card { padding: 32px; }
.sticky-form { position: sticky; top: 24px; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.count-badge { flex: none; padding: 4px 11px; color: var(--blue); background: var(--blue-pale); border-radius: 999px; font-size: 12px; font-weight: 800; }
.report-content { overflow-wrap: anywhere; }
.report-content h3, .report-content h4 { margin: 28px 0 10px; color: var(--navy); }
.report-content p { margin: 7px 0; }
.report-content ul { margin: 8px 0; padding-left: 22px; }
.report-result { max-width: 860px; margin: 30px auto 10px; }
.success-banner { display: flex; justify-content: space-between; gap: 12px; padding: 14px 18px; color: #146b5d; background: #eaf8f4; border: 1px solid #b9e4d8; border-radius: 10px; font-size: 13px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--line); }
.error-page { margin: 60px auto; text-align: center; }
.error-page .button { margin-top: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 820px) {
    .site-header { height: auto; min-height: 64px; padding: 12px 20px; }
    .header-user { gap: 8px; flex-direction: column; align-items: flex-end; line-height: 1.2; }
    .page-shell { width: min(100% - 28px, 680px); padding-top: 34px; }
    .login-grid, .feature-grid, .chat-layout, .evaluation-grid { grid-template-columns: 1fr; }
    .login-grid { min-height: 0; }
    .intro-panel { padding: 42px 28px; }
    .intro-panel h1 { font-size: 38px; }
    .login-card { margin: 0; padding: 34px 26px 42px; border: 0; }
    .feature-card { min-height: 250px; padding: 28px; }
    .chat-settings { order: 0; }
    .chat-sidebar { order: 0; }
    .chat-panel { order: 1; }
    .coaching-history-panel details:not([open]) .coaching-history-nav { display: none; }
    .chat-panel { min-height: 560px; }
    .chat-header { padding: 18px 20px 16px; }
    .chat-messages { max-height: 500px; padding: 20px; }
    .message { max-width: 92%; }
    .sticky-form { position: static; }
    .summary-panel, .sticky-form, .result-card { padding: 24px; }
    .success-banner { flex-direction: column; }
    .history-item { align-items: flex-start; flex-direction: column; gap: 12px; padding: 22px; }
    .heading-actions { align-items: flex-start; flex-direction: column; gap: 8px; }
}

@media (max-width: 520px) {
    .brand { font-size: 16px; }
    .header-user > span { display: none; }
    .chat-composer { grid-template-columns: 1fr; }
    .chat-composer .button { width: 100%; }
}
