* { box-sizing: border-box; }
:root {
  --bg: #0f172a;
  --panel: #111827;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-2: #22c55e;
  --danger: #ef4444;
}

html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; }
header { padding: 20px; text-align: center; background: linear-gradient(90deg, #4f46e5, #06b6d4); }
header h1 { margin: 0; color: white; font-weight: 700; }
header .topnav {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
header .topnav a {
  color: #fff;
  text-decoration: none;
  background: rgba(255,255,255,0.15);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25);
}
header .topnav a:hover {
  background: rgba(255,255,255,0.25);
}

main { max-width: 1000px; margin: 24px auto; padding: 0 16px; }
.panel { background: var(--panel); border: 1px solid #1f2937; border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.panel h2 { margin-top: 0; font-size: 18px; }
.row { display: grid; grid-template-columns: 180px 1fr; gap: 12px; align-items: center; margin: 10px 0; }
.row label { color: var(--muted); }
.row input[type="password"], .row input[type="text"], .row select, textarea { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid #374151; background: #0b1220; color: var(--text); }
.row input[type="range"] { width: 100%; }

.actions { display: flex; gap: 10px; margin-top: 10px; }
button { background: var(--accent); color: white; border: none; padding: 10px 14px; border-radius: 8px; cursor: pointer; }
button:hover { filter: brightness(1.05); }
button.danger { background: var(--danger); }
.status { margin-top: 10px; color: var(--muted); }

.chat .messages { background: #0b1220; border: 1px solid #1f2937; border-radius: 8px; height: 320px; overflow-y: auto; padding: 12px; }
.message { margin: 8px 0; }
.message .role { font-weight: 600; color: var(--accent-2); }
.message .content { white-space: pre-wrap; margin-top: 4px; }
.message.assistant .role { color: #38bdf8; }

.chat-input { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 10px; }
footer { text-align: center; padding: 12px; color: var(--muted); }

.details {
  margin-top: 8px;
  background: #0f172a;
  border: 1px dashed #334155;
  padding: 8px;
  border-radius: 8px;
}

/* Home cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.card {
  background: var(--panel);
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 16px;
}
.card h3 { margin: 0 0 8px 0; }
.card p { margin: 0 0 12px 0; color: var(--muted); }
.card a.button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
}
.card a.button:hover { filter: brightness(1.05); }

/* --- ChatGPT-like layout additions --- */
.chatgpt-layout {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.chatgpt-header, .chatgpt-footer {
  padding: 12px 16px;
  border-bottom: 1px solid #1f2937;
  background: #0b1220;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chatgpt-footer { border-top: 1px solid #1f2937; border-bottom: none; }
.chatgpt-header .brand { font-weight: 700; }
.chatgpt-header .right-actions .ghost {
  color: var(--muted);
  text-decoration: none;
  border: 1px solid #243040;
  padding: 4px 8px;
  border-radius: 8px;
}

.chatgpt-main {
  display: flex;
  flex-direction: column;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 12px;
}

.messages.bubbles {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  border-radius: 12px;
  background: #0b1220;
  border: 1px solid #1f2937;
  min-height: 300px;
}

/* Bubble styling compatible with both layouts */
.message {
  display: flex;
  margin: 10px 0;
}
.message.user { justify-content: flex-end; }
.message .content {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.message.user .content {
  background: #1e2638;
  border: 1px solid #2a3650;
}
.message.assistant .content {
  background: #0f172a;
  border: 1px solid #22304a;
}

/* Composer */
.composer-wrap { position: relative; margin-top: 10px; }
.composer {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  background: #0b1220;
  border: 1px solid #1f2937;
  border-radius: 14px;
  padding: 8px;
}
.composer input[type="text"] {
  background: transparent;
  border: none;
  color: var(--text);
  outline: none;
  padding: 8px;
}
.icon-btn, .send-btn {
  background: #111827;
  border: 1px solid #243040;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}
.send-btn { background: var(--accent); border-color: var(--accent); color: #fff; }
.composer-status { margin-top: 6px; color: var(--muted); font-size: 12px; }

/* URL popover */
.popover {
  position: absolute;
  bottom: 58px;
  left: 40px;
  background: #0b1220;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.popover.hidden { display: none; }
.popover input[type="text"] {
  width: 260px;
  padding: 8px;
  border: 1px solid #243040;
  border-radius: 8px;
  background: #0f172a;
  color: var(--text);
}
.popover button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 10px;
  border-radius: 8px;
}
