/* Personal Agent — dark, calm, glass accents */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0b1020;
  --bg2: #101731;
  --card: rgba(255,255,255,.05);
  --line: rgba(255,255,255,.09);
  --ink: #e8ecf8;
  --muted: #8b93ad;
  --brand: #7c9cff;
  --brand2: #b28cff;
  --good: #4ade80;
  --err: #ff6b81;
}
html, body { height: 100%; }
body {
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  background: radial-gradient(1200px 700px at 80% -10%, #1b2450 0%, var(--bg) 55%);
  color: var(--ink);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }

button { font: inherit; cursor: pointer; border: 0; }
.ghost {
  background: transparent; color: var(--muted); border-radius: 10px;
  padding: 6px 10px; font-size: 14px;
}
.ghost:hover { background: var(--card); color: var(--ink); }

/* ── Login ── */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(380px, 100%); text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 36px 28px; backdrop-filter: blur(14px);
}
.logo {
  width: 54px; height: 54px; margin: 0 auto 14px; display: grid; place-items: center;
  font-size: 26px; border-radius: 16px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
}
.logo.big { width: 64px; height: 64px; font-size: 30px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); margin-bottom: 22px; }
.login-card input {
  width: 100%; margin-bottom: 12px; padding: 12px 14px; font-size: 16px;
  background: rgba(255,255,255,.06); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; outline: none;
}
.login-card input:focus { border-color: var(--brand); }
.login-card button[type=submit] {
  width: 100%; padding: 12px; border-radius: 12px; color: #fff; font-weight: 600;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
}
.err { color: var(--err); font-size: 13px; margin-top: 10px; }

/* ── Layout ── */
.app { display: flex; height: 100dvh; }
.sidebar {
  width: 264px; flex: none; display: flex; flex-direction: column;
  background: rgba(0,0,0,.25); border-right: 1px solid var(--line);
}
.side-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 14px 10px;
}
.brand { font-weight: 700; letter-spacing: .3px; }
.convlist { flex: 1; overflow-y: auto; padding: 6px 8px; }
.convitem {
  display: block; width: 100%; text-align: left; padding: 9px 10px; margin-bottom: 2px;
  border-radius: 10px; color: var(--muted); font-size: 13.5px; background: transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.convitem:hover { background: var(--card); color: var(--ink); }
.convitem.active { background: var(--card); color: var(--ink); }
.side-bottom {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-top: 1px solid var(--line); gap: 8px;
}
.side-bottom .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-bottom: 1px solid var(--line);
}
.topbar .title { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { display: none; }

/* ── Messages ── */
.messages { flex: 1; overflow-y: auto; padding: 22px 18px 10px; scroll-behavior: smooth; }
.msg { max-width: 760px; margin: 0 auto 16px; display: flex; gap: 10px; }
.msg .bubble {
  padding: 11px 15px; border-radius: 16px; font-size: 14.5px;
  overflow-wrap: break-word; min-width: 0;
}
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  color: #fff; border-bottom-right-radius: 6px; max-width: 85%;
  white-space: pre-wrap;
}
.msg.assistant .bubble {
  background: var(--card); border: 1px solid var(--line);
  border-bottom-left-radius: 6px; flex: 1;
}
.msg .bubble p { margin: 0 0 8px; } .msg .bubble p:last-child { margin: 0; }
.msg .bubble ul, .msg .bubble ol { margin: 0 0 8px 20px; }
.msg .bubble code {
  font-family: ui-monospace, Menlo, monospace; font-size: 13px;
  background: rgba(255,255,255,.09); border-radius: 5px; padding: 1px 5px;
}
.msg .bubble pre {
  background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin: 0 0 8px; overflow-x: auto;
}
.msg .bubble pre code { background: none; padding: 0; }
.msg .bubble table { border-collapse: collapse; margin: 0 0 8px; font-size: 13.5px; }
.msg .bubble th, .msg .bubble td { border: 1px solid var(--line); padding: 4px 9px; }
.msg .bubble a { color: var(--brand); }

.toolnote {
  max-width: 760px; margin: 0 auto 10px; color: var(--muted); font-size: 12.5px;
  display: flex; align-items: center; gap: 6px;
}
.toolnote .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: pulse 1s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }

/* ── Welcome ── */
.welcome { max-width: 640px; margin: 12vh auto 0; text-align: center; }
.welcome h2 { margin: 16px 0 20px; font-size: 22px; font-weight: 650; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 8px 14px; font-size: 13px;
}
.chip:hover { color: var(--ink); border-color: var(--brand); }

/* ── Composer ── */
.composer {
  display: flex; gap: 10px; align-items: flex-end;
  max-width: 792px; width: 100%; margin: 0 auto;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
}
.composer textarea {
  flex: 1; resize: none; max-height: 160px; padding: 12px 16px; font: inherit; font-size: 16px;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 18px; outline: none;
  backdrop-filter: blur(10px);
}
.composer textarea:focus { border-color: var(--brand); }
.composer button {
  flex: none; width: 44px; height: 44px; border-radius: 50%; color: #fff; font-size: 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
}
.composer button:disabled { opacity: .4; cursor: default; }

/* ── Mobile ── */
@media (max-width: 760px) {
  .sidebar {
    position: fixed; inset: 0 30% 0 0; z-index: 20; transform: translateX(-100%);
    transition: transform .22s ease; background: #0d1329;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.6); }
  .menu { display: block; }
}

/* ── Confirm/Cancel action cards ── */
.action-card {
  max-width: 760px; margin: 0 auto 16px;
  background: rgba(124,156,255,.08);
  border: 1px solid rgba(124,156,255,.35); border-radius: 16px;
  padding: 14px 16px;
}
.action-card.done { border-color: rgba(74,222,128,.4); background: rgba(74,222,128,.06); }
.action-card.declined { border-color: var(--line); background: var(--card); opacity: .7; }
.ac-head { font-size: 12px; letter-spacing: .4px; text-transform: uppercase; color: var(--brand); margin-bottom: 6px; }
.action-card.done .ac-head { color: var(--good); }
.ac-summary { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.ac-buttons { display: flex; gap: 10px; }
.ac-confirm, .ac-cancel {
  padding: 9px 18px; border-radius: 10px; font-weight: 600; font-size: 14px;
}
.ac-confirm { background: linear-gradient(135deg, #34d399, #4ade80); color: #06281a; }
.ac-cancel { background: var(--card); border: 1px solid var(--line); color: var(--muted); }
.ac-cancel:hover { color: var(--ink); }
.ac-status { font-size: 13px; color: var(--muted); }

/* ── Attachments ── */
.composer-wrap { max-width: 792px; width: 100%; margin: 0 auto; }
.composer-wrap .composer { max-width: none; margin: 0; }
#attachBtn {
  flex: none; width: 44px; height: 44px; border-radius: 50%; font-size: 17px;
  background: var(--card); border: 1px solid var(--line);
}
#attachBtn:hover { border-color: var(--brand); }
.attach-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 8px; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 12.5px; color: var(--muted);
}
.attach-chip.ready { color: var(--ink); border-color: rgba(124,156,255,.4); }
.attach-chip.error { color: var(--err); border-color: var(--err); }
.attach-chip .x { cursor: pointer; opacity: .6; font-size: 14px; }
.attach-chip .x:hover { opacity: 1; }
.attach-chip .spin {
  width: 11px; height: 11px; border: 2px solid var(--line); border-top-color: var(--brand);
  border-radius: 50%; animation: rot 1s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }
