:root {
  --bg: #0b0f14;
  --panel: #12181f;
  --panel-2: #182029;
  --border: #243040;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #3aa0ff;
  --accent-2: #2f81f7;
  --green: #2ea44f;
  --danger: #e5534b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; min-width: 0; }
.eyebrow { margin: 0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 18px;
  cursor: pointer;
}
.icon-btn:active { background: #1f2a36; }

.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #555; flex-shrink: 0; }
.status-dot.ok { background: var(--green); box-shadow: 0 0 8px var(--green); }

/* Chat */
.chat-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.message {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}
.message.user { align-self: flex-end; background: var(--accent-2); border-bottom-right-radius: 4px; }
.message.agent { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.message.system { align-self: center; background: transparent; color: var(--muted); font-size: 12px; }
.message.error { align-self: flex-start; background: #2a1416; color: #ff9b94; border: 1px solid #4a1f22; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--border);
}
.composer textarea {
  flex: 1;
  resize: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 15px;
  max-height: 120px;
}
.composer textarea:focus { outline: none; border-color: var(--accent); }
.send-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: 14px;
  width: 44px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
}
.send-btn:disabled { opacity: .5; }

/* Drawer */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(320px, 88vw);
  background: var(--panel);
  z-index: 50;
  overflow-y: auto;
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top));
  border-left: 1px solid var(--border);
  transition: transform .2s ease;
}
.drawer.hidden { transform: translateX(100%); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 14px; }

.menu-section { margin-bottom: 20px; }
.menu-section h2 { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.menu-section select, .menu-section input, .menu-section textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  margin-bottom: 8px;
}
.menu-section textarea { resize: vertical; }
.menu-section :is(select, input, textarea):focus { outline: none; border-color: var(--accent); }
.menu-btn {
  width: 100%;
  background: var(--accent);
  border: none; color: #fff;
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  cursor: pointer;
}
.list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.list .li { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }

.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.hidden { display: none !important; }
