:root {
  color-scheme: dark;
  --bg: #07101d;
  --panel: rgba(11, 18, 31, 0.88);
  --panel-strong: rgba(13, 22, 38, 0.98);
  --text: #ecf4ff;
  --muted: #97a9c8;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #73d8ff;
  --accent-strong: #3cb9ea;
  --good: #68d391;
  --warn: #f6ad55;
  --danger: #fc8181;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(64, 129, 198, 0.25), transparent 35%),
    linear-gradient(180deg, #050a13, var(--bg));
  color: var(--text);
}

.shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
  display: grid;
  gap: 18px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(13, 20, 34, 0.9), rgba(8, 13, 23, 0.96));
  backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  padding: 22px 24px;
}

.appbar {
  position: relative;
  overflow: hidden;
}

.appbar::after {
  content: "";
  position: absolute;
  inset: auto -20% -70% -20%;
  height: 180px;
  background: radial-gradient(circle, rgba(115, 216, 255, 0.18), transparent 60%);
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  width: 68px;
  height: 68px;
  border-radius: 22px;
  padding: 8px;
  background: linear-gradient(180deg, rgba(115, 216, 255, 0.12), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(115, 216, 255, 0.18);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
  flex: none;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
}

h1 {
  margin: 0;
  font-size: clamp(2.5rem, 8vw, 5.6rem);
  line-height: 0.92;
  letter-spacing: -0.07em;
}

.sub {
  margin: 10px 0 0;
  max-width: 62ch;
  color: var(--muted);
  line-height: 1.55;
}

.badges,
.app-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
  gap: 18px;
}

.chat {
  min-height: 68vh;
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.panel .card {
  padding: 16px;
}

.chat-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.chat-head h2,
.panel h2 {
  margin: 0;
  font-size: 16px;
}

.small {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.mini-status {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  white-space: nowrap;
  font-size: 12px;
}

.messages {
  flex: 1;
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 6px 2px 14px;
}

.message {
  max-width: min(88%, 760px);
  padding: 12px 14px;
  border-radius: 18px;
  line-height: 1.45;
  border: 1px solid transparent;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user {
  margin-left: auto;
  background: linear-gradient(180deg, rgba(115, 216, 255, 0.2), rgba(115, 216, 255, 0.08));
  border-color: rgba(115, 216, 255, 0.2);
}

.message.assistant {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.07);
}

.message.system {
  background: rgba(255, 255, 255, 0.03);
  border-style: dashed;
  color: var(--muted);
}

.composer {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(5, 10, 18, 0.95);
  color: var(--text);
  padding: 14px 15px;
  font: inherit;
  outline: none;
}

textarea:focus {
  border-color: rgba(115, 216, 255, 0.45);
  box-shadow: 0 0 0 4px rgba(115, 216, 255, 0.08);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 11px 15px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font: inherit;
}

button:hover {
  border-color: rgba(115, 216, 255, 0.28);
}

button.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #04111b;
  border-color: transparent;
  font-weight: 700;
}

button.ghost {
  background: rgba(255, 255, 255, 0.03);
}

.panel {
  display: grid;
  gap: 16px;
}

.panel .card {
  padding: 16px;
}

.panel {
  display: grid;
  gap: 16px;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.grid-two button {
  border-radius: 16px;
  text-align: left;
  min-height: 52px;
}

.profile-box {
  margin: 10px 0 0;
  min-height: 120px;
  max-height: 260px;
  overflow: auto;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(5, 10, 18, 0.95);
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.hint {
  color: var(--muted);
  line-height: 1.55;
}

.permission-empty {
  color: var(--muted);
  line-height: 1.5;
}

.permission-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(115, 216, 255, 0.2);
  background: rgba(115, 216, 255, 0.06);
}

.permission-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.favorites-empty {
  color: var(--muted);
  line-height: 1.5;
}

.favorites-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.favorite-pill {
  border-radius: 999px;
  padding: 10px 14px;
  border: 1px solid rgba(115, 216, 255, 0.18);
  background: rgba(115, 216, 255, 0.08);
}

.memory-empty {
  color: var(--muted);
  line-height: 1.5;
}

.memory-list {
  display: grid;
  gap: 10px;
}

.memory-item {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  line-height: 1.45;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
    align-items: start;
  }

  .badges {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1280px);
    padding-top: 12px;
  }

  .chat {
    min-height: 62vh;
  }

  .grid-two {
    grid-template-columns: 1fr;
  }
}
