:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-soft: #f1f3f8;
  --ink: #171923;
  --muted: #767b8c;
  --line: #e5e7ef;
  --brand: #4f46e5;
  --brand-strong: #3730a3;
  --brand-soft: #ecebff;
  --amber: #a16207;
  --amber-soft: #fef3c7;
  --risk: #b42318;
  --safe: #0f766e;
  --shadow: 0 18px 48px rgba(26, 28, 42, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(79, 70, 229, 0.07), rgba(79, 70, 229, 0) 260px),
    var(--bg);
  color: var(--ink);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "PingFang SC",
    "Microsoft YaHei",
    "Segoe UI",
    sans-serif;
  font-size: 15px;
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(760px, 100%);
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  gap: 6px;
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 12px calc(10px + env(safe-area-inset-bottom));
  overflow: hidden;
}

.app-header {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 2px 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark,
.candidate-avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #c7d2fe, #ede9fe);
  color: var(--brand-strong);
  font-weight: 850;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.brand-mark {
  width: 36px;
  height: 36px;
  font-size: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  overflow: hidden;
  font-size: 18px;
  font-weight: 850;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.icon-button,
.ghost-button,
.icon-close {
  min-height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  color: var(--brand);
  box-shadow: 0 8px 22px rgba(25, 28, 45, 0.08);
}

.icon-button {
  width: 38px;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 10px;
}

.icon-button span {
  width: 18px;
  height: 2px;
  display: block;
  border-radius: 999px;
  background: var(--brand);
}

.ghost-button {
  min-width: 74px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
}

.login-button {
  min-width: 58px;
  max-width: 94px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-button {
  min-width: 58px;
}

.notice-card,
.candidate-card,
.composer,
.drawer-panel {
  border: 1px solid rgba(229, 231, 239, 0.9);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.notice-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius);
}

.service-scope-card {
  border-color: #fed7aa;
  background: #fff7ed;
  box-shadow: 0 12px 28px rgba(154, 52, 18, 0.1);
}

.notice-card strong {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #ea580c;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.notice-card span {
  display: -webkit-box;
  overflow: hidden;
  color: #7c2d12;
  font-size: 11.5px;
  font-weight: 720;
  line-height: 1.45;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.candidate-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
}

.candidate-card:active {
  transform: translateY(1px);
}

.candidate-avatar {
  width: 34px;
  height: 34px;
  font-size: 12px;
}

.candidate-main {
  min-width: 0;
}

.candidate-main span {
  color: var(--muted);
  font-size: 11px;
}

.candidate-main strong {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  font-size: 14px;
  font-weight: 820;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.tag-row em,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: #555b6f;
  font-size: 10.5px;
  font-style: normal;
}

.status-badge {
  align-self: start;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #fee2e2;
  color: var(--risk);
  font-size: 11px;
  font-weight: 760;
  line-height: 22px;
}

.status-badge.ready {
  background: #ccfbf1;
  color: var(--safe);
}

.profile-empty-state {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid #dddffc;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 32px rgba(26, 28, 42, 0.08);
}

.profile-empty-state[hidden] {
  display: none;
}

.profile-empty-state div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.profile-empty-state strong {
  font-size: 16px;
  font-weight: 850;
}

.profile-empty-state span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.profile-empty-state button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 820;
  white-space: nowrap;
}

.needs-profile .chat-log {
  opacity: 0.62;
}

.chat-log {
  min-height: 0;
  overscroll-behavior: contain;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 2px 8px;
  scroll-behavior: smooth;
}

.chat-log::after {
  content: "";
  flex: 0 0 2px;
}

.scroll-bottom {
  position: fixed;
  left: 50%;
  bottom: calc(118px + env(safe-area-inset-bottom));
  z-index: 18;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid #dddffc;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--brand);
  font-size: 13px;
  font-weight: 820;
  transform: translateX(-50%);
  box-shadow: 0 12px 28px rgba(25, 28, 45, 0.14);
}

.scroll-bottom[hidden] {
  display: none;
}

.message {
  max-width: 88%;
  display: grid;
  gap: 5px;
}

.message.assistant {
  align-self: start;
}

.message.user {
  align-self: end;
}

.message-role {
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.bubble {
  position: relative;
  border-radius: 8px;
  padding: 12px 13px;
  line-height: 1.65;
  word-break: break-word;
}

.markdown-body p,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre {
  margin: 0;
}

.markdown-body {
  white-space: normal;
}

.markdown-body p + p,
.markdown-body p + ul,
.markdown-body p + ol,
.markdown-body ul + p,
.markdown-body ol + p,
.markdown-body blockquote + p,
.markdown-body pre + p {
  margin-top: 8px;
}

.markdown-body h3,
.markdown-body h4,
.markdown-body h5 {
  margin: 2px 0 7px;
  font-size: 15px;
  line-height: 1.45;
}

.markdown-body ul,
.markdown-body ol {
  display: grid;
  gap: 4px;
  padding-left: 20px;
}

.markdown-body blockquote {
  padding-left: 10px;
  border-left: 3px solid #c7d2fe;
  color: #555b6f;
}

.markdown-body code {
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--panel-soft);
  color: #3730a3;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.markdown-body pre {
  overflow-x: auto;
  padding: 10px;
  border-radius: 8px;
  background: #171923;
  color: #f8fafc;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.assistant.collapsed .bubble {
  max-height: 260px;
  overflow: hidden;
}

.assistant.collapsed .bubble::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 64px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff);
}

