@import "https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=Noto+Sans+SC:wght@400;500;600&display=swap";

:root {
  --ink: #1f2521;
  --ink-soft: #657068;
  --ink-faint: #89938c;
  --paper: #fbfcfa;
  --surface: #fff;
  --sidebar: #f0f3ed;
  --line: #e2e7df;
  --line-strong: #d5ddd2;
  --accent: #3f6e51;
  --accent-dark: #315940;
  --accent-soft: #e4ede3;
  --accent-pale: #f0f5ef;
  --danger: #9b3b3b;
  --shadow: 0 16px 50px #25352a14;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "DM Sans", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  overflow: hidden;
  background: radial-gradient(circle at 80% 10%, #dbe8da59, transparent 30%), var(--paper);
}

.sidebar {
  position: relative;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: 272px;
  min-width: 272px;
  height: 100vh;
  height: 100dvh;
  padding: 25px 18px 18px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 25px;
  color: #263b2c;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.brand-mark, .welcome-mark {
  display: grid;
  place-items: center;
  color: var(--accent);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-soft);
}

.new-chat, .gate-card button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid #31594014;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 7px 16px #3f6e5126;
  transition: transform 0.16s, background 0.16s;
}

.new-chat:hover, .gate-card button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.shortcut { margin-left: auto; padding: 2px 5px; border: 1px solid #ffffff2e; border-radius: 5px; color: #ffffffb3; font-size: 10px; }

.sidebar-section { display: flex; flex-direction: column; min-height: 0; margin-top: 29px; }
.section-label { margin: 0 10px 9px; color: var(--ink-faint); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }

.history-search { margin: 0 4px 8px; }
.history-search input, .gate-card input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  outline: none;
}
.history-search input:focus, .gate-card input:focus { border-color: #b8cab8; }

#history { display: flex; flex-direction: column; min-height: 0; overflow: auto; }

.history-item {
  display: grid;
  grid-template-columns: 1fr 28px;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 4px 4px 9px;
  border-radius: 9px;
  color: var(--ink-soft);
  font-size: 13px;
}
.history-item:hover, .history-item.active { color: var(--ink); background: #ffffffa6; }
.history-item button {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.history-open { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; padding: 6px 0; }
.history-open span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-delete { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; opacity: 0; }
.history-item:hover .history-delete, .history-delete:focus { opacity: 1; }
.empty-history { margin: 4px 10px; color: var(--ink-faint); font-size: 13px; }

.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line-strong); }
.profile { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px; border: 0; border-radius: 10px; background: transparent; text-align: left; }
.profile:hover { background: #fff9; }
.avatar { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; background: #d7e1d3; color: var(--accent-dark); font-size: 13px; font-weight: 600; }
.profile-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.profile-text strong { font-size: 13px; font-weight: 600; }
.profile-text small { margin-top: 1px; color: var(--ink-faint); font-size: 11px; }

.main-panel { position: relative; display: flex; flex: 1; flex-direction: column; min-width: 0; height: 100vh; height: 100dvh; }
.topbar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  height: 66px;
  padding: 0 27px;
  border-bottom: 1px solid #e2e7dfcc;
  background: #fbfcfab8;
  backdrop-filter: blur(16px);
}
.model-name { position: absolute; left: 50%; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; transform: translateX(-50%); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #78a37f; box-shadow: 0 0 0 3px #78a37f1f; }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-soft); transition: color 0.16s, background 0.16s; }
.icon-button:hover { background: var(--accent-pale); color: var(--accent-dark); }
.menu-button { visibility: hidden; }
.sidebar-close { display: none; margin-left: auto; }

.conversation { display: flex; flex: 1; min-width: 0; min-height: 0; padding: 28px 34px 18px; overflow-x: hidden; overflow-y: auto; }
.welcome { width: min(760px, 100%); min-width: 0; margin: auto; padding-bottom: 24px; animation: rise-in 0.5s both; }
.welcome-mark { width: 48px; height: 48px; margin-bottom: 22px; border: 1px solid #d9e5d7; border-radius: 15px; background: linear-gradient(145deg, #eff6ed, #e1ebde); box-shadow: 0 8px 24px #43614814; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; }
.welcome h1, .gate-card h1 { margin: 0; color: var(--ink); font-size: clamp(32px, 4vw, 46px); font-weight: 500; line-height: 1.28; letter-spacing: -0.035em; }
.welcome h1 span { color: #899188; font-weight: 400; }
.suggestion-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; margin-top: 38px; }
.suggestion-card {
  display: grid;
  min-width: 0;
  grid-template-columns: 36px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 12px;
  min-height: 88px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffffba;
  text-align: left;
  box-shadow: 0 3px 13px #303d3306;
  transition: border 0.18s, transform 0.18s, box-shadow 0.18s;
}
.suggestion-card:hover { border-color: #cad8c7; transform: translateY(-2px); box-shadow: 0 12px 30px #30433512; }
.suggestion-card > svg { color: #a1aaa2; }
.suggestion-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-pale); color: var(--accent); }
.suggestion-card strong, .suggestion-card small { display: block; }
.suggestion-card strong { margin-bottom: 4px; font-size: 13px; font-weight: 600; }
.suggestion-card small { overflow: hidden; color: var(--ink-faint); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }

.message-list { width: min(760px, 100%); margin: 0 auto; padding: 16px 0 28px; }
.conversation-heading { margin-bottom: 42px; text-align: center; }
.conversation-heading p { margin: 0 0 5px; font-size: 15px; font-weight: 600; }
.conversation-heading span { color: var(--ink-faint); font-size: 11px; }
.message { display: grid; grid-template-columns: 34px 1fr; gap: 13px; margin-bottom: 31px; animation: rise-in 0.3s both; }
.message.user { margin-left: 48px; padding: 16px; border-radius: 14px; background: var(--accent-pale); }
.message-avatar { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--accent); }
.user .message-avatar { border-color: #d5e1d3; background: #dfe9dd; }
.message-author { margin: 1px 0 7px; font-size: 12px; font-weight: 600; }
.message-content { margin: 0; color: #3f4741; font-size: 14px; line-height: 1.75; white-space: pre-wrap; }
.typing { display: flex; align-items: center; gap: 4px; height: 22px; }
.typing span { width: 5px; height: 5px; border-radius: 50%; background: #87968a; animation: pulse 1.1s infinite; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

.composer-wrap { flex: none; width: min(820px, calc(100% - 56px)); margin: 0 auto 15px; }
.composer { padding: 15px 15px 10px; border: 1px solid var(--line-strong); border-radius: 16px; background: #ffffffe6; box-shadow: var(--shadow); transition: border 0.18s, box-shadow 0.18s; }
.composer:focus-within { border-color: #b8cab8; box-shadow: var(--shadow), 0 0 0 3px #3f6e510f; }
.composer textarea { display: block; width: 100%; min-height: 30px; max-height: 130px; border: 0; outline: 0; resize: none; background: transparent; font-size: 14px; line-height: 1.5; }
.composer textarea::placeholder { color: #9ba39d; }
.composer-actions { display: flex; align-items: center; margin-top: 7px; }
.composer-hint { margin-left: auto; color: #abb1ac; font-size: 10px; }
.send-button { display: grid; place-items: center; width: 34px; height: 34px; margin-left: 10px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; transition: transform 0.16s, background 0.16s, opacity 0.16s; }
.send-button:hover:not(:disabled) { background: var(--accent-dark); transform: translateY(-1px); }
.send-button:disabled { opacity: 0.28; cursor: default; }
.disclaimer, .form-error { text-align: center; }
.disclaimer { margin: 9px 0 0; color: #a0a7a1; font-size: 10px; }
.form-error { min-height: 1.2em; margin: 8px 0 0; color: var(--danger); font-size: 13px; }
.sidebar-backdrop { display: none; }

.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 80% 10%, #dbe8da59, transparent 30%), var(--paper); }
.gate-card { width: min(440px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 16px; background: #ffffffe6; box-shadow: var(--shadow); }
.gate-card .welcome-mark { margin-bottom: 18px; }
.gate-copy { margin: 8px 0 18px; color: var(--ink-faint); }
.gate-card label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.gate-card button { justify-content: center; margin-top: 8px; }

@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 50% { opacity: 0.5; } }

@media (width <= 760px) {
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: transform 0.22s; }
  .sidebar.sidebar-open { transform: translateX(0); box-shadow: 16px 0 50px #18221b24; }
  .sidebar-close, .menu-button { display: grid; visibility: visible; }
  .sidebar-backdrop.visible { position: fixed; inset: 0; z-index: 20; display: block; border: 0; background: #19201b38; backdrop-filter: blur(2px); }
  .topbar { padding: 0 17px; }
  .conversation { padding: 24px 18px 14px; }
  .welcome h1 { font-size: 32px; }
  .suggestion-grid { grid-template-columns: 1fr; margin-top: 30px; }
  .suggestion-card:nth-child(n + 4) { display: none; }
  .composer-wrap { width: calc(100% - 24px); margin-bottom: calc(9px + env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
  .history-delete { opacity: 1; }
}

@media (height <= 720px) and (width >= 761px) {
  .welcome { padding-bottom: 6px; }
  .welcome-mark { margin-bottom: 13px; }
  .suggestion-grid { margin-top: 24px; }
}

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