:root {
  --brand: #0f5c4d;
  --brand-600: #0c4a3e;
  --brand-50: #e8f3f0;
  --accent: #d9a441;
  --ink: #1b2522;
  --muted: #5d6b67;
  --line: #e2e8e6;
  --bg: #f6f8f7;
  --card: #ffffff;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 40, 34, .06), 0 8px 24px rgba(16, 40, 34, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; }

.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.logo svg, .logo img { width: 34px; height: 34px; flex: none; }
.auth-hero .logo img { box-shadow: 0 0 0 2px rgba(255,255,255,.25); border-radius: 10px; }
[hidden] { display: none !important; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  position: relative; overflow: hidden; color: #fff; padding: 48px;
  background: linear-gradient(160deg, #0f5c4d 0%, #0b3f35 60%, #082e27 100%);
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth-hero .logo { color: #fff; }
.auth-hero h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.15; margin: 0 0 14px; letter-spacing: -.02em; max-width: 16ch; }
.auth-hero p { color: rgba(255,255,255,.8); max-width: 42ch; margin: 0; }
.skyline { position: absolute; right: -20px; bottom: -10px; width: 70%; opacity: .16; pointer-events: none; }
.hero-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; }
.hero-points li { display: flex; gap: 10px; align-items: center; color: rgba(255,255,255,.9); }
.hero-points li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.auth-foot { font-size: .85rem; color: rgba(255,255,255,.6); position: relative; }

.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { margin: 0 0 6px; font-size: 1.6rem; letter-spacing: -.01em; }
.auth-card .sub { margin: 0 0 28px; color: var(--muted); }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: .9rem; }
.field input {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 92, 77, .15); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 10px; padding: 12px 18px; font-weight: 600;
  background: var(--brand); color: #fff; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--brand-600); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--brand-50); }
.error { color: var(--danger); font-size: .9rem; min-height: 1.3em; margin: 8px 0 0; }

.samples { margin-top: 28px; padding-top: 20px; border-top: 1px dashed var(--line); }
.samples h3 { margin: 0 0 4px; font-size: .9rem; }
.samples p { margin: 0 0 12px; font-size: .85rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px;
  font-size: .82rem; color: var(--ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- App shell ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 24px; }
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a { text-decoration: none; color: var(--muted); padding: 8px 12px; border-radius: 8px; font-weight: 500; font-size: .95rem; }
.nav a.active, .nav a:hover { color: var(--brand); background: var(--brand-50); }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
.who-text { display: grid; line-height: 1.2; text-align: right; }
.who-text strong { font-size: .92rem; }
.who-text span { font-size: .8rem; color: var(--muted); }

.page { max-width: 1180px; margin: 0 auto; padding: 32px 24px 120px; }
.welcome {
  border-radius: var(--radius); padding: 32px; color: #fff; margin-bottom: 24px; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #0f5c4d, #0b3f35);
}
.welcome h1 { margin: 0 0 6px; font-size: 1.7rem; letter-spacing: -.01em; }
.welcome p { margin: 0; color: rgba(255,255,255,.8); max-width: 60ch; }
.welcome .skyline { width: 45%; opacity: .14; }
.welcome .btn { margin-top: 18px; background: var(--accent); color: #1f1a0e; position: relative; }
.welcome .btn:hover { background: #e3b457; }

.grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card h2 { margin: 0 0 4px; font-size: 1.1rem; }
.card .hint { margin: 0 0 18px; color: var(--muted); font-size: .9rem; }

.profile { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; margin: 0; }
.profile div { min-width: 0; }
.profile dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.profile dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.empty { color: var(--muted); font-size: .9rem; }

.actions { display: grid; gap: 10px; }
.action {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; color: var(--ink);
  transition: border-color .15s, background .15s;
}
.action:hover { border-color: var(--brand); background: var(--brand-50); }
.action .ico { width: 36px; height: 36px; border-radius: 10px; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; flex: none; }
.action .ico svg { width: 18px; height: 18px; }
.action strong { display: block; font-size: .95rem; }
.action span { display: block; font-size: .83rem; color: var(--muted); }

/* ---------- Chat widget ---------- */
.chat-launcher {
  position: fixed; right: 24px; bottom: 24px; z-index: 40; width: 60px; height: 60px; border-radius: 50%;
  border: 0; background: var(--brand); color: #fff; box-shadow: 0 10px 30px rgba(15, 92, 77, .35);
  display: grid; place-items: center; transition: transform .15s;
}
.chat-launcher:hover { transform: scale(1.05); }
.chat-launcher svg { width: 26px; height: 26px; }

.chat {
  position: fixed; right: 24px; bottom: 96px; z-index: 50; width: 400px; max-width: calc(100vw - 32px);
  height: 600px; max-height: calc(100vh - 120px);
  background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 24px 60px rgba(16, 40, 34, .22);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(12px) scale(.98); pointer-events: none; transition: opacity .18s, transform .18s;
}
.chat.open { opacity: 1; transform: none; pointer-events: auto; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--brand); color: #fff; }
.chat-head .bot { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.16); display: grid; place-items: center; }
.chat-head .bot svg { width: 20px; height: 20px; }
.chat-head strong { display: block; font-size: .98rem; }
.chat-head span { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: rgba(255,255,255,.8); }
.chat-head span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #5ee0a0; }
.chat-head .icon-btn { margin-left: auto; }
.icon-btn { background: transparent; border: 0; color: inherit; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn:hover { background: rgba(255,255,255,.14); }
.icon-btn svg { width: 18px; height: 18px; }

.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #fafcfb; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: .93rem; overflow-wrap: anywhere; }
.msg.bot { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; align-self: flex-start; }
.msg.user { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; white-space: pre-wrap; }
.msg.err { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c2; align-self: flex-start; }
.msg p { margin: 0 0 8px; } .msg p:last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: 4px 0 8px; padding-left: 20px; }
.msg code { background: #eef2f1; padding: 1px 5px; border-radius: 4px; font-size: .86em; }
.msg pre { background: #eef2f1; padding: 10px; border-radius: 8px; overflow-x: auto; margin: 6px 0; }
.msg pre code { background: none; padding: 0; }
.msg table { border-collapse: collapse; font-size: .86rem; margin: 6px 0; display: block; overflow-x: auto; }
.msg th, .msg td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #9fb0ab; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; background: #fafcfb; }
.suggest button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 10px; font-size: .8rem; color: var(--brand); }
.suggest button:hover { border-color: var(--brand); }

.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #fff; }
.chat-input textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; max-height: 120px;
  outline: none; line-height: 1.4;
}
.chat-input textarea:focus { border-color: var(--brand); }
.chat-input .btn { padding: 0 14px; border-radius: 12px; }
.chat-input .btn svg { width: 18px; height: 18px; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 32px 24px; min-height: 260px; }
  .grid { grid-template-columns: 1fr; }
  .nav { display: none; }
}
@media (max-width: 560px) {
  .page { padding: 20px 16px 110px; }
  .topbar-inner { padding: 10px 16px; }
  .who-text { display: none; }
  .topbar .logo span { display: none; }
  .who .btn { padding: 8px 12px; }
  .profile { grid-template-columns: 1fr; }
  .chat { right: 8px; left: 8px; width: auto; max-width: none; bottom: 88px; height: calc(100vh - 110px); }
  .chat-launcher { right: 16px; bottom: 16px; }
}
