/* ============================================================
   IELTS Agent — Editorial Design System
   杂志编辑风：暖纸底 + 藏蓝 + 琥珀金
   ============================================================ */

:root {
  --paper: #f6f1e7;
  --paper-deep: #efe8d8;
  --card: #fffdf8;
  --ink: #22303e;
  --ink-soft: #5c6a78;
  --navy: #1a3c6e;
  --navy-deep: #12294d;
  --gold: #b8860b;
  --gold-soft: #d9b45c;
  --line: #e3dac6;
  --serif: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
  --sans: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --mono: Consolas, "Courier New", monospace;
  --shadow: 0 2px 10px rgba(28, 42, 58, 0.07);
  --shadow-lg: 0 8px 28px rgba(28, 42, 58, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
}

body {
  background-image:
    radial-gradient(rgba(184, 134, 11, 0.035) 1px, transparent 1px);
  background-size: 26px 26px;
}

/* ---------- Header ---------- */
header.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 0 28px; height: 58px;
  background: linear-gradient(90deg, var(--navy-deep), var(--navy));
  color: #f3ead7;
  box-shadow: 0 2px 14px rgba(18, 41, 77, 0.35);
}
header.topbar .brand {
  font-family: var(--serif);
  font-size: 19px; font-weight: bold; letter-spacing: 0.5px;
  color: #fff; cursor: pointer; user-select: none;
}
header.topbar .brand span { color: var(--gold-soft); }
header.topbar nav { display: flex; gap: 4px; margin-left: 10px; }
header.topbar nav a {
  color: #cdd9e8; text-decoration: none; font-size: 13.5px;
  padding: 6px 14px; border-radius: 999px; transition: all .18s;
}
header.topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
header.topbar nav a.active { background: var(--gold); color: #fff; font-weight: 600; }
header.topbar .spacer { flex: 1; }
header.topbar .api-badge {
  font-size: 12px; padding: 5px 13px; border-radius: 999px;
  background: rgba(255,255,255,.1); color: #e8ddc6;
  display: flex; align-items: center; gap: 6px;
}
header.topbar .api-badge .dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
header.topbar .api-badge .dot.ok { background: #7fd48b; box-shadow: 0 0 6px #7fd48b; }
header.topbar .api-badge .dot.no { background: #e58a7c; box-shadow: 0 0 6px #e58a7c; }
header.topbar .quit {
  background: none; border: 1px solid rgba(255,255,255,.25); color: #e8ddc6;
  font-size: 13px; padding: 5px 13px; border-radius: 999px; cursor: pointer;
  transition: all .18s; font-family: var(--sans);
}
header.topbar .quit:hover { background: #c0392b; border-color: #c0392b; color: #fff; }

/* ---------- Layout ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 36px 28px 90px; }
.page.hero { padding-top: 54px; }

/* ---------- Hero ---------- */
.hero h1 {
  font-family: var(--serif); font-size: 40px; font-weight: bold;
  color: var(--navy); letter-spacing: 0.5px; margin-bottom: 10px;
}
.hero h1 em { font-style: normal; color: var(--gold); }
.hero .subtitle { color: var(--ink-soft); font-size: 16px; margin-bottom: 42px; }
.hero .rule {
  width: 64px; height: 4px; background: var(--gold); border: none;
  margin: 0 0 14px;
}

/* ---------- Cards ---------- */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 22px;
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 26px 24px 22px; cursor: pointer; position: relative; overflow: hidden;
  box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s, border-color .18s;
  text-decoration: none; color: inherit; display: block;
}
.card:hover {
  transform: translateY(-4px); box-shadow: var(--shadow-lg);
  border-color: var(--gold-soft);
}
.card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--navy), var(--gold));
  opacity: 0; transition: opacity .18s;
}
.card:hover::before { opacity: 1; }
.card .icon {
  font-size: 34px; line-height: 1; margin-bottom: 14px; display: block;
}
.card .name {
  font-family: var(--serif); font-size: 21px; font-weight: bold;
  color: var(--navy); margin-bottom: 6px;
}
.card .tagline { font-size: 13px; color: var(--gold); font-weight: 600; margin-bottom: 12px; }
.card .hint { font-size: 13px; color: var(--ink-soft); }
.card .go {
  position: absolute; right: 20px; top: 26px; font-size: 18px;
  color: var(--gold-soft); transition: transform .18s;
}
.card:hover .go { transform: translateX(4px); color: var(--gold); }

