:root {
  --bg: #f4f6f8; --panel: #fff; --line: #dde2e7; --text: #1f2933; --muted: #66727f;
  --primary: #1f6f8b; --primary-d: #175a71; --accent: #e8f3f7;
  --error: #b42318; --warn: #9a6700;
  font-family: "Yu Gothic UI", "Meiryo", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 15px; }
.hidden { display: none !important; }
.spacer { flex: 1; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 6px;
  padding: 8px 16px; cursor: pointer; font: inherit; }
.btn:hover { background: #f0f3f5; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--primary-d); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }

/* ---- login ---- */
.login-page { display: grid; place-items: center; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 32px 36px; width: min(420px, 92vw); box-shadow: 0 4px 18px rgba(0,0,0,.05); }
.login-card h1 { margin: 0; font-size: 24px; color: var(--primary); }
.login-card .sub { margin: 4px 0 20px; color: var(--muted); font-size: 13px; }
.login-card label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 14px; }
.login-card select, .login-card input { width: 100%; padding: 9px 10px; font: inherit;
  border: 1px solid var(--line); border-radius: 6px; }
.login-card .btn { width: 100%; margin-top: 22px; padding: 10px; }
.login-card .note { color: var(--muted); font-size: 12px; margin-top: 18px; }
.alert { background: #fdecea; color: var(--error); padding: 8px 12px; border-radius: 6px; font-size: 14px; }

/* ---- app ---- */
body:not(.login-page) { display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 18px; background: var(--panel);
  border-bottom: 1px solid var(--line); }
.topbar form { margin: 0; }
.brand { font-weight: 700; font-size: 17px; color: var(--primary); }
.model-badge { font-size: 12px; background: var(--accent); color: var(--primary-d);
  border: 1px solid #c4dfe8; border-radius: 999px; padding: 3px 10px; user-select: none; }
.site { font-size: 14px; }

.layout { flex: 1; display: flex; min-height: 0; }
.sidebar { width: 270px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px;
  border-bottom: 1px solid var(--line); }
.side-head h2 { font-size: 14px; margin: 0; color: var(--muted); }
.skill-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.skill { padding: 9px 10px; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.skill:hover, .skill:focus { background: #f0f3f5; outline: none; }
.skill.active { background: var(--accent); box-shadow: inset 3px 0 0 var(--primary); }
.skill-name { font-weight: 600; font-size: 14px; }
.skill-desc { font-size: 12px; color: var(--muted); }

/* ---- サイドバーの使い方 ---- */
.skill-empty { padding: 8px 10px; font-size: 13px; color: var(--muted); }
.side-help { margin-top: auto; padding: 12px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.side-help-title { margin: 0 0 4px; font-weight: 700; color: var(--text); }
.side-help ol { margin: 0 0 8px; padding-left: 18px; line-height: 1.7; }
.side-help-note { margin: 0; line-height: 1.6; }

/* ---- メイン：上＝入力、下＝結果 ---- */
.main { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; padding: 14px 18px 40px;
  display: flex; flex-direction: column; gap: 14px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }

.doc-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.doc-title { font-size: 18px; font-weight: 700; color: var(--primary-d); }
.doc-title.warn { color: var(--warn); font-size: 16px; }
.doc-title.warn::before { content: "← "; }
.doc-desc { font-size: 13px; color: var(--muted); }

.karte { width: 100%; height: 230px; min-height: 120px; resize: vertical; border: 1px solid var(--line);
  border-radius: 6px; padding: 10px 12px; font: inherit; line-height: 1.6; }
.karte:focus, .revise input:focus { outline: 2px solid #b9dbe7; border-color: var(--primary); }
.karte:disabled { background: #f7f9fa; color: var(--muted); }
.bar { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.file-btn { display: inline-flex; align-items: center; }
.hint { font-size: 12px; color: var(--muted); }
.send-hint { font-size: 13px; font-weight: 600; color: var(--warn); }
.btn.big { padding: 10px 26px; font-size: 16px; }
.attach-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.attach-list:empty { display: none; }
.chip { background: var(--accent); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12px;
  display: inline-flex; align-items: center; gap: 4px; }
.chip button { border: none; background: transparent; cursor: pointer; font-size: 14px; color: var(--muted); }

.result-panel { border-color: #c4dfe8; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-bottom: 10px; }
.result-title { font-weight: 700; font-size: 16px; }
.result-sub { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions.bottom { justify-content: flex-end; margin-top: 10px; }
.actions .btn.done { background: #e7f6ec; border-color: #9fd3b0; color: #1e6b3a; opacity: 1; }
.actions .btn.primary.done { background: #1e6b3a; border-color: #1e6b3a; color: #fff; }

.result { min-height: 320px; white-space: pre-wrap; word-break: break-word; line-height: 1.8;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.result.empty { color: #9aa5b1; display: flex; align-items: center; justify-content: center;
  background: #fafbfc; border-style: dashed; }
.result.loading { display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--primary-d); background: #f6fafc; }
.result.streaming::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--primary); }
@keyframes blink { 50% { opacity: 0; } }
.spinner { width: 20px; height: 20px; border: 3px solid #c4dfe8; border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.notice { font-size: 13px; padding: 8px 12px; border-radius: 6px; margin-bottom: 10px; }
.notice.error { background: #fdecea; color: var(--error); }
.notice.warn { background: #fff6dd; color: var(--warn); }

.revise { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.revise label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.revise-row { display: flex; gap: 8px; }
.revise input { flex: 1; padding: 7px 10px; font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 6px; }

/* ---- 通知 ---- */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 50;
  background: #1f2933; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 90vw; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; max-height: 34vh; }
  .side-help { display: none; }
  .model-badge { display: none; }
}

/* =====================================================================
   視認性の調整（文字サイズ・行間・余白／文字の詰まり・途切れ防止）
   ===================================================================== */
html, body { font-size: 16px; line-height: 1.6; }
.btn { line-height: 1.4; white-space: nowrap; }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.big { padding: 11px 30px; font-size: 17px; }
.btn:focus-visible, .doc-chip:focus-visible, .skill:focus-visible { outline: 3px solid #9fd0e0; outline-offset: 1px; }

.topbar { flex-wrap: wrap; row-gap: 6px; padding: 12px 22px; }
.brand { font-size: 18px; }
.model-badge { font-size: 13px; padding: 4px 12px; }
.site { font-size: 15px; }

.sidebar { width: 280px; }
.side-head { padding: 14px 16px; }
.side-head h2 { font-size: 15px; }
.skill-list { padding: 8px; }
.skill { padding: 11px 12px; gap: 3px; }
.skill-name { font-size: 15px; line-height: 1.45; }
.skill-desc { font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere; }
.side-help { padding: 14px 16px; font-size: 12.5px; line-height: 1.65; }

.main { padding: 20px 26px 48px; gap: 18px; }
.panel { padding: 18px 22px; border-radius: 12px; }

/* 手順ラベル（1→2→3） */
.step-label { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px;
  color: var(--text); margin: 4px 0 10px; }
.step-label.inline { margin: 0; }
.step-no { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 700; flex: none; }
.step-sub { font-weight: 400; font-size: 13px; color: var(--muted); }

/* 上部の書類選択ボタン */
.doc-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.doc-chip { border: 1px solid #c4dfe8; background: #fff; color: var(--primary-d); border-radius: 999px;
  padding: 8px 16px; font: inherit; font-size: 15px; line-height: 1.4; cursor: pointer; white-space: nowrap; }
.doc-chip:hover { background: var(--accent); }
.doc-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.doc-chip.active::before { content: "✓ "; }

.doc-head { margin: 0 0 16px; padding: 10px 14px; border-radius: 8px; background: #f6fafc; gap: 6px 14px; }
.doc-title { font-size: 17px; line-height: 1.5; }
.doc-title.warn { font-size: 16px; }
.doc-title.warn::before { content: "⚠ "; }
.doc-head:has(.doc-title.warn) { background: #fff8e6; }
.doc-desc { font-size: 13.5px; line-height: 1.6; }

.karte { height: 240px; min-height: 140px; font-size: 15.5px; line-height: 1.75; padding: 12px 14px; }
.bar { gap: 12px; margin-top: 12px; }
.hint { font-size: 13px; }
.send-hint { font-size: 14px; }
.chip { font-size: 13px; padding: 4px 6px 4px 12px; }

.result-head { margin-bottom: 12px; row-gap: 10px; }
.actions { gap: 10px; }
.actions.bottom { margin-top: 12px; }
.result { min-height: 340px; font-size: 15.5px; line-height: 1.9; padding: 18px 20px; overflow-wrap: anywhere; }
.result.empty, .result.loading { font-size: 15px; }
.notice { font-size: 14px; line-height: 1.6; padding: 10px 14px; }
.revise { margin-top: 18px; padding-top: 14px; }
.revise label { font-size: 14px; }
.revise input { padding: 9px 12px; font-size: 15px; }
.toast { font-size: 15px; padding: 12px 20px; line-height: 1.5; }

@media (max-width: 1100px) {
  .sidebar { width: 240px; }
  .main { padding: 16px 16px 40px; }
}
