:root {
  --bg: #0f172a;
  --surface: #0b1220;
  --card: #071221;
  --muted: #94a3b8;
  --accent: #7dd3fc;
  --accent-600: #38bdf8;
  --glass: rgba(255, 255, 255, 0.03);
  --radius: 12px;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    Segoe UI,
    Roboto,
    Helvetica,
    Arial,
    "Apple Color Emoji",
    "Segoe UI Emoji";
  margin: 0;
  background: linear-gradient(180deg, var(--bg), #071826);
  color: #e6eef6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.site-header {
  width: 100vw;
  background: linear-gradient(90deg, #04202a, #083849);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.2px;
}
.brand .badge {
  background: rgba(125, 211, 252, 0.12);
  color: var(--accent);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  margin-left: 8px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-pill {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03),
    rgba(255, 255, 255, 0.02)
  );
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--muted);
}
.btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: inherit;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn.small {
  padding: 4px 8px;
  font-size: 0.82rem;
}
.btn.primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-600));
  border: none;
  color: #042026;
}

.layout {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 22px;
  align-items: start;
}
@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .header-inner {
    padding: 12px;
  }
}

.chat-area {
  display: flex;
  flex-direction: column;
}
.chat-card {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.35);
  display: flex;
  flex-direction: column;
  min-height: 60vh;
  max-height: calc(100vh - 160px);
  flex-grow: 1;
}
.msgs {
  flex: 1;
  overflow: auto;
  padding: 12px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), transparent);
  border: 1px solid rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg {
  display: flex;
  margin-bottom: 12px;
  gap: 10px;
  align-items: flex-end;
}
.msg .bubble {
  max-width: 78%;
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.45;
  font-size: 0.96rem;
}
.msg.user {
  justify-content: flex-end;
}
.msg.user .bubble {
  background: linear-gradient(90deg, var(--accent), var(--accent-600));
  color: #042026;
  border-bottom-right-radius: 6px;
}
.msg.assistant {
  justify-content: flex-start;
}
.msg.assistant .bubble {
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  border-bottom-left-radius: 6px;
}
.meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.composer {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  padding-top: 12px;
}
.composer textarea {
  flex: 1;
  resize: vertical;
  min-height: 56px;
  max-height: 260px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  background: transparent;
  color: inherit;
  font-size: 1rem;
}
.composer textarea::placeholder {
  color: rgba(230, 238, 246, 0.5);
}
.composer textarea:focus {
  outline: none;
  box-shadow: 0 0 0 6px rgba(125, 211, 252, 0.04);
}
.composer-actions {
  display: flex;
  align-items: center;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 160px);
  overflow: auto;
  padding-right: 6px;
}
.panel {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.01),
    rgba(255, 255, 255, 0.005)
  );
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.02);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.panel-header h3,
h4 {
  margin: 0;
  color: #e6eef6;
}
.panel-actions {
  margin-top: 10px;
}
.mem-list {
  max-height: 220px;
  overflow: auto;
  padding: 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid rgba(255, 255, 255, 0.02);
}
.mem {
  padding: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.01);
  font-size: 0.95rem;
  color: var(--muted);
}
.json {
  background: rgba(255, 255, 255, 0.01);
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.02);
  max-height: 160px;
  overflow: auto;
  font-size: 0.86rem;
  color: var(--muted);
}
.cmds {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cmd {
  background: linear-gradient(
    90deg,
    rgba(125, 211, 252, 0.06),
    rgba(56, 189, 248, 0.03)
  );
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.92rem;
  border: 1px solid rgba(125, 211, 252, 0.06);
  cursor: pointer;
  color: var(--accent-600);
}

@media (max-width: 520px) {
  .header-inner {
    padding: 10px;
  }
  .brand {
    font-size: 0.98rem;
  }
  .composer textarea {
    min-height: 64px;
  }
}

.auth-container {
  min-height: calc(100vh - 72px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.45);
}
.auth-title {
  margin: 0 0 6px 0;
  font-size: 1.4rem;
  color: #e6eef6;
}
.auth-sub {
  margin: 0 0 14px 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.auth-form .field {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-form label {
  font-size: 0.9rem;
  color: #e6eef6;
}
.auth-form input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  background: transparent;
  color: inherit;
  font-size: 1rem;
}
.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}
.muted {
  color: var(--muted);
  text-decoration: none;
}
.error {
  margin-top: 12px;
  color: #ffb4b4;
  background: rgba(255, 180, 180, 0.03);
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 180, 180, 0.06);
}
