:root {
  --ground: #F6F6F3;
  --surface: #FFFFFF;
  --border: #E2E2DC;
  --border-strong: #CFCFC8;
  --text: #1C1C1A;
  --muted: #5B5B57;
  --accent: #1F4FB8;
  --accent-hover: #163A87;
  --accent-soft: #EEF2FB;
  --accent-disabled: #9DB0DA;
  --warn: #8A4A0B;
  --error: #B00020;
  --code-bg: #1C1C1A;
  --code-head: #2A2A27;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: var(--text);
  background: var(--ground);
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  font: inherit; font-size: 14px; font-weight: 500;
  min-height: 44px; padding: 0 16px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-primary:disabled { background: var(--accent-disabled); cursor: default; }
.btn-outline { border-color: var(--accent); color: var(--accent); background: transparent; }
.btn-ghost { border-color: var(--border-strong); background: var(--surface); color: var(--text); }
.btn-link {
  font: inherit; font-size: 13px; color: var(--accent); background: transparent; border: 0;
  min-height: 44px; padding: 0 8px; cursor: pointer; text-decoration: underline;
}

/* login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 32px; display: flex; flex-direction: column; gap: 20px;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card p { margin: 0; font-size: 14px; line-height: 1.7; }
.login-card .login-note { font-size: 13px; border-top: 1px solid var(--border); padding-top: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 500; }
input[type=text], input[type=password] {
  font: inherit; font-size: 16px; border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 0 12px; min-height: 44px; background: var(--surface); color: var(--text);
}
.form-error { margin: 0; font-size: 13px; color: var(--error); }

/* chat */
.chat-page { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 16px;
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between;
}
.app-header__id { display: flex; align-items: center; gap: 4px 16px; flex-wrap: wrap; font-size: 13px; }
.app-title { font-weight: 700; font-size: 16px; }
.small-link { font-size: 12px; display: inline-flex; align-items: center; min-height: 44px; }
.app-header__actions { display: flex; flex-wrap: wrap; gap: 8px; }

.messages {
  flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 24px 16px 0;
  display: flex; flex-direction: column; gap: 20px;
}
.msg { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.msg--user { align-self: flex-end; max-width: 85%; align-items: flex-end; }
.msg--assistant { align-self: flex-start; max-width: 92%; }
.bubble-user {
  background: var(--accent); color: #fff; padding: 12px 16px; border-radius: 12px 12px 4px 12px;
  font-size: 15px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere;
}
.bubble-assistant {
  background: var(--surface); border: 1px solid var(--border); padding: 16px 20px;
  border-radius: 12px 12px 12px 4px; font-size: 15px; line-height: 1.8; overflow-wrap: anywhere; min-width: 0;
}
.bubble-assistant > :first-child { margin-top: 0; }
.bubble-assistant > :last-child { margin-bottom: 0; }
.bubble-assistant table { border-collapse: collapse; display: block; overflow-x: auto; }
.bubble-assistant th, .bubble-assistant td { border: 1px solid var(--border); padding: 4px 8px; }
.time { font-size: 12px; color: var(--muted); }
.note { font-size: 13px; color: var(--warn); margin: 0; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 13px;
  overflow-wrap: anywhere;
}
.status-line { align-self: flex-start; color: var(--muted); font-size: 14px; }

.code-block { background: var(--code-bg); border-radius: 8px; overflow: hidden; margin: 12px 0; }
.code-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 8px 4px 14px; background: var(--code-head); font-size: 12px; color: #C9C9C2;
}
.code-copy {
  font: inherit; font-size: 12px; color: #F2F2EE; background: transparent;
  border: 1px solid #55554F; border-radius: 6px; padding: 0 12px; min-height: 44px; cursor: pointer;
}
.code-block pre { margin: 0; overflow-x: auto; }
.code-block pre code.hljs {
  background: transparent; color: #F2F2EE; padding: 14px; font-size: 13px; line-height: 1.6;
  font-family: ui-monospace, "JetBrains Mono", Menlo, monospace;
}
.code-block .hljs-keyword, .code-block .hljs-built_in { color: #8FB4FF; }
.code-block .hljs-string { color: #A5D6A7; }
.code-block .hljs-comment { color: #9A9A92; }
.code-block .hljs-number, .code-block .hljs-literal { color: #FFCC80; }
.bubble-assistant :not(pre) > code { background: var(--ground); border-radius: 4px; padding: 1px 5px; font-size: .9em; }

.goal-card {
  border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 10px;
  padding: 14px 18px; display: flex; flex-direction: column; gap: 6px;
}
.goal-card__head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.goal-card__title { font-size: 13px; font-weight: 700; color: var(--accent); display: inline-flex; align-items: center; gap: 6px; }
.goal-card p { margin: 0; font-size: 15px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }

.composer-wrap {
  position: sticky; bottom: 0; padding: 24px 16px 20px;
  background: linear-gradient(#F6F6F300, var(--ground) 24px);
}
.composer {
  max-width: 860px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px;
}
textarea {
  font: inherit; font-size: 16px; line-height: 1.6; width: 100%; border: 0; resize: vertical;
  background: transparent; color: var(--text);
}
.composer textarea:focus-visible { outline: none; }
.composer:focus-within { border-color: var(--accent); }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty { display: none; }
.chips .attach-chip button {
  font: inherit; min-width: 44px; min-height: 44px; margin: -8px -12px -8px 0;
  background: transparent; border: 0; cursor: pointer; color: var(--muted); font-size: 18px;
}
.composer__row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.composer__tools { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.warn-note { font-size: 12px; color: var(--warn); }
.btn-send { font-size: 15px; padding: 0 20px; }

.dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 24px; width: min(560px, calc(100vw - 32px));
  background: var(--surface); color: var(--text);
}
.dialog::backdrop { background: rgb(28 28 26 / .4); }
.dialog h2 { margin: 0 0 8px; font-size: 18px; }
.dialog p { margin: 0 0 12px; font-size: 14px; }
.dialog textarea { border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 12px; margin-top: 6px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

@media (max-width: 480px) {
  .login-card { padding: 24px 20px; }
  .msg--user, .msg--assistant { max-width: 100%; }
  .bubble-assistant { padding: 12px 14px; }
}

/* prepare / done */
:root { --warn-soft: #FFF4E8; --warn-border: #E2B98C; --row-line: #EEEEE9; }
.done-icon { color: var(--accent); }
.done-logout { align-self: flex-start; }
.prepare { width: 100%; max-width: 860px; margin: 0 auto; padding: 24px 16px 48px; display: flex; flex-direction: column; gap: 24px; }
.prepare .intro { margin: 0; font-size: 14px; line-height: 1.8; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; }
.card h2 { margin: 0; font-size: 17px; }
.card p { margin: 0; font-size: 14px; line-height: 1.7; }
.row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--row-line); }
.row--att { padding-left: 32px; }
.row input[type=checkbox] { width: 20px; height: 20px; margin: 2px 0 0; flex: none; }
.row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; line-height: 1.7; }
.row__meta { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.row__text { white-space: pre-wrap; overflow-wrap: anywhere; }
.mark-flag { display: none; }
.row.is-marked { background: var(--warn-soft); border-radius: 8px; padding: 12px; margin: 0 -12px; border-bottom-color: transparent; }
.row.is-marked .row__meta { color: var(--warn); font-weight: 500; }
.row.is-marked .row__text { text-decoration: line-through; color: var(--muted); }
.row.is-marked .mark-flag { display: inline; }
.ask { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; border: 1px solid var(--warn-border); border-radius: 8px; padding: 12px 16px; background: var(--surface); }
.ask[hidden] { display: none; }
.ask span { font-size: 14px; }
.ask__actions { display: flex; gap: 8px; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-warn:hover { background: #6E3A08; }
.upload { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.upload .muted { font-size: 13px; overflow-wrap: anywhere; }
.upload label.btn:focus-within, .upload:focus-within label.btn { outline: 2px solid var(--accent); outline-offset: 2px; }
.goals { display: flex; flex-direction: column; gap: 8px; }
.goal-version { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; font-size: 14px; line-height: 1.7; color: var(--muted); display: flex; flex-direction: column; }
.goal-version--latest { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.goal-version__head { font-size: 12px; font-weight: 700; }
.goal-version--latest .goal-version__head { color: var(--accent); }
.achievement { border: 0; margin: 0; padding: 0; }
.achievement legend { padding: 0; margin-bottom: 8px; }
.achievement__options { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 14px; min-height: 44px; font-size: 14px; }
textarea.boxed { border: 1px solid var(--border-strong); border-radius: 8px; padding: 10px 12px; line-height: 1.7; }
.submit-row { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: flex-end; }
.submit-row .form-error { flex-basis: 100%; text-align: right; }
.btn-submit { font-size: 15px; padding: 0 28px; min-height: 48px; }