/* ---------- Chat ---------- */
.chat-shell { display: flex; flex-direction: column; height: 100vh; }
.chat-info {
  padding: 14px 30px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
}
.chat-info .icon { font-size: 26px; }
.chat-info .cname { font-family: var(--serif); font-size: 17px; font-weight: bold; color: var(--navy); }
.chat-info .ctag { font-size: 12px; color: var(--ink-soft); }
.chat-info .actions { margin-left: auto; display: flex; gap: 8px; }
.btn {
  font-family: var(--sans); font-size: 13px; padding: 7px 15px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; transition: all .16s; text-decoration: none; display: inline-block;
}
.btn:hover { border-color: var(--gold); color: var(--navy); background: #fdfaf2; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-deep); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.gold:hover { background: #a07609; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.messages { flex: 1; overflow-y: auto; padding: 28px 30px; }
.welcome {
  max-width: 640px; margin: 60px auto; text-align: center; color: var(--ink-soft);
}
.welcome .big { font-size: 40px; margin-bottom: 14px; }
.welcome h2 { font-family: var(--serif); color: var(--navy); margin-bottom: 10px; }
.welcome .hintbox {
  text-align: left; background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--gold); border-radius: 10px; padding: 16px 20px;
  margin-top: 22px; font-size: 14px;
}

