:root {
  color-scheme: dark;
  --bg: #0b0d13;
  --panel: #131826;
  --panel-2: #1a2235;
  --border: #2a3652;
  --text: #eef2ff;
  --muted: #a6b1c8;
  --accent: #8b5cf6;
  --good: #22c55e;
  --bad: #ef4444;

}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; }
.centered { width: min(420px, calc(100vw - 28px)); margin: 7vh auto; padding: 20px; }

/* Modern Login Page */
.login-wrapper {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.login-bg-effect {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse at 50% 0%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(56, 189, 248, 0.08) 0%, transparent 40%),
    radial-gradient(ellipse at 20% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}
.login-card {
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, rgba(19, 24, 38, 0.95) 0%, rgba(11, 13, 19, 0.98) 100%);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(42, 54, 82, 0.6);
  box-shadow: 
    0 25px 50px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(139, 92, 246, 0.1) inset;
  padding: 40px 32px;
}
.logo-container {
  text-align: center;
  margin-bottom: 8px;
}
.codex-logo {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  background: linear-gradient(135deg, #ffffff 0%, #a78bfa 50%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 60px rgba(139, 92, 246, 0.3);
}
.login-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 32px;
  letter-spacing: 0.02em;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.input-group {
  position: relative;
}
.input-group input {
  width: 100%;
  background: rgba(26, 34, 53, 0.6);
  border: 1px solid rgba(42, 54, 82, 0.8);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
  transition: all 0.2s ease;
  outline: none;
}
.input-group input:focus {
  border-color: rgba(139, 92, 246, 0.6);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
  background: rgba(26, 34, 53, 0.8);
}
.input-group input::placeholder {
  color: rgba(166, 177, 200, 0.5);
}
.input-glow {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: radial-gradient(600px circle at 50% 0%, rgba(139, 92, 246, 0), rgba(139, 92, 246, 0.04));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.input-group input:focus + .input-glow {
  opacity: 1;
}
.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
}
.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.45);
}
.login-btn:active {
  transform: translateY(0);
}
.btn-icon {
  font-size: 18px;
  transition: transform 0.2s ease;
}
.login-btn:hover .btn-icon {
  transform: translateX(3px);
}
.login-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  font-size: 12px;
  color: rgba(166, 177, 200, 0.7);
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
  animation: statusPulse 2s infinite ease-in-out;
}
@keyframes statusPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.9); }
}
.app-shell { height: 100vh; display: grid; grid-template-rows: auto 1fr auto auto; }
.topbar { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.topbar h1 { margin: 0; font-size: 18px; text-transform: lowercase; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; gap: 6px; }
.messages { overflow: auto; padding: 12px 12px 220px 12px; display: flex; flex-direction: column; gap: 8px; position: relative; }
.message { scroll-margin-bottom: 200px; }
.approvals-stack { position: fixed; left: 10px; right: 10px; bottom: 170px; display: flex; flex-direction: column; gap: 8px; z-index: 20; pointer-events: none; }
.approval-item { pointer-events: auto; background: #2f2631; border: 1px solid #5a3d67; border-radius: 12px; padding: 10px; }
.composer-wrap { position: fixed; left: 0; right: 0; bottom: 54px; padding: 10px; background: linear-gradient(180deg, transparent, rgba(11,13,19,.95) 25%); z-index: 15; }
.composer { 
  background: var(--panel); 
  border: 1px solid var(--border); 
  border-radius: 14px; 
  padding: 6px; 
  display: flex; 
  align-items: flex-end; 
  gap: 6px; 
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.composer:focus-within {
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
}
.composer textarea { 
  flex: 1; 
  min-height: 40px; 
  max-height: 80px; 
  border: none;
  background: transparent;
  padding: 10px 12px;
  resize: none;
  line-height: 1.5;
}
.composer textarea:focus {
  outline: none;
  box-shadow: none;
}
.composer textarea::placeholder {
  color: rgba(166, 177, 200, 0.5);
}
.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 3px 12px rgba(139, 92, 246, 0.3);
  white-space: nowrap;
  flex-shrink: 0;
}
.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 18px rgba(139, 92, 246, 0.4);
}
.send-btn:active {
  transform: translateY(0);
}
.send-icon {
  font-size: 16px;
  transition: transform 0.2s ease;
}
.send-btn:hover .send-icon {
  transform: translateX(3px);
}
.dock { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1px; background: var(--border); z-index: 30; padding: 1px; }
.dock-btn { 
  border-radius: 0; 
  border: 0; 
  background: var(--panel); 
  padding: 14px 12px; 
  font-weight: 600; 
  font-size: 13px;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  transition: all 0.15s ease;
  position: relative;
}
.dock-btn:hover {
  background: var(--panel-2);
}
.dock-btn:active {
  background: rgba(139, 92, 246, 0.2);
}
.panel-sheet { position: fixed; left: 0; right: 0; bottom: 54px; max-height: 68vh; overflow: auto; background: #101523; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; padding: 12px; z-index: 40; box-shadow: 0 -20px 40px rgba(0,0,0,.35); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.panel-head h2 { margin: 0; font-size: 16px; text-transform: lowercase; }
.thread-list, .setting-group { display: flex; flex-direction: column; gap: 8px; }
.thread-item, .message { background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px; text-align: left; }
.thread-item.active { outline: 2px solid var(--accent); }
.thread-item.newly-created { border-color: #7c3aed; box-shadow: 0 0 0 1px rgba(139,92,246,.5) inset; }
.thread-topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.thread-actions { display: flex; align-items: center; gap: 6px; }
.thread-actions .mini { font-size: 11px; padding: 5px 8px; border-radius: 8px; }
.new-pill { font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #d8b4fe; background: rgba(124,58,237,.22); border: 1px solid rgba(167,139,250,.5); border-radius: 999px; padding: 2px 7px; }
.thread-preview { margin-top: 4px; color: var(--muted); font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thread-time { color: var(--muted); font-size: 11px; }
.message.user { border-left: 3px solid #38bdf8; }
.message.agent { border-left: 3px solid var(--accent); }
.message.command { border-left: 3px solid #f59e0b; }
.message.system { border-left: 3px solid #64748b; }
.message.typing { border-left: 3px solid #8b5cf6; }
.typing-dots { display: inline-flex; gap: 5px; align-items: center; min-height: 16px; }
.typing-dots span { width: 6px; height: 6px; border-radius: 999px; background: #c4b5fd; opacity: .45; animation: typingPulse 1s infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typingPulse { 0%, 80%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-3px); opacity: 1; } }
.message.command details { margin-top: 4px; }
.message.command summary { cursor: pointer; color: #f8cc7a; }
.message.command.collapsed pre { max-height: 90px; overflow: auto; }
.message small, .muted { color: var(--muted); }
input, select, textarea, button { font: inherit; color: var(--text); }
input, select, textarea { width: 100%; border: 1px solid var(--border); background: var(--panel-2); border-radius: 10px; padding: 10px; }
button { 
  border: 0; 
  border-radius: 10px; 
  padding: 10px 16px; 
  background: var(--accent); 
  cursor: pointer; 
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
}
button:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}
button:active {
  transform: translateY(0);
}
button.ghost { 
  background: #27344f;
}
button.ghost:hover {
  background: #334161;
}
button.approve { background: var(--good); }
button.decline { background: var(--bad); }
label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.row-buttons { display: flex; gap: 8px; margin: 4px 0 8px; }
.row-buttons > button { flex: 1; }
.folder-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.folder-name { font-weight: 600; }
summary { cursor: pointer; font-weight: 700; margin-bottom: 8px; }
.error { color: #fca5a5; min-height: 20px; }
pre { white-space: pre-wrap; word-break: break-word; margin: 6px 0 0; }