.message-actions {
  display: flex;
  gap: 8px;
  padding: 0 4px;
}

.copy-message {
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted);
  font-size: 12px;
}

.thinking .bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.typing-dot {
  width: 6px;
  height: 6px;
  display: inline-block;
  border-radius: 50%;
  background: var(--brand);
  animation: pulse 1s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.12s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes pulse {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  50% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

.assistant .bubble {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(26, 28, 42, 0.06);
}

.user .bubble {
  background: var(--brand);
  color: #fff;
}

.prompt-area {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  transition: max-height 0.18s ease, opacity 0.18s ease, padding 0.18s ease;
}

.prompt-toggle {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(25, 28, 45, 0.08);
}

.prompt-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 1px 0 2px;
  scrollbar-width: none;
}

.prompt-area.compact .prompt-strip {
  max-height: 0;
  opacity: 0;
  padding: 0;
  pointer-events: none;
}

.prompt-area.compact {
  grid-template-columns: auto;
}

.prompt-strip::-webkit-scrollbar {
  display: none;
}

.prompt-strip button {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid #dddffc;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 720;
}

.composer {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 8px;
  align-items: end;
  padding: 7px;
  border-radius: var(--radius);
}

.composer textarea {
  width: 100%;
  max-height: 104px;
  min-height: 38px;
  resize: none;
  border: 0;
  outline: 0;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 9px 10px;
  line-height: 1.38;
}

.composer:focus-within {
  border-color: rgba(79, 70, 229, 0.22);
  box-shadow: 0 18px 48px rgba(79, 70, 229, 0.16);
}

.composer button,
.drawer-new {
  min-height: 38px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.composer button:disabled,
.drawer-new:disabled {
  opacity: 0.64;
  cursor: default;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

.login-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: 14px;
  pointer-events: none;
}

.login-modal.open {
  pointer-events: auto;
}

.login-backdrop {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: rgba(15, 18, 30, 0.36);
  transition: opacity 0.18s ease;
}

.login-modal.open .login-backdrop {
  opacity: 1;
}

.login-panel {
  position: relative;
  width: min(100%, 430px);
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  display: grid;
  gap: 16px;
  overflow: hidden;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(110%);
  transition: transform 0.2s ease, opacity 0.18s ease;
}

.login-modal.open .login-panel {
  opacity: 1;
  transform: translateY(0);
}

.login-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.login-head h2 {
  font-size: 20px;
}

.login-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.phone-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.phone-field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  padding: 0 14px;
  color: var(--ink);
  font-size: 16px;
}

.phone-field select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}

.phone-field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.phone-field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 10px;
  align-items: end;
}

.code-button {
  min-height: 48px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 820;
}

.code-button:disabled {
  opacity: 0.62;
}

.sms-hint {
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.sms-hint.ok {
  color: var(--safe);
}

.sms-hint.error {
  color: var(--risk);
}

.login-submit,
.drawer-login {
  min-height: 44px;
  border-radius: 8px;
  font-weight: 800;
}

.login-submit.secondary {
  border: 1px solid #dddffc;
  background: #fff;
  color: var(--brand);
}

.login-submit.danger {
  background: #fff1f2;
  color: var(--risk);
}

.account-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.account-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.account-card strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-panel {
  width: min(100%, 560px);
}

.share-grid {
  display: grid;
  gap: 12px;
}

.qr-card,
.share-copy-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.qr-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 16px;
}

.qr-card img {
  width: min(220px, 68vw);
  aspect-ratio: 1;
  display: block;
  border: 10px solid #fff;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(26, 28, 42, 0.08);
}

