:root {
  --bg: #f6f6f2;
  --panel: rgba(255, 255, 252, 0.86);
  --sidebar: #ecece6;
  --sidebar-deep: #e5e5de;
  --text: #20221f;
  --muted: #777b72;
  --line: rgba(37, 40, 34, 0.1);
  --accent: #305c4a;
  --accent-soft: #dce8df;
  --shadow: 0 18px 55px rgba(41, 46, 39, 0.1);
  --sans: "DM Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --display: "Manrope", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 67% 26%, rgba(223, 232, 219, 0.65), transparent 28%),
    var(--bg);
  font-family: var(--sans);
  transition: color .25s ease, background .25s ease;
}

button, textarea { font: inherit; }
button { color: inherit; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex: 0 0 278px;
  flex-direction: column;
  min-height: 100vh;
  padding: 22px 16px 16px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-deep));
}

.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-family: var(--display); font-size: 18px; font-weight: 700; text-decoration: none; }
.brand-mark { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 10px; color: #fff; background: var(--accent); font-size: 15px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.icon-button { display: grid; width: 38px; height: 38px; padding: 0; place-items: center; border: 0; border-radius: 11px; background: transparent; cursor: pointer; transition: background .2s, transform .2s; }
.icon-button:hover { background: rgba(80, 84, 75, .08); }
.icon-button:active { transform: scale(.94); }
.icon-button svg, .share-button svg, .tool-button svg, .send-button svg { width: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.sidebar-close { display: none; }

.new-chat { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,252,.7); font-weight: 600; cursor: pointer; box-shadow: 0 4px 14px rgba(40,45,37,.04); transition: transform .2s, background .2s; }
.new-chat:hover { background: #fff; transform: translateY(-1px); }
.new-chat svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.new-chat span { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 500; }

.history { flex: 1; overflow: auto; padding-top: 20px; }
.nav-label { margin: 17px 10px 7px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; }
.history-item { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 10px 11px; border: 0; border-radius: 9px; overflow: hidden; background: transparent; cursor: pointer; font-size: 13px; text-align: left; transition: background .18s; }
.history-item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item:hover, .history-item.active { background: rgba(255,255,252,.62); }
.more { opacity: 0; color: var(--muted); font-size: 10px; letter-spacing: 2px; transition: opacity .18s; }
.history-item:hover .more { opacity: 1; }

.sidebar-footer { display: grid; gap: 8px; }
.upgrade-card, .profile-button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px; border: 0; border-radius: 12px; background: transparent; cursor: pointer; text-align: left; }
.upgrade-card { background: rgba(255,255,252,.48); }
.upgrade-card > span:nth-child(2), .profile-button > span:nth-child(2) { display: grid; flex: 1; gap: 2px; }
.upgrade-card strong, .profile-button strong { font-size: 12px; font-weight: 600; }
.upgrade-card small, .profile-button small { color: var(--muted); font-size: 10px; }
.sparkle { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 9px; color: var(--accent); background: var(--accent-soft); }
.avatar { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; color: #fff; background: #856f5c; font-size: 12px; }

.main-panel { display: flex; min-width: 0; flex: 1; flex-direction: column; min-height: 100vh; }
.topbar { display: flex; height: 70px; flex: 0 0 70px; align-items: center; padding: 0 28px; }
.menu-button { display: none; }
.model-picker { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; cursor: pointer; }
.model-picker:hover { background: rgba(80,84,75,.06); }
.model-dot { width: 7px; height: 7px; border-radius: 50%; background: #6f9b80; box-shadow: 0 0 0 4px rgba(111,155,128,.12); }
.top-actions { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.share-button { display: flex; align-items: center; gap: 7px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,252,.5); cursor: pointer; font-size: 12px; font-weight: 600; }
.share-button svg { width: 15px; }

.chat-stage { display: flex; min-height: 0; flex: 1; flex-direction: column; align-items: center; padding: 20px 28px 12px; }
.welcome { width: min(760px, 100%); margin: auto 0 26px; text-align: center; animation: rise .65s ease both; }
.orb { position: relative; width: 54px; height: 54px; margin: 0 auto 21px; border-radius: 18px; background: conic-gradient(from 210deg, #a9c7b4, #476c5e, #d9c0a6, #a9c7b4); box-shadow: 0 12px 32px rgba(62,96,77,.2); transform: rotate(8deg); }
.orb::after { position: absolute; inset: 2px; border-radius: 16px; background: radial-gradient(circle at 35% 28%, rgba(255,255,255,.88), transparent 25%), linear-gradient(145deg, rgba(255,255,255,.16), rgba(20,63,47,.2)); content: ""; }
.orb span { position: absolute; z-index: 1; inset: 16px; border: 1.5px solid rgba(255,255,255,.78); border-radius: 8px 8px 8px 2px; }
.eyebrow { margin: 0 0 9px; color: var(--accent); font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; font-family: var(--display); font-size: clamp(31px, 4vw, 46px); font-weight: 600; letter-spacing: -.045em; line-height: 1.18; }
.subtitle { margin: 13px 0 32px; color: var(--muted); font-size: 14px; }
.suggestion-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; text-align: left; }
.suggestion { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px; min-height: 76px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,252,.52); cursor: pointer; box-shadow: 0 7px 22px rgba(48,53,45,.035); text-align: left; transition: transform .2s, border-color .2s, background .2s, box-shadow .2s; }
.suggestion:hover { transform: translateY(-2px); border-color: rgba(48,92,74,.24); background: rgba(255,255,252,.9); box-shadow: 0 12px 30px rgba(48,53,45,.075); }
.suggestion-icon { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 11px; font-size: 16px; }
.travel { color: #657d65; background: #e4ecdf; }.learn { color: #866c4d; background: #efe5d6; }.write { color: #6a718d; background: #e5e6ef; }.analyze { color: #77618b; background: #ebe4ef; }
.suggestion > span:nth-child(2) { display: grid; gap: 3px; }
.suggestion strong { font-size: 13px; font-weight: 600; }
.suggestion small { color: var(--muted); font-size: 11px; }
.arrow { color: var(--muted); opacity: 0; transform: translateX(-4px); transition: opacity .2s, transform .2s; }
.suggestion:hover .arrow { opacity: 1; transform: translateX(0); }

.conversation { width: min(740px, 100%); flex: 1; overflow-y: auto; padding: 25px 4px 150px; scrollbar-width: thin; }
.message { display: flex; gap: 14px; margin: 0 0 28px; animation: rise .35s ease both; }
.message.user { justify-content: flex-end; }
.message-bubble { max-width: min(590px, 86%); padding: 12px 15px; border-radius: 16px; font-size: 14px; line-height: 1.65; white-space: pre-wrap; }
.user .message-bubble { border-bottom-right-radius: 5px; background: var(--accent); color: #fff; }
.assistant .message-bubble { padding: 2px 0; }
.ai-badge { display: grid; width: 28px; height: 28px; flex: 0 0 28px; place-items: center; border-radius: 9px; color: #fff; background: var(--accent); font-family: var(--display); font-size: 11px; }
.typing { display: inline-flex; gap: 4px; padding-top: 9px; }
.typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite alternate; }
.typing span:nth-child(2) { animation-delay: .2s; }.typing span:nth-child(3) { animation-delay: .4s; }

.composer-wrap { width: min(760px, 100%); margin-top: auto; }
.composer { padding: 12px 12px 10px 16px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(16px); transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: rgba(48,92,74,.34); box-shadow: 0 18px 60px rgba(41,46,39,.14), 0 0 0 3px rgba(48,92,74,.05); }
textarea { display: block; width: 100%; max-height: 140px; min-height: 28px; padding: 3px 0 9px; resize: none; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 14px; line-height: 1.5; }
textarea::placeholder { color: #999c94; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; }
.composer-left { display: flex; align-items: center; gap: 4px; }
.tool-button { display: grid; width: 32px; height: 32px; padding: 0; place-items: center; border: 0; border-radius: 9px; background: transparent; cursor: pointer; }
.tool-button:hover { background: rgba(70,75,66,.06); }
.tool-button svg { width: 17px; }
.mode-button { display: flex; align-items: center; gap: 5px; padding: 7px 9px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; }
.mode-button:hover { background: rgba(70,75,66,.06); color: var(--text); }
.mode-button span { color: var(--accent); }
.send-button { display: grid; width: 34px; height: 34px; padding: 0; place-items: center; border: 0; border-radius: 11px; color: #fff; background: var(--accent); cursor: pointer; transition: transform .2s, opacity .2s; }
.send-button:hover { transform: translateY(-1px); }
.send-button:disabled { opacity: .38; cursor: default; transform: none; }
.send-button svg { width: 17px; }
.disclaimer { margin: 9px 0 0; color: var(--muted); font-size: 10px; text-align: center; }
.sidebar-overlay { display: none; }

.settings-layer { position: fixed; z-index: 60; inset: 0; }
.settings-layer[hidden] { display: none; }
.settings-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(28,31,27,.38); backdrop-filter: blur(5px); cursor: default; animation: fade-in .2s ease both; }
.settings-panel { position: absolute; top: 0; right: 0; display: flex; width: min(560px, 100%); height: 100%; flex-direction: column; overflow: auto; border-left: 1px solid var(--line); background: var(--bg); box-shadow: -24px 0 80px rgba(25,28,24,.16); animation: panel-in .3s cubic-bezier(.2,.8,.2,1) both; }
.settings-header { display: flex; align-items: center; justify-content: space-between; padding: 32px 34px 23px; border-bottom: 1px solid var(--line); }
.settings-header .eyebrow { margin-bottom: 5px; }
.settings-header h2 { margin: 0; font-family: var(--display); font-size: 27px; letter-spacing: -.035em; }
.settings-form { display: flex; flex: 1; flex-direction: column; }
.setting-section { padding: 26px 34px; border-bottom: 1px solid var(--line); }
.section-title { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.section-title > span { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 9px; color: var(--accent); background: var(--accent-soft); font-size: 10px; font-weight: 700; }
.section-title > div { display: grid; gap: 2px; }
.section-title strong { font-size: 14px; }
.section-title small, .field small { color: var(--muted); font-size: 10px; }
.field { display: grid; gap: 8px; margin-top: 15px; color: var(--text); font-size: 12px; font-weight: 600; }
.field > span { display: flex; justify-content: space-between; }
.field input:not([type="range"]), .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; outline: 0; color: var(--text); background: var(--panel); font: 400 13px/1.5 var(--sans); transition: border-color .2s, box-shadow .2s; }
.field input:not([type="range"]), .field select { height: 43px; padding: 0 12px; }
.field textarea { min-height: 130px; padding: 11px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: rgba(48,92,74,.42); box-shadow: 0 0 0 3px rgba(48,92,74,.06); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.secret-field { position: relative; }
.secret-field input { padding-right: 58px !important; }
.secret-field button { position: absolute; top: 5px; right: 5px; height: 33px; padding: 0 9px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; }
.secret-field button:hover { color: var(--text); background: rgba(70,75,66,.06); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.prompt-presets { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.prompt-presets button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); background: transparent; cursor: pointer; font-size: 10px; }
.prompt-presets button:hover { border-color: rgba(48,92,74,.28); color: var(--accent); background: var(--accent-soft); }
.settings-actions { display: flex; align-items: center; gap: 18px; margin-top: auto; padding: 22px 34px 28px; }
.settings-actions p { display: flex; flex: 1; align-items: center; gap: 7px; margin: 0; color: var(--muted); font-size: 10px; }
.settings-actions p span { width: 6px; height: 6px; border-radius: 50%; background: #7ca087; }
.save-settings { min-width: 112px; padding: 11px 18px; border: 0; border-radius: 11px; color: #fff; background: var(--accent); cursor: pointer; font-weight: 600; box-shadow: 0 8px 20px rgba(48,92,74,.16); }
.save-settings:hover { transform: translateY(-1px); }
.error-message { color: #a64b42; }

body.dark { --bg: #171916; --panel: rgba(36,39,34,.86); --sidebar: #20221f; --sidebar-deep: #1d1f1c; --text: #eceee8; --muted: #969b91; --line: rgba(240,245,235,.09); --accent: #7ba68d; --accent-soft: #2b3b32; --shadow: 0 18px 55px rgba(0,0,0,.28); background: radial-gradient(circle at 67% 26%, rgba(48,75,59,.3), transparent 28%), var(--bg); }
body.dark .brand-mark, body.dark .send-button, body.dark .ai-badge, body.dark .user .message-bubble { color: #142019; background: #8db39a; }
body.dark .suggestion, body.dark .composer, body.dark .share-button { background: rgba(38,41,36,.72); }
body.dark .suggestion:hover { background: rgba(47,51,44,.9); }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes blink { to { opacity: .25; transform: translateY(-2px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes panel-in { from { opacity: 0; transform: translateX(25px); } }

@media (max-width: 820px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 278px; transform: translateX(-100%); box-shadow: 20px 0 70px rgba(25,28,23,.18); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close, .menu-button { display: grid; }
  .sidebar-overlay { position: fixed; z-index: 15; inset: 0; display: block; visibility: hidden; opacity: 0; background: rgba(20,22,19,.28); transition: opacity .25s, visibility .25s; }
  .sidebar-overlay.open { visibility: visible; opacity: 1; }
  .topbar { padding: 0 16px; }
  .chat-stage { padding: 12px 16px 10px; }
}

@media (max-width: 570px) {
  .topbar { height: 60px; flex-basis: 60px; }
  .share-button { width: 38px; height: 38px; padding: 0; justify-content: center; }
  .share-button span, .share-button:not(:has(span)) { font-size: 0; }
  .share-button { font-size: 0; }
  .welcome { margin-bottom: 18px; }
  .orb { width: 48px; height: 48px; margin-bottom: 17px; }
  h1 { font-size: 30px; }
  .subtitle { margin-bottom: 24px; font-size: 13px; }
  .suggestion-grid { grid-template-columns: 1fr; gap: 8px; }
  .suggestion { min-height: 62px; }
  .suggestion:nth-child(n+4) { display: none; }
  .composer { border-radius: 17px; }
  .settings-header, .setting-section { padding-right: 20px; padding-left: 20px; }
  .settings-actions { align-items: stretch; flex-direction: column; padding: 18px 20px 24px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .save-settings { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