.msg { max-width: 820px; margin: 0 auto 22px; display: flex; flex-direction: column; }
.msg.user { align-items: flex-end; }
.msg .who { font-size: 11.5px; letter-spacing: 1.5px; color: #9a8f77; margin: 0 4px 6px; text-transform: uppercase; }
.msg .bubble {
  padding: 16px 20px; border-radius: 16px; background: #fff;
  border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 14.5px; max-width: 100%; overflow-wrap: break-word;
}
.msg.user .bubble {
  background: var(--navy); color: #eef2f8; border-color: var(--navy);
  border-top-right-radius: 4px;
}
.msg.assistant .bubble { border-top-left-radius: 4px; }
.msg .time { font-size: 11px; color: #b3a98f; margin-top: 6px; }
.msg .cursor { display: inline-block; width: 8px; height: 16px; background: var(--gold); animation: blink 1s infinite; vertical-align: -2px; }
@keyframes blink { 0%,100% {opacity: 1;} 50% {opacity: 0;} }

/* markdown inside bubbles */
.bubble h1, .bubble h2, .bubble h3, .bubble h4 { color: var(--navy); margin: 14px 0 8px; line-height: 1.4; }
.bubble h1 { font-size: 20px; border-bottom: 1px solid var(--line); padding-bottom: 5px; }
.bubble h2 { font-size: 17px; }
.bubble h3 { font-size: 15px; }
.bubble p { margin: 8px 0; }
.bubble ul, .bubble ol { margin: 8px 0 8px 22px; }
.bubble li { margin: 4px 0; }
.bubble table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13.5px; }
.bubble th, .bubble td { border: 1px solid #d9d0bd; padding: 6px 10px; text-align: left; }
.bubble th { background: var(--navy); color: #fff; font-weight: normal; }
.bubble code {
  background: rgba(26, 60, 110, 0.08); padding: 2px 6px; border-radius: 4px;
  font-family: var(--mono); font-size: 13px;
}
.bubble pre {
  background: var(--navy-deep); color: #e6e0cf; padding: 14px 16px;
  border-radius: 10px; overflow-x: auto; margin: 10px 0; font-size: 12.5px;
}
.bubble pre code { background: none; color: inherit; padding: 0; }
.bubble blockquote {
  border-left: 3px solid var(--gold); padding: 6px 14px; margin: 10px 0;
  background: var(--paper-deep); color: #5a5140; border-radius: 0 8px 8px 0;
}
.bubble hr { border: none; border-top: 1px dashed #cfc5ae; margin: 14px 0; }
.bubble a { color: var(--navy); }
.msg.user .bubble h1, .msg.user .bubble h2, .msg.user .bubble h3 { color: #f3d489; }
.msg.user .bubble table th { background: rgba(255,255,255,.15); }
.msg.user .bubble table th, .msg.user .bubble td { border-color: rgba(255,255,255,.2); }
.msg.user .bubble code { background: rgba(255,255,255,.15); color: #ffe9b8; }
.msg.user .bubble pre { background: rgba(0,0,0,.3); }

/* ---------- Input area ---------- */
.input-bar {
  padding: 14px 30px 20px; background: var(--card); border-top: 1px solid var(--line);
}
.input-wrap {
  max-width: 860px; margin: 0 auto; display: flex; gap: 12px; align-items: flex-end;
}
.input-wrap textarea {
  flex: 1; resize: vertical; min-height: 54px; max-height: 220px;
  border: 1px solid var(--line); border-radius: 14px; padding: 13px 16px;
  font-family: var(--sans); font-size: 14.5px; background: #fff; color: var(--ink);
  outline: none; transition: border-color .18s, box-shadow .18s;
}
.input-wrap textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(184,134,11,.12); }
.send-btn {
  min-width: 108px; height: 54px; border-radius: 14px; border: none; cursor: pointer;
  background: var(--navy); color: #fff; font-size: 15px; font-weight: 600;
  font-family: var(--sans); transition: background .18s;
}
.send-btn:hover { background: var(--navy-deep); }
.send-btn:disabled { background: #9aa7b8; cursor: not-allowed; }
.input-hint { max-width: 860px; margin: 8px auto 0; font-size: 11.5px; color: #a89d84; text-align: center; }

/* ---------- Settings ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.panel-head {
  padding: 18px 26px; border-bottom: 1px solid var(--line);
  font-family: var(--serif); font-size: 18px; font-weight: bold; color: var(--navy);
  display: flex; align-items: center; gap: 10px;
}
.panel-body { padding: 24px 26px; }
.preset-list { display: flex; flex-direction: column; gap: 16px; }
.preset-item {
  border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px;
  display: flex; align-items: center; gap: 14px; cursor: pointer; transition: all .16s;
  background: #fff;
}
.preset-item:hover { border-color: var(--gold-soft); }
.preset-item.active { border-color: var(--gold); background: #fdf9ee; box-shadow: 0 0 0 2px rgba(184,134,11,.15); }
.preset-item .pname { font-weight: 600; color: var(--navy); font-size: 15px; }
.preset-item .pdetail { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.preset-item .radio {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.preset-item.active .radio { border-color: var(--gold); }
.preset-item.active .radio::after {
  content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--gold);
}
.preset-item .pdel {
  margin-left: auto; background: none; border: none; color: #c9b896; cursor: pointer;
  font-size: 15px; padding: 4px 8px; border-radius: 8px;
}
.preset-item .pdel:hover { color: #c0392b; background: #fdf0ee; }

.form-row { margin-bottom: 16px; }
.form-row label {
  display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 6px;
}
.form-row input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
  font-size: 14px; font-family: var(--sans); outline: none; background: #fff;
  transition: border-color .18s, box-shadow .18s;
}
.form-row input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(184,134,11,.12); }
.form-row .help { font-size: 12px; color: #a89d84; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }

.test-result {
  margin-top: 14px; padding: 12px 16px; border-radius: 10px; font-size: 13.5px;
}
.test-result.ok { background: #eef8ef; color: #2e7d32; border: 1px solid #c3e3c6; }
.test-result.fail { background: #fdf0ee; color: #b23b2e; border: 1px solid #f0c9c3; }

/* ---------- History ---------- */
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 22px; display: flex; align-items: center; gap: 16px;
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
  transition: all .16s;
}
.history-item:hover { border-color: var(--gold-soft); transform: translateX(3px); }
.history-item .hicon { font-size: 24px; }
.history-item .htitle { font-weight: 600; color: var(--navy); font-size: 15px; }
.history-item .hmeta { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.history-item .hbadge {
  font-size: 11px; background: var(--paper-deep); border: 1px solid var(--line);
  padding: 2px 10px; border-radius: 999px; color: #7d6f55;
}
.history-item .hdel {
  margin-left: auto; background: none; border: none; color: #c9b896; cursor: pointer;
  font-size: 15px; padding: 6px 10px; border-radius: 8px;
}
.history-item .hdel:hover { color: #c0392b; background: #fdf0ee; }
.empty-state { text-align: center; padding: 70px 20px; color: var(--ink-soft); }
.empty-state .big { font-size: 46px; margin-bottom: 14px; }

/* ---------- Banner ---------- */
.banner {
  background: #fdf6e3; border: 1px solid #e8d9a8; border-left: 5px solid var(--gold);
  border-radius: 12px; padding: 14px 20px; margin-bottom: 26px; font-size: 14px;
  display: flex; align-items: center; gap: 14px; color: #6d5b24;
}
.banner a { color: var(--navy); font-weight: 600; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--navy-deep); color: #fff; padding: 12px 26px; border-radius: 999px;
  font-size: 13.5px; box-shadow: var(--shadow-lg); z-index: 200;
  transition: transform .3s; opacity: 0; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cfc3a6; border-radius: 99px; border: 2px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: #b8a97f; }

@media (max-width: 720px) {
  .hero h1 { font-size: 30px; }
  .form-grid { grid-template-columns: 1fr; }
  header.topbar { padding: 0 14px; gap: 8px; }
  .page { padding: 24px 16px 70px; }
}

/* ---------- Production web additions ---------- */
.user-badge { font-size:12px; color:var(--ink-soft); padding:5px 10px; border:1px solid var(--line); border-radius:999px; background:#fff; white-space:nowrap; }
.auth-shell { min-height:calc(100vh - 64px); display:grid; place-items:center; padding:34px 18px 90px; }
.auth-card { width:min(440px,100%); background:#fff; border:1px solid var(--line); border-radius:20px; box-shadow:var(--shadow-lg); padding:34px 34px 30px; }
.auth-mark { font-family:Georgia,serif; font-size:17px; font-weight:700; letter-spacing:1px; color:var(--navy); margin-bottom:22px; }
.auth-mark span { color:var(--gold); }
.auth-card h1 { margin:0 0 8px; color:var(--navy); font-family:Georgia,serif; font-size:28px; }
.auth-card > p { margin:0 0 26px; color:var(--ink-soft); font-size:13.5px; line-height:1.65; }
.auth-submit { width:100%; justify-content:center; min-height:44px; margin-top:4px; }
.auth-error { min-height:22px; color:#b23b2e; font-size:13px; margin-top:12px; }
.auth-switch { border-top:1px solid var(--line); padding-top:18px; margin-top:10px; text-align:center; color:var(--ink-soft); font-size:13px; }
.auth-switch a { color:var(--navy); font-weight:600; }
.site-footer { display:flex; justify-content:center; gap:18px; flex-wrap:wrap; padding:22px 16px 28px; color:#998e76; font-size:11.5px; }
.site-footer a { color:#7d725d; text-decoration:none; }
.site-footer a:hover { text-decoration:underline; }
@media (max-width:720px) {
  .api-badge { display:none; }
  .user-badge { display:none; }
  .auth-card { padding:28px 22px 24px; }
}
