:root {
  color-scheme: dark;
  --bg: #080c12;
  --surface: #101720;
  --surface-2: #151f2b;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f4f7fb;
  --muted: #91a0b2;
  --accent: #30d69b;
  --accent-2: #11a971;
  --danger: #ff6b6b;
  --warning: #ffb454;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 80% -10%, rgba(48, 214, 155, 0.15), transparent 38%),
    radial-gradient(circle at -10% 40%, rgba(67, 116, 255, 0.08), transparent 35%);
}

.app-shell { min-height: 100dvh; max-width: 880px; margin: 0 auto; padding-bottom: 170px; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 18px 14px; background: rgba(8, 12, 18, 0.88); backdrop-filter: blur(20px); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 11px; align-items: center; }
.brand-mark, .login-logo { display: grid; place-items: center; background: linear-gradient(145deg, #4ae3ae, #159b69); color: #04110c; font-weight: 900; box-shadow: 0 10px 30px rgba(48, 214, 155, 0.2); }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; }
.brand h1 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--warning); }
.status-dot.online { background: var(--accent); box-shadow: 0 0 0 4px rgba(48, 214, 155, 0.12); }
.status-dot.offline { background: var(--danger); }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--text); }

.control-card { margin: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: rgba(16, 23, 32, 0.82); }
.control-card label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.path-row { display: flex; gap: 9px; }
.path-row input { min-width: 0; flex: 1; border: 1px solid var(--line); border-radius: 12px; background: #090e15; color: var(--text); padding: 11px 12px; outline: none; }
.path-row input:focus, .composer textarea:focus, .login-card input:focus { border-color: rgba(48, 214, 155, 0.7); box-shadow: 0 0 0 3px rgba(48, 214, 155, 0.1); }
.secondary-button { border: 1px solid var(--line); border-radius: 12px; padding: 0 13px; background: var(--surface-2); color: var(--text); }
.permission-row { display: flex; align-items: center; gap: 9px; margin-top: 11px; color: var(--muted); font-size: 12px; }
.danger-badge { padding: 4px 8px; border: 1px solid rgba(255, 107, 107, 0.26); border-radius: 999px; color: #ff9a9a; background: rgba(255, 107, 107, 0.08); font-weight: 700; }

.conversation { padding: 0 16px; }
.welcome-card { padding: 24px 20px; border: 1px solid var(--line); border-radius: 22px; background: linear-gradient(145deg, rgba(21, 31, 43, 0.95), rgba(12, 18, 26, 0.95)); }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.welcome-card h2 { margin: 9px 0 10px; font-size: 25px; letter-spacing: -0.035em; }
.welcome-card p { margin: 0; color: var(--muted); line-height: 1.65; font-size: 14px; }
.suggestions { display: grid; gap: 9px; margin-top: 18px; }
.suggestions button { text-align: left; border: 1px solid var(--line); border-radius: 13px; padding: 12px 14px; background: rgba(255,255,255,0.025); color: #dbe4ef; }

.message { margin: 13px 0; border: 1px solid var(--line); border-radius: 17px; overflow: hidden; background: var(--surface); }
.message.user { margin-left: 28px; border-color: rgba(48, 214, 155, 0.18); background: rgba(20, 71, 54, 0.28); }
.message-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 13px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.message-body { padding: 13px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.58; font-size: 14px; }
.message.command .message-body, .message.log .message-body { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; color: #c4d2e2; background: #090e14; max-height: 340px; overflow: auto; }
.message.error { border-color: rgba(255, 107, 107, 0.28); }
.message.error .message-head { color: #ff9c9c; }
.message.reasoning .message-body { color: var(--muted); }

.composer-wrap { position: fixed; z-index: 12; left: 50%; bottom: 0; width: min(880px, 100%); transform: translateX(-50%); padding: 8px 14px calc(9px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, transparent, rgba(8,12,18,.97) 20%); }
.composer { display: flex; align-items: flex-end; gap: 10px; border: 1px solid var(--line); border-radius: 20px; padding: 9px; background: rgba(18, 26, 36, 0.97); box-shadow: 0 14px 45px rgba(0,0,0,.35); }
.composer textarea { flex: 1; max-height: 150px; resize: none; border: 0; background: transparent; color: var(--text); padding: 8px 5px; outline: none; line-height: 1.45; }
.composer-actions { display: flex; gap: 7px; }
.round-button, .send-button { height: 40px; border: 0; border-radius: 13px; font-weight: 750; }
.round-button { width: 40px; background: var(--surface-2); color: var(--text); }
.send-button { min-width: 62px; padding: 0 15px; color: #03110b; background: var(--accent); }
.send-button:disabled, button:disabled { opacity: .45; }
.composer-hint { margin: 7px 0 0; text-align: center; color: #657284; font-size: 10px; }
.running-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; padding: 8px 12px; border: 1px solid rgba(48,214,155,.18); border-radius: 12px; background: rgba(13, 58, 44, .85); font-size: 12px; }
.running-bar i { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite; }
.running-bar button { border: 0; background: transparent; color: #ffaaaa; font-weight: 700; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }

.hidden { display: none !important; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.58); backdrop-filter: blur(3px); }
.sheet { position: fixed; z-index: 21; left: 50%; bottom: 0; width: min(880px, 100%); max-height: 75dvh; transform: translateX(-50%); padding: 12px 16px calc(18px + env(safe-area-inset-bottom)); border: 1px solid var(--line); border-bottom: 0; border-radius: 24px 24px 0 0; background: #111923; overflow: auto; }
.sheet-handle { width: 44px; height: 4px; margin: 0 auto 18px; border-radius: 9px; background: #465466; }
.sheet h3 { margin: 0 0 12px; }
.history-item { width: 100%; margin: 7px 0; padding: 12px; text-align: left; border: 1px solid var(--line); border-radius: 13px; background: #0c121a; color: var(--text); }
.history-item strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.history-item span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.logout-button { width: 100%; margin-top: 12px; padding: 13px; border: 1px solid rgba(255,107,107,.2); border-radius: 13px; background: rgba(255,107,107,.07); color: #ff9c9c; }

.login-body { display: grid; min-height: 100dvh; place-items: center; padding: 24px 18px; }
.login-card { width: min(420px, 100%); padding: 30px 24px; border: 1px solid var(--line); border-radius: 26px; background: rgba(16,23,32,.92); box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.login-logo { width: 58px; height: 58px; margin-bottom: 24px; border-radius: 18px; font-size: 25px; }
.login-card h1 { margin: 9px 0 8px; font-size: 28px; letter-spacing: -.035em; }
.login-intro { margin: 0 0 24px; color: var(--muted); }
.login-card label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.login-card input { width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 14px; outline: none; background: #090e15; color: var(--text); text-align: center; letter-spacing: .38em; font-size: 22px; }
.login-card form button { width: 100%; margin-top: 12px; padding: 14px; border: 0; border-radius: 14px; background: var(--accent); color: #03110b; font-weight: 800; }
.login-rules { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.45; }
.login-rules p { margin: 6px 0; }
.login-message { margin: 0 0 14px; padding: 11px 12px; border-radius: 12px; font-size: 13px; }
.login-message.error { color: #ffb0b0; background: rgba(255,107,107,.1); border: 1px solid rgba(255,107,107,.2); }
.login-message.locked { color: #ffd29b; background: rgba(255,180,84,.09); border: 1px solid rgba(255,180,84,.2); }

@media (min-width: 700px) {
  .suggestions { grid-template-columns: repeat(3, 1fr); }
  .conversation, .control-card { margin-left: 24px; margin-right: 24px; }
  .conversation { padding: 0; }
}
