:root {
  --paper: #fffefa;
  --canvas: #f6f5f1;
  --milk: #fcfbf8;
  --ink: #2c2c2a;
  --ink-soft: #676763;
  --ink-faint: #9a9a94;
  --line: #e6e4dd;
  --line-soft: #efeee8;
  --accent: #676763;
  --warn: #854f0b;
  --warn-bg: #faeeda;
  --danger: #a32d2d;
  --danger-bg: #fcebeb;
  --ok: #3b6d11;
  --ok-bg: #eaf3de;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(44, 44, 42, 0.04), 0 8px 24px rgba(44, 44, 42, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------------------------- 登录页（深蓝星空 · 沿用 CreoME 官网视觉） ---------------------------- */

/* 仅登录页覆盖为深色主题，工作台保持奶油白 */
body.is-auth {
  background: #061321;
  color: #f5f8fc;
}

.creome-starfield {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  user-select: none;
  background: #06172b;
}
.creome-starfield[data-starfield-failed] { visibility: hidden; }

.auth-layout {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  align-items: center;
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 48px 32px;
}

/* 左侧品牌故事 */
.auth-story { padding: 0 12px 0 8px; }

.story-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 40px;
}
.story-fox { font-size: 22px; }
.story-cat {
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}
.brand-cat {
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}
.story-wordmark {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #f1f6fc;
}
.story-divider { width: 1px; height: 18px; background: #ccdeef2e; }
.story-cn { font-size: 15px; color: #bdd9ed; letter-spacing: 0.14em; }

.story-title {
  margin: 0 0 18px;
  font-size: clamp(30px, 4.2vw, 44px);
  line-height: 1.28;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #f7fafd;
}

.story-sub {
  margin: 0 0 26px;
  font-size: 15px;
  line-height: 1.8;
  color: #d5e3ee;
}
.story-desc {
  margin: 0 0 10px;
  font-size: 13.5px;
  line-height: 1.85;
  color: #a7bacb;
  max-width: 520px;
  text-wrap: pretty;
}

.story-team {
  display: block;
  width: min(460px, 82%);
  margin: 26px auto 8px;
  border-radius: 18px;
  -webkit-mask-image: radial-gradient(ellipse 78% 78% at 50% 50%, #000 62%, transparent 98%);
  mask-image: radial-gradient(ellipse 78% 78% at 50% 50%, #000 62%, transparent 98%);
}
.story-hint {
  text-align: center;
  font-size: 12.5px;
  color: #8fa5b8;
  margin: 0 0 30px;
}

.story-flow {
  border-top: 1px solid #c2ddf014;
  padding-top: 20px;
  font-size: 12.5px;
  color: #9fb4c6;
  line-height: 2.1;
  letter-spacing: 0.02em;
}
.story-flow i {
  font-style: normal;
  color: #5f7d95;
  margin: 0 10px;
}

/* 右侧登录卡：深色玻璃质感 */
.auth-panel { display: grid; place-items: center; }

.auth-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(150deg, #0b2233e0, #081a29d6);
  border: 1px solid #ccdeef18;
  border-radius: 22px;
  padding: 30px 28px 24px;
  box-shadow: 0 24px 60px rgba(2, 10, 20, 0.5);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, #fff0cd, #fce2ee 55%, #deecff);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  color: #102638;
}

.brand-name { font-size: 17px; font-weight: 600; color: #f1f6fc; letter-spacing: 0.2px; }
.brand-cn { font-weight: 400; color: #bdd9ed; font-size: 13px; margin-left: 4px; }
.brand-tag { font-size: 12px; color: #8fa5b8; margin: 0 0 22px; }

.tabs {
  display: flex;
  gap: 6px;
  background: #0a1b2b;
  border: 1px solid #ccdeef14;
  border-radius: 11px;
  padding: 4px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  color: #9fb4c6;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
.tab.is-active { background: #173044; color: #f5f8fc; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  color: #9fb4c6;
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccdeef1f;
  border-radius: 10px;
  background: #0a1b2b;
  color: #f5f8fc;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.field input::placeholder { color: #5f7d95; }
.field input:focus { border-color: #7fb3d8; background: #0d2133; }

.btn {
  width: 100%;
  padding: 11px 16px;
  border: 1px solid #deebf4;
  border-radius: 10px;
  background: #deebf4;
  color: #102638;
  font-size: 14px;
  font-weight: 600;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.notice {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.55;
  display: none;
}
.notice.is-error { display: block; background: #3a1418; color: #f2a6ab; border: 1px solid #f2a6ab2e; }
.notice.is-ok { display: block; background: #12290f; color: #b5e2a1; border: 1px solid #b5e2a12b; }
.notice.is-warn { display: block; background: #33240e; color: #ecc786; border: 1px solid #ecc7862b; }

.auth-foot {
  margin-top: 18px;
  font-size: 11.5px;
  color: #7d93a6;
  line-height: 1.7;
  border-top: 1px dashed #ccdeef1c;
  padding-top: 14px;
}

@media (max-width: 900px) {
  .auth-layout {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 36px 18px 44px;
  }
  .auth-story { padding: 0 4px; }
  .story-brand { margin-bottom: 26px; }
  .story-title { font-size: clamp(26px, 7vw, 34px); }
  .story-team { width: min(380px, 92%); margin-top: 20px; }
  .auth-panel { margin-top: 10px; }
}

/* ---------------------------- 工作台 ---------------------------- */

.app-shell {
  display: grid;
  grid-template-columns: 264px 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: var(--milk);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.side-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}
.side-user-name { font-size: 12.5px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.quota-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok);
  white-space: nowrap;
}
.quota-pill.is-low { background: var(--warn-bg); color: var(--warn); }
.quota-pill.is-out { background: var(--danger-bg); color: var(--danger); }

.new-chat {
  width: 100%;
  margin: 12px 0 4px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  font-size: 13px;
  color: var(--ink);
  text-align: left;
}
.new-chat:hover { border-color: var(--accent); }

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 0;
}

.conv-item {
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.conv-item:hover { background: #efeee8; }
.conv-item.is-active { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.conv-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-del {
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0;
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: var(--danger); }

.side-foot {
  border-top: 1px solid var(--line-soft);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-link {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.side-link:hover { background: #efeee8; }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--paper);
}

.main-head {
  padding: 14px 24px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.main-title { font-size: 13.5px; font-weight: 500; }
.main-sub { font-size: 11.5px; color: var(--ink-faint); }

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  min-height: 0;
}

.empty {
  max-width: 620px;
  margin: 8vh auto 0;
  text-align: center;
}
.empty h1 { font-size: 20px; font-weight: 500; margin: 0 0 8px; }
.empty p { color: var(--ink-soft); font-size: 13px; margin: 0 0 22px; }

.suggest-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  text-align: left;
}
.suggest {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--milk);
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
}
.suggest:hover { border-color: var(--accent); background: var(--paper); color: var(--ink); }
.suggest strong { display: block; color: var(--ink); font-weight: 500; margin-bottom: 3px; font-size: 13px; }

.msg {
  max-width: 760px;
  margin: 0 auto 20px;
  display: flex;
  gap: 12px;
}
.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--milk);
  border: 1px solid var(--line);
}
.msg.is-user .msg-avatar { background: #deecff; border-color: #c9dcf5; }
.msg.is-memo .msg-avatar { background: linear-gradient(135deg, #fff0cd, #fce2ee); }

.msg-body { min-width: 0; flex: 1; }
.msg-meta { font-size: 11px; color: var(--ink-faint); margin-bottom: 4px; }
.msg-content {
  font-size: 14px;
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.is-user .msg-content {
  background: var(--milk);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 10px 14px;
}
.msg-content code {
  background: var(--canvas);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 12.5px;
}
.cursor-blink::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 15px;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: -2px;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.composer-wrap {
  border-top: 1px solid var(--line-soft);
  padding: 12px 24px 18px;
  background: var(--paper);
}

.composer {
  max-width: 760px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--milk);
  padding: 10px 12px 8px;
  transition: border-color 0.15s;
}
.composer:focus-within { border-color: var(--accent); background: var(--paper); }

.composer textarea {
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  resize: none;
  font-size: 14px;
  line-height: 1.6;
  max-height: 200px;
  min-height: 46px;
  padding: 2px 2px 6px;
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.composer-hint { font-size: 11px; color: var(--ink-faint); }

.send-btn {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 9px;
  padding: 6px 16px;
  font-size: 13px;
}
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.banner {
  max-width: 760px;
  margin: 0 auto 14px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.6;
  display: none;
}
.banner.is-show { display: block; }
.banner.is-warn { background: var(--warn-bg); color: var(--warn); }
.banner.is-error { background: var(--danger-bg); color: var(--danger); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 264px;
    transform: translateX(-100%);
    transition: transform 0.2s;
    z-index: 30;
    box-shadow: 0 0 40px rgba(0,0,0,0.12);
  }
  .sidebar.is-open { transform: translateX(0); }
  .suggest-grid { grid-template-columns: 1fr; }
  .chat-scroll { padding: 16px; }
  .composer-wrap { padding: 10px 14px 14px; }
  .main-head { padding: 12px 16px; }
  .menu-btn { display: inline-flex !important; }
}

.menu-btn {
  display: none;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
}
