:root {
  --ink: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --surface: #ffffff;
  --soft: #f5f7fa;
  --brand: #153d6f;
  --brand-2: #245b9b;
  --accent: #b56a2d;
  --danger: #a63d40;
  --shadow: 0 12px 36px rgba(16, 24, 40, 0.08);
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: #f7f8fa;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.site-header {
  min-height: 72px;
  padding: 14px clamp(20px, 5vw, 72px);
  background: rgba(255,255,255,.95);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 10px;
  display: grid; place-items: center;
  color: white; background: var(--brand);
  font-weight: 800; letter-spacing: .5px;
}
.brand-title { font-size: 17px; font-weight: 800; }
.brand-subtitle { font-size: 11px; color: var(--muted); margin-top: 2px; }

main { min-height: calc(100vh - 128px); }
.view { padding: 56px clamp(20px, 6vw, 96px); }
.hero { max-width: 1080px; margin: 0 auto; }
.eyebrow {
  margin: 0 0 12px;
  color: var(--brand-2);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.17;
  letter-spacing: -.03em;
}
.hero-copy {
  max-width: 780px;
  margin: 22px 0 30px;
  font-size: 18px;
  line-height: 1.8;
  color: #475467;
}
.access-gate {
  max-width: 620px;
  margin: 0 0 34px;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(16,24,40,.05);
}
.access-row {
  max-width: 100%;
}
.access-row label {
  display: block;
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 9px;
}
.access-controls {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.access-row input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid #cfd5df;
  border-radius: 10px;
  background: white;
}
.access-row input:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(36,91,155,.10);
}
.access-hint {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.access-error {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  background: #fff0f0;
  color: var(--danger);
  border: 1px solid #f0c2c2;
  font-size: 13px;
}
.scenario-prompt {
  margin: 0 0 14px;
  color: #475467;
  font-size: 15px;
  font-weight: 700;
}
.scenario-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.scenario-card {
  min-height: 190px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(16,24,40,.04);
  text-align: left;
  transition: .18s ease;
  display: flex;
  flex-direction: column;
}
.scenario-card:hover {
  transform: translateY(-3px);
  border-color: #9eb4ce;
  box-shadow: var(--shadow);
}
.scenario-index {
  color: var(--brand-2); font-weight: 800; font-size: 12px;
  margin-bottom: 20px;
}
.scenario-card h3 { margin: 0; font-size: 25px; }
.scenario-card p { margin: 8px 0 0; color: var(--muted); line-height: 1.5; }
.scenario-card .enter {
  margin-top: auto; padding-top: 22px;
  color: var(--brand); font-weight: 800; font-size: 14px;
}
.notice {
  margin-top: 26px; padding: 16px 18px;
  border-left: 4px solid var(--brand-2);
  background: #eef4fb; border-radius: 8px;
  color: #344054; line-height: 1.65;
}
.notice strong { margin-right: 12px; }

.chat-layout {
  max-width: 1180px; margin: 0 auto;
  display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 24px;
}
.scenario-panel, .chat-card, .result-shell {
  background: white; border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow);
}
.scenario-panel { padding: 26px; align-self: start; position: sticky; top: 96px; }
.scenario-panel h2 { margin: 0 0 16px; font-size: 25px; line-height: 1.35; }
.scenario-panel > p:not(.eyebrow):not(.privacy-note) {
  color: #475467; line-height: 1.7; font-size: 14px;
}
.scenario-rule {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--line); font-size: 14px;
}
.scenario-rule span { color: var(--muted); }
.privacy-note {
  margin: 18px 0 0; padding: 12px;
  background: var(--soft); border-radius: 10px;
  color: var(--muted); font-size: 12px; line-height: 1.6;
}
.chat-card { overflow: hidden; }
.messages {
  height: min(58vh, 620px);
  min-height: 420px;
  overflow-y: auto;
  padding: 26px;
  background: linear-gradient(#fbfcfe, #fff);
}
.message {
  display: flex; flex-direction: column;
  margin-bottom: 18px;
  max-width: 82%;
}
.message.assistant { align-items: flex-start; }
.message.user { align-items: flex-end; margin-left: auto; }
.message-label {
  font-size: 11px; color: var(--muted); margin: 0 8px 6px;
}
.bubble {
  padding: 13px 16px;
  border-radius: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.assistant .bubble { background: #eef3f8; border-bottom-left-radius: 5px; }
.user .bubble { background: var(--brand); color: white; border-bottom-right-radius: 5px; }

.composer { padding: 18px 20px 12px; border-top: 1px solid var(--line); }
.input-wrap { position: relative; }
.composer textarea {
  width: 100%; resize: vertical; min-height: 106px; max-height: 210px;
  padding: 14px 14px 54px; border: 1px solid #cfd5df; border-radius: 12px;
  outline: none; line-height: 1.6;
}
.composer textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(36,91,155,.10); }

.mic-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid #cfd5df;
  border-radius: 999px;
  background: #fff;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(16,24,40,.05);
}
.mic-btn:hover { background: #f6f9fc; }
.mic-btn.listening {
  color: #9b2c2c;
  border-color: #efb0b0;
  background: #fff2f2;
  animation: micPulse 1.15s ease-in-out infinite;
}
.mic-btn:disabled { opacity: .45; cursor: not-allowed; }
.mic-icon { font-size: 15px; line-height: 1; }
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(166,61,64,.10); }
  50% { box-shadow: 0 0 0 5px rgba(166,61,64,.08); }
}
.composer-actions {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-top: 10px;
}
.status-text { font-size: 12px; color: var(--muted); }
.primary-btn, .secondary-btn, .finish-btn, .ghost-btn {
  border: 0; border-radius: 10px; padding: 11px 18px; font-weight: 800;
}
.primary-btn { background: var(--brand); color: white; }
.primary-btn:disabled { opacity: .45; cursor: not-allowed; }
.secondary-btn { background: #eef2f6; color: var(--ink); }
.ghost-btn { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.finish-bar {
  padding: 12px 20px 18px;
  display: flex; justify-content: flex-end; align-items: center; gap: 12px;
  color: var(--muted); font-size: 13px;
}
.finish-btn { background: #fff4e8; color: #8a4b15; border: 1px solid #efc493; }
.finish-btn:disabled { opacity: .45; cursor: not-allowed; }

.error-box {
  margin: 0 20px; padding: 12px 14px; border-radius: 10px;
  background: #fff0f0; color: var(--danger); border: 1px solid #f0c2c2;
  font-size: 13px;
}
.result-shell {
  max-width: 760px; margin: 0 auto; padding: clamp(28px, 5vw, 52px);
}
.result-badge {
  display: inline-block; margin-bottom: 22px;
  padding: 7px 12px; border-radius: 999px;
  background: #eaf1f8; color: var(--brand); font-size: 13px; font-weight: 800;
}
.result-text {
  white-space: pre-wrap; line-height: 1.85;
  font-size: 16px; color: #344054;
}
.result-text strong { color: var(--ink); }
.result-actions {
  display: flex; gap: 10px; margin-top: 30px; flex-wrap: wrap;
}
footer {
  min-height: 56px; display: grid; place-items: center;
  color: #98a2b3; font-size: 12px; padding: 12px;
}

@media (max-width: 960px) {
  .scenario-grid { grid-template-columns: repeat(2, 1fr); }
  .chat-layout { grid-template-columns: 1fr; }
  .scenario-panel { position: static; }
  .messages { height: 52vh; }
}
@media (max-width: 620px) {
  .site-header { padding: 12px 16px; }
  .brand-subtitle { display: none; }
  .view { padding: 28px 14px; }
  h1 { font-size: 34px; }
  .hero-copy { font-size: 16px; }
  .access-gate { padding: 18px; }
  .access-controls { flex-direction: column; }
  .access-controls .primary-btn { width: 100%; }
  .scenario-grid { grid-template-columns: 1fr; }
  .scenario-card { min-height: 145px; }
  .message { max-width: 94%; }
  .messages { padding: 18px 14px; min-height: 360px; height: 54vh; }
  .finish-bar { align-items: stretch; flex-direction: column; }
  .finish-btn { width: 100%; }
}