.qr-card span,
.share-copy-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.share-copy-card {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.share-copy-card p {
  color: #4b5265;
  font-size: 13px;
  line-height: 1.7;
  word-break: break-word;
}

.share-small-button {
  min-height: 34px;
  justify-self: stretch;
  border: 1px solid #dddffc;
  border-radius: 8px;
  background: #fff;
  color: var(--brand);
  font-size: 13px;
  font-weight: 820;
}

.drawer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.drawer-links button {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff;
  color: var(--brand);
  font-size: 12px;
  font-weight: 760;
  text-decoration: none;
}

.consent-copy {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.consent-copy p {
  margin: 0;
  color: #4b5265;
  font-size: 13px;
  line-height: 1.6;
}

.consent-check {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: #4b5265;
  font-size: 13px;
  line-height: 1.55;
}

.consent-check input {
  width: 16px;
  height: 16px;
  margin-top: 3px;
}

.consent-check button {
  display: inline;
  min-height: 0;
  padding: 0;
  background: transparent;
  color: var(--brand);
  font-weight: 760;
  text-decoration: none;
}

.legal-panel {
  max-height: min(78vh, 640px);
}

.legal-card-copy {
  max-height: min(58vh, 460px);
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.legal-card-copy section {
  display: grid;
  gap: 4px;
}

.legal-card-copy h3 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
}

.legal-card-copy p {
  margin: 0;
  color: #4b5265;
  font-size: 13px;
  line-height: 1.65;
}

.legal-updated {
  color: var(--muted) !important;
  font-size: 12px !important;
}

.drawer-danger {
  min-height: 42px;
  margin-top: auto;
  border-radius: 8px;
  background: #fff1f2;
  color: #be123c;
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 60;
  max-width: min(84vw, 360px);
  min-height: 34px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(23, 25, 35, 0.88);
  color: #fff;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 0 12px 34px rgba(18, 20, 32, 0.24);
}

.toast.show {
  display: flex;
}

.identity-note {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  font-weight: 760;
}

.login-submit {
  background: var(--brand);
  color: #fff;
}

.drawer-login {
  border: 1px solid #dddffc;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.sync-status-card {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.sync-status-card span {
  font-size: 14px;
  font-weight: 850;
}

.sync-status-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.sync-status-card.cloud {
  border-color: #c7d2fe;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.sync-status-card.guest {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.drawer-add-profile {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 2px;
  background: transparent;
  color: var(--ink);
  font-weight: 820;
  text-align: left;
}

.profile-list {
  display: grid;
  gap: 4px;
}

.profile-item {
  width: 100%;
  min-height: 38px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto auto;
  gap: 9px;
  align-items: center;
  padding: 5px 2px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.profile-item::before {
  content: "▤";
  color: var(--muted);
  font-size: 16px;
}

.profile-item.active {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.profile-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-mini-action {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 820;
}

.profile-mini-action.danger {
  color: var(--risk);
}

.profile-picker-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}

.profile-picker-item {
  min-height: 44px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 820;
  text-align: left;
  padding: 0 12px;
}

.profile-picker-add {
  min-height: 44px;
  border: 1px dashed #c7d2fe;
  border-radius: 8px;
  background: #fff;
  color: var(--brand);
  font-weight: 850;
  text-align: left;
  padding: 0 12px;
}

.profile-form-grid {
  display: grid;
  gap: 12px;
  min-height: 0;
}

.profile-modal .login-panel {
  width: min(100%, 520px);
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.profile-modal .profile-form-grid {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}

.profile-modal .login-submit {
  align-self: end;
}

.profile-picker-modal .login-panel {
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  max-height: min(560px, calc(100vh - 28px));
  max-height: min(560px, calc(100dvh - 28px));
}

.profile-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.profile-chip-row button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #555b6f;
  font-size: 12px;
  font-weight: 760;
}

.profile-chip-row button.active {
  border-color: #c7d2fe;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.profile-chip-row button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.drawer.open {
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: rgba(15, 18, 30, 0.36);
  transition: opacity 0.18s ease;
}

.drawer.open .drawer-backdrop {
  opacity: 1;
}

.drawer-panel {
  position: absolute;
  inset: 0 auto 0 0;
  width: min(82vw, 340px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: calc(22px + env(safe-area-inset-top)) 18px 22px;
  transform: translateX(-104%);
  transition: transform 0.2s ease;
}

.drawer.open .drawer-panel {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-head h2 {
  font-size: 20px;
}

.icon-close {
  width: 40px;
  padding: 0;
  font-size: 26px;
  line-height: 40px;
}

.drawer-section {
  display: grid;
  gap: 10px;
}

.drawer-section > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.drawer-profile,
.history-list {
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
  color: #555b6f;
  font-size: 13px;
  line-height: 1.55;
}

.drawer-profile-button {
  width: 100%;
  display: block;
  border: 0;
  text-align: left;
  white-space: pre-wrap;
  cursor: pointer;
}

.drawer-profile-button:active {
  background: #e8ebf3;
}

.history-item {
  display: block;
  width: 100%;
  min-height: 40px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  padding: 9px 10px;
}

@media (min-width: 860px) {
  :root {
    --desktop-page-w: min(calc(100vw - 64px), 1180px);
    --desktop-page-left: calc((100vw - var(--desktop-page-w)) / 2);
    --desktop-sidebar-w: 300px;
    --desktop-gap: 18px;
  }

  body {
    background:
      linear-gradient(180deg, rgba(79, 70, 229, 0.06), rgba(79, 70, 229, 0) 280px),
      #eef1f7;
  }

  .app-shell {
    width: calc(var(--desktop-page-w) - var(--desktop-sidebar-w) - var(--desktop-gap));
    height: calc(100vh - 48px);
    height: calc(100dvh - 48px);
    max-height: none;
    min-height: 680px;
    margin-left: calc(var(--desktop-page-left) + var(--desktop-sidebar-w) + var(--desktop-gap));
    margin-right: var(--desktop-page-left);
    margin-top: 24px;
    margin-bottom: 24px;
    padding: 18px;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
    gap: 10px;
    border: 1px solid rgba(229, 231, 239, 0.82);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 28px 80px rgba(26, 28, 42, 0.14);
  }

  .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
    padding-bottom: 4px;
  }

  #historyToggle {
    display: none;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  h1 {
    font-size: 22px;
  }

  .brand p {
    font-size: 13px;
  }

  .header-actions {
    gap: 10px;
  }

  .ghost-button {
    min-height: 40px;
    min-width: 84px;
    font-size: 13px;
  }

  .share-button {
    min-width: 76px;
  }

  .share-grid {
    grid-template-columns: 240px minmax(0, 1fr);
    align-items: stretch;
  }

  .qr-card {
    align-content: center;
  }

  .notice-card {
    padding: 8px 12px;
  }

  .notice-card span {
    font-size: 12px;
    -webkit-line-clamp: 2;
  }

  .candidate-card {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    padding: 12px 14px;
  }

  .candidate-avatar {
    width: 42px;
    height: 42px;
    font-size: 14px;
  }

  .candidate-main strong {
    font-size: 16px;
  }

  .chat-log {
    gap: 14px;
    padding: 10px 8px 12px;
  }

  .message {
    max-width: min(76%, 680px);
  }

  .bubble {
    font-size: 15px;
  }

  .prompt-area {
    gap: 8px;
  }

  .prompt-toggle,
  .prompt-strip button {
    min-height: 34px;
    font-size: 13px;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) 72px;
    gap: 10px;
    padding: 10px;
  }

  .composer textarea {
    min-height: 44px;
    max-height: 150px;
    padding: 12px;
  }

  .composer button {
    min-height: 44px;
  }

  .drawer {
    inset: 24px auto 24px var(--desktop-page-left);
    width: var(--desktop-sidebar-w);
    z-index: 20;
    pointer-events: auto;
  }

  .drawer-backdrop,
  .drawer-head .icon-close {
    display: none;
  }

  .drawer-panel {
    inset: 0;
    width: var(--desktop-sidebar-w);
    border-radius: 18px;
    padding: 22px 18px;
    transform: none;
    overflow: auto;
  }

  .login-modal {
    place-items: center;
  }

  .login-panel {
    max-height: calc(100vh - 64px);
    max-height: calc(100dvh - 64px);
    transform: translateY(14px) scale(0.98);
  }

  .login-modal.open .login-panel {
    transform: translateY(0) scale(1);
  }

  .profile-modal .login-panel {
    max-height: min(760px, calc(100vh - 64px));
    max-height: min(760px, calc(100dvh - 64px));
  }

  .profile-picker-modal .login-panel {
    max-height: min(620px, calc(100vh - 64px));
    max-height: min(620px, calc(100dvh - 64px));
  }

  .drawer-head h2 {
    font-size: 22px;
  }

  .drawer-section {
    gap: 8px;
  }

  .drawer-profile,
  .history-list {
    padding: 10px;
  }

  .toast {
    bottom: 34px;
  }
}

@media (min-width: 860px) and (max-width: 1080px) {
  .app-shell {
    width: calc(100vw - 328px);
    margin-left: 316px;
    margin-right: 12px;
  }

  .drawer {
    left: 12px;
  }

  .drawer-panel {
    width: 286px;
  }
}

@media (max-width: 520px) {
  .app-header {
    grid-template-columns: 38px minmax(0, 1fr) auto;
  }

  .brand p,
  #shareApp,
  #phoneLogin {
    display: none;
  }

  .header-actions {
    gap: 0;
  }

  .ghost-button {
    min-width: 70px;
    padding: 0 12px;
  }
}

@media (max-width: 380px) {
  .app-header {
    grid-template-columns: 38px minmax(0, 1fr) auto;
  }

  .header-actions {
    justify-content: flex-end;
  }

  .candidate-card {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .candidate-avatar {
    width: 42px;
    height: 42px;
  }

  .status-badge {
    grid-column: 2;
    justify-self: start;
  }

  .ghost-button {
    min-width: 60px;
    padding: 0 10px;
  }

  .share-button {
    min-width: 56px;
  }
}
