* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --ink: #1A1714;
  --ink-soft: #4A453F;
  --muted: #8A847A;
  --paper: #F3EFE6;
  --paper-deep: #E8E2D4;
  --card: #FFFcf7;
  --line: #D9D2C4;
  --accent: #0E6B5C;
  --accent-soft: #D8EBE6;
  --warn: #B86A2A;
  --ok: #1F7A52;
  --danger: #B33A3A;
  --radius: 18px;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Noto Serif SC", "Songti SC", "SimSun", serif;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
}
.hidden { display: none !important; }
.view { min-height: 100vh; max-width: 640px; margin: 0 auto; position: relative; }
.sub { color: var(--muted); font-size: 13px; line-height: 1.55; }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; text-align: center; }
b { font-weight: 600; }
.brand-kicker {
  font-size: 12px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin-bottom: 8px;
}

/* ---------- 登录页：暖纸色，无渐变蓝 ---------- */
#view-activate { background: var(--paper); }
.activate-bg {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(14,107,92,.08), transparent 60%),
    repeating-linear-gradient(0deg, transparent, transparent 23px, rgba(26,23,20,.03) 24px);
}
.activate-wrap {
  position: relative; z-index: 1;
  padding: 56px 24px 40px; display: flex; flex-direction: column; gap: 36px;
}
.brand { text-align: center; }
.brand-mark { margin: 0 auto 18px; width: 56px; height: 56px; }
.brand h1 {
  font-family: var(--serif); font-size: 34px; font-weight: 700;
  letter-spacing: .04em; color: var(--ink); margin-bottom: 10px;
}
.form-card {
  background: var(--card); border-radius: var(--radius); padding: 26px 22px;
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(26, 23, 20, .06);
  display: flex; flex-direction: column; gap: 8px;
}
/* 面板内 label/input 默认是 inline，宽屏会并排换行错位；强制纵向排布 */
#panel-login,
#panel-register {
  display: flex;
  flex-direction: column;
}
.form-card label {
  display: block;
  font-size: 12px; color: var(--muted); margin-top: 10px; letter-spacing: .06em;
}
.form-card label:first-child { margin-top: 0; }
.form-card input {
  display: block; width: 100%;
  border: 1.5px solid var(--line); border-radius: 12px; padding: 13px 14px;
  font-size: 16px; outline: none; background: #fff; color: var(--ink);
  font-family: inherit; transition: border-color .15s;
}
.form-card input:focus { border-color: var(--accent); }
.form-card .btn-primary { width: 100%; }
.auth-tabs {
  display: flex; gap: 0; margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.auth-tab {
  flex: 1; border: none; background: none; padding: 10px 8px 12px;
  font-size: 15px; color: var(--muted); cursor: pointer; font-family: inherit;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.auth-tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.invite-hint {
  font-size: 12px; color: var(--accent); margin: 4px 0 0;
  padding: 8px 10px; background: var(--accent-soft); border-radius: 8px;
}
.invite-hint.bad { color: var(--danger); background: #F8E4E4; }
.btn-primary {
  margin-top: 18px; border: none; border-radius: 12px; padding: 14px;
  background: var(--ink); color: #F3EFE6;
  font-size: 16px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-primary:active { opacity: .88; }
.btn-primary:disabled { opacity: .45; }
.btn-ghost {
  border: 1.5px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 12px; padding: 13px; font-size: 15px; cursor: pointer; font-family: inherit;
}

/* ---------- 首页 ---------- */
#view-home { background: var(--paper); }
.home-header {
  padding: 28px 20px 10px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.home-header h1 {
  font-family: var(--serif); font-size: 28px; font-weight: 700; letter-spacing: .02em;
}
.btn-logout {
  flex-shrink: 0; margin-top: 4px;
  border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.btn-logout:active { background: var(--paper-deep); }

.agent-list { padding: 12px 16px; display: flex; flex-direction: column; gap: 14px; }
.agent-card {
  background: var(--card); border-radius: var(--radius); padding: 18px 16px;
  display: flex; align-items: center; gap: 16px; cursor: pointer;
  border: 1px solid var(--line);
  box-shadow: 0 4px 18px rgba(26, 23, 20, .04);
  transition: transform .12s, border-color .12s;
}
.agent-card:active { transform: scale(.985); }
.agent-card:not(.locked):hover { border-color: var(--accent); }
.agent-card.locked { opacity: .58; cursor: default; }

.agent-icon {
  width: 56px; height: 56px; border-radius: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper-deep); color: var(--ink);
}
.agent-icon svg { width: 28px; height: 28px; }
.agent-icon.day1 { background: #E4EFEA; color: var(--accent); }
.agent-icon.day2 { background: #F0E8D8; color: #8A5A2B; }
.agent-icon.day3 { background: #E8E4F0; color: #4A3F6B; }

.agent-info { flex: 1; min-width: 0; }
.agent-name {
  font-weight: 600; font-size: 16px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.day-tag {
  font-size: 11px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); border-radius: 6px; padding: 2px 8px;
  letter-spacing: .04em;
}
.agent-desc { font-size: 13px; color: var(--muted); margin-top: 3px; }
.agent-status { font-size: 12px; margin-top: 6px; font-weight: 500; }
.agent-status.done { color: var(--ok); }
.agent-status.todo { color: var(--warn); }
.agent-status.lock { color: var(--muted); }
.home-tip { padding: 8px 24px 40px; font-size: 13px; color: var(--muted); }

/* ---------- 聊天 ---------- */
#view-chat {
  display: flex; flex-direction: column; height: 100vh; height: 100dvh;
  background: var(--paper);
}
.chat-header {
  display: flex; align-items: center; gap: 8px; padding: 12px 12px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.btn-icon {
  border: none; background: none; font-size: 26px; line-height: 1;
  color: var(--ink); cursor: pointer; padding: 4px 10px; font-family: inherit;
}
.chat-title { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; min-width: 0; }
.chat-title span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-card {
  border: none; border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 600;
  background: var(--ink); color: #F3EFE6; cursor: pointer; white-space: nowrap; font-family: inherit;
}
.btn-card:disabled { opacity: .55; }
.messages { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 12px; }
.msg {
  max-width: 86%; padding: 12px 14px; border-radius: 16px; font-size: 15px;
  white-space: pre-wrap; word-break: break-word;
}
.msg.user {
  align-self: flex-end; background: var(--ink); color: #F3EFE6;
  border-bottom-right-radius: 5px;
}
.msg.assistant {
  align-self: flex-start; background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-bottom-left-radius: 5px;
}
.msg.assistant.typing::after { content: "▍"; animation: blink 1s infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }
.msg.error-msg { background: #F8E4E4; color: var(--danger); align-self: center; font-size: 13px; border: none; }
.composer {
  display: flex; align-items: flex-end; gap: 10px; padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; border: 1.5px solid var(--line); border-radius: 14px;
  padding: 11px 14px; font-size: 16px; font-family: inherit; resize: none;
  outline: none; max-height: 120px; line-height: 1.5; background: #fff;
}
.composer textarea:focus { border-color: var(--accent); }
.btn-send {
  width: 42px; height: 42px; border: none; border-radius: 50%;
  background: var(--ink); color: #F3EFE6;
  font-size: 18px; cursor: pointer; flex-shrink: 0;
}
.btn-send:disabled { opacity: .45; }

/* ---------- 卡片弹窗 + 海报 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(26, 23, 20, .55); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-body {
  background: var(--paper); width: 100%; max-width: 640px; max-height: 90vh;
  border-radius: 22px 22px 0 0; display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 8px;
}
.modal-head h2 { font-family: var(--serif); font-size: 18px; }
.modal-scroll { overflow-y: auto; padding: 8px 16px 12px; flex: 1; }

.card-poster {
  width: 100%; max-width: 420px; margin: 0 auto;
  padding: 28px 24px 22px;
  border-radius: 4px;
  background: #FFFcf7;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 8px 28px rgba(26, 23, 20, .08);
  position: relative;
  overflow: hidden;
}
.card-poster::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: var(--accent);
}
.card-poster.theme-day1::before { background: #0E6B5C; }
.card-poster.theme-day2::before { background: #8A5A2B; }
.card-poster.theme-day3::before { background: #4A3F6B; }

.poster-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px; font-size: 11px; letter-spacing: .12em; color: var(--muted);
}
.poster-day {
  font-weight: 700; color: var(--accent); letter-spacing: .08em;
  background: var(--accent-soft); padding: 3px 10px; border-radius: 999px;
}
.theme-day2 .poster-day { color: #8A5A2B; background: #F0E8D8; }
.theme-day3 .poster-day { color: #4A3F6B; background: #E8E4F0; }

.poster-title {
  font-family: var(--serif); font-size: 26px; font-weight: 700;
  line-height: 1.25; margin-bottom: 6px; letter-spacing: .02em;
}
.poster-nick { font-size: 13px; color: var(--muted); margin-bottom: 20px; }

.poster-body { font-size: 14px; line-height: 1.7; }
.poster-field { margin-bottom: 16px; }
.poster-field:last-child { margin-bottom: 0; }
.poster-label {
  display: block; font-size: 11px; letter-spacing: .14em;
  color: var(--muted); margin-bottom: 4px; font-weight: 600;
}
.poster-value { color: var(--ink); font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.poster-value.lead {
  font-family: var(--serif); font-size: 17px; font-weight: 600; line-height: 1.45;
}
.poster-list { padding-left: 18px; margin: 0; }
.poster-list li { margin: 3px 0; }

.poster-foot {
  margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; font-size: 11px; color: var(--muted);
  letter-spacing: .06em;
}

.share-text-fold {
  max-width: 420px; margin: 14px auto 0; font-size: 13px; color: var(--muted);
}
.share-text-fold summary { cursor: pointer; user-select: none; }
.share-text-fold pre {
  margin-top: 8px; padding: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; white-space: pre-wrap; word-break: break-word;
  font-family: inherit; font-size: 13px; color: var(--ink);
}

.modal-actions {
  display: flex; gap: 10px; padding: 12px 16px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--paper);
}
.modal-actions button { flex: 1; margin-top: 0; }

/* 离屏导出宿主：固定宽度保证 PNG 清晰 */
.poster-export-host {
  position: fixed; left: -9999px; top: 0; width: 720px; pointer-events: none; opacity: 0;
}
.poster-export-host .card-poster {
  max-width: none; width: 720px; padding: 48px 44px 36px;
  box-shadow: none;
}
.poster-export-host .poster-title { font-size: 36px; }
.poster-export-host .poster-value.lead { font-size: 22px; }
.poster-export-host .poster-value { font-size: 17px; }
.poster-export-host .poster-body { font-size: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(26, 23, 20, .92); color: #F3EFE6; font-size: 14px;
  padding: 10px 18px; border-radius: 12px; z-index: 200; max-width: 80vw; text-align: center;
}
