/* Kognetra — interface styles. Apple system type and colours, blue as the one accent. */

:root {
  --blue: #007aff;
  --blue-deep: #0062d6;
  --blue-soft: rgba(0, 122, 255, 0.12);
  --blue-glow: rgba(0, 122, 255, 0.28);
  --bg: #f2f3f7;
  --panel: rgba(255, 255, 255, 0.62);
  --card: rgba(255, 255, 255, 0.86);
  --solid: #ffffff;
  --label: #1d1d1f;
  --label-2: rgba(60, 60, 67, 0.72);
  --label-3: rgba(60, 60, 67, 0.46);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --line: rgba(60, 60, 67, 0.13);
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(15, 35, 80, 0.07);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.05), 0 22px 60px rgba(15, 35, 80, 0.16);
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --bounce: cubic-bezier(0.34, 1.4, 0.64, 1);
  --sidebar: 284px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --blue: #0a84ff;
    --blue-deep: #0a6fdb;
    --blue-soft: rgba(10, 132, 255, 0.2);
    --blue-glow: rgba(10, 132, 255, 0.4);
    --bg: #08090c;
    --panel: rgba(28, 29, 34, 0.6);
    --card: rgba(36, 37, 43, 0.82);
    --solid: #1c1c1f;
    --label: #f5f5f7;
    --label-2: rgba(235, 235, 245, 0.68);
    --label-3: rgba(235, 235, 245, 0.38);
    --fill: rgba(120, 120, 128, 0.22);
    --fill-2: rgba(120, 120, 128, 0.34);
    --line: rgba(255, 255, 255, 0.1);
    --green: #30d158;
    --orange: #ff9f0a;
    --red: #ff453a;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.4), 0 22px 60px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { height: 100dvh; }
body {
  margin: 0;
  font: 15px/1.5 var(--font);
  letter-spacing: -0.01em;
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--blue-glow); outline-offset: 2px; }
[hidden] { display: none !important; }
svg { display: block; }
[data-icon] { display: inline-grid; place-items: center; flex: none; }
::selection { background: var(--blue-glow); }

/* Soft blue light behind everything */
.aurora { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.aurora i { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.55; animation: drift 26s ease-in-out infinite alternate; }
.aurora i:nth-child(1) { width: 52vw; height: 52vw; left: 28%; top: -30%; background: #7cc0ff; }
.aurora i:nth-child(2) { width: 38vw; height: 38vw; right: -12%; bottom: -22%; background: #9db4ff; animation-duration: 34s; animation-direction: alternate-reverse; }
.aurora i:nth-child(3) { width: 30vw; height: 30vw; left: -8%; bottom: 4%; background: #a8e6ff; animation-duration: 30s; }
@media (prefers-color-scheme: dark) {
  .aurora i { opacity: 0.26; }
  .aurora i:nth-child(1) { background: #0a5fd8; }
  .aurora i:nth-child(2) { background: #2a3fb8; }
  .aurora i:nth-child(3) { background: #0a7fa8; }
}
@keyframes drift { to { transform: translate3d(6vw, 5vh, 0) scale(1.12); } }

/* ── Frame ─────────────────────────────────────────────────────────────── */
.app { position: relative; display: flex; height: 100%; }

.sidebar {
  width: var(--sidebar);
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 12px 12px;
  background: var(--panel);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
  border-right: 1px solid var(--line);
  transition: margin-left 0.5s var(--spring), opacity 0.3s ease;
  z-index: 5;
}
.app.collapsed .sidebar { margin-left: calc(var(--sidebar) * -1); opacity: 0; pointer-events: none; }

.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 4px 6px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-name { font: 600 17px/1 var(--font); letter-spacing: -0.03em; }

.mark {
  width: 26px; height: 26px; border-radius: 28%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M22 17v30M24 33l17-16M30 28l13 19' stroke='white' stroke-width='6' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E") center / 100% no-repeat,
    linear-gradient(145deg, #46adff, #0058e0);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 3px 10px var(--blue-glow);
  flex: none;
}
.mark-lg { width: 58px; height: 58px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 14px 34px var(--blue-glow); }

.icon-btn {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  color: var(--label-2);
  transition: background 0.2s, color 0.2s, transform 0.25s var(--spring);
}
.icon-btn:hover { background: var(--fill); color: var(--label); }
.icon-btn:active { transform: scale(0.9); }

.new-chat {
  display: flex; align-items: center; gap: 9px;
  height: 40px; padding: 0 12px;
  border-radius: 12px;
  background: var(--blue);
  color: #fff; font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 6px 16px var(--blue-glow);
  transition: transform 0.3s var(--spring), box-shadow 0.3s, filter 0.2s;
}
.new-chat:hover { filter: brightness(1.07); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 9px 22px var(--blue-glow); }
.new-chat:active { transform: scale(0.97); }
.new-chat kbd { margin-left: auto; font: 500 12px var(--font); opacity: 0.7; }

.search {
  display: flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 10px;
  border-radius: 10px; background: var(--fill);
  color: var(--label-3);
  transition: box-shadow 0.2s, background 0.2s;
}
.search:focus-within { box-shadow: 0 0 0 3px var(--blue-glow); background: var(--card); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--label); }
.search input::placeholder { color: var(--label-3); }
.search input::-webkit-search-cancel-button { display: none; }

.chats { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: none; }
.chats::-webkit-scrollbar { display: none; }
.group { margin: 14px 8px 5px; font: 600 11.5px var(--font); letter-spacing: 0.01em; color: var(--label-3); }
.chat {
  position: relative; display: flex; align-items: center;
  width: 100%; height: 36px; padding: 0 10px; border-radius: 9px;
  text-align: left; color: var(--label);
  transition: background 0.18s, transform 0.25s var(--spring);
  animation: rise 0.45s var(--spring) both;
}
.chat > span:first-child { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat:hover { background: var(--fill); }
.chat:active { transform: scale(0.985); }
.chat.active { background: var(--blue-soft); color: var(--blue); font-weight: 500; }
.chat .del {
  width: 24px; height: 24px; margin-right: -4px; border-radius: 7px;
  display: grid; place-items: center; color: var(--label-3);
  opacity: 0; transform: scale(0.8); transition: opacity 0.15s, transform 0.2s var(--spring), background 0.15s, color 0.15s;
}
.chat:hover .del, .chat .del:focus-visible { opacity: 1; transform: none; }
.chat .del:hover { background: var(--fill-2); color: var(--red); }
.chats-empty { margin: 26px 10px; color: var(--label-3); font-size: 13px; line-height: 1.45; }

.account {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 11px; border-radius: 12px;
  background: var(--fill);
}
.account .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); flex: none; transition: background 0.3s; }
.account.ok .dot { background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 20%, transparent); }
.account.bad .dot { background: var(--red); }
.account .grow { min-width: 0; }
.account .icon-btn { width: 28px; height: 28px; margin-right: -4px; }
.account strong { display: block; font-size: 13px; font-weight: 600; line-height: 1.25; }
.account small { display: block; font-size: 11.5px; color: var(--label-2); line-height: 1.3; }

/* ── Main column ───────────────────────────────────────────────────────── */
.main { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 52px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 14px; }
#topNew, .scrim { display: none; }
#expand { opacity: 0; pointer-events: none; transform: translateX(-8px); transition: opacity 0.3s, transform 0.4s var(--spring), background 0.2s; }
.app.collapsed #expand { opacity: 1; pointer-events: auto; transform: none; }
.chat-title {
  margin: 0; font: 600 15px var(--font); letter-spacing: -0.02em;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  transition: opacity 0.3s;
}
.main.empty .chat-title { opacity: 0; }

.thread {
  flex: 1 1 0; min-height: 0; overflow-y: auto;
  scroll-behavior: smooth;
  mask-image: linear-gradient(to bottom, transparent 0, #000 22px, #000 calc(100% - 26px), transparent 100%);
  transition: flex-grow 0.7s var(--spring);
}
.main.empty .thread { flex-grow: 0; }
.thread-inner { max-width: 768px; margin: 0 auto; padding: 18px 24px 30px; }

.stage {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center;
  padding: 0 24px 14px;
  transition: flex-grow 0.7s var(--spring);
}
.main.empty .stage { flex-grow: 1; justify-content: center; padding-bottom: 9vh; }

.hero {
  text-align: center; max-height: 0; opacity: 0; overflow: hidden;
  transform: translateY(-14px) scale(0.96);
  transition: max-height 0.6s var(--spring), opacity 0.3s, transform 0.6s var(--spring), margin 0.6s var(--spring);
}
.main.empty .hero { max-height: 260px; opacity: 1; transform: none; margin-bottom: 26px; overflow: visible; }
.hero .mark { display: inline-block; margin-bottom: 20px; animation: float 6s ease-in-out infinite; }
.hero h2 {
  margin: 0; font: 700 clamp(30px, 4.2vw, 44px)/1.08 "SF Pro Display", var(--font); letter-spacing: -0.04em;
  background: linear-gradient(100deg, var(--label) 20%, var(--blue) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { margin: 10px 0 0; color: var(--label-2); font-size: 16px; }
@keyframes float { 50% { transform: translateY(-6px) rotate(-2deg); } }

/* ── Files ─────────────────────────────────────────────────────────────── */
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 9px;
  font-weight: 500; color: var(--label); text-align: left;
  transition: background 0.18s, color 0.18s, transform 0.25s var(--spring);
}
.nav-item [data-icon] { color: var(--blue); }
.nav-item:hover { background: var(--fill); }
.nav-item:active { transform: scale(0.98); }
.nav-item.disconnect { color: var(--red); }
.nav-item.disconnect [data-icon] { color: var(--red); }
.nav-item.disconnect:hover { background: color-mix(in srgb, var(--red) 12%, transparent); }
.nav-item.active { background: var(--blue-soft); color: var(--blue); }

.drive { display: none; flex: 1 1 0; min-height: 0; overflow-y: auto; }
.main.in-files .drive { display: block; animation: rise 0.5s var(--spring) both; }
.main.in-files .thread, .main.in-files .stage { display: none; }
.drive-inner { max-width: 1040px; margin: 0 auto; padding: 4px 28px 40px; }
.drive-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; min-width: 0; }
.crumbs button {
  padding: 3px 8px; border-radius: 9px; max-width: 260px;
  font: 700 26px/1.2 "SF Pro Display", var(--font); letter-spacing: -0.035em; color: var(--label-3);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  transition: color 0.2s, background 0.2s;
}
.crumbs button:hover { color: var(--label); background: var(--fill); }
.crumbs button:last-of-type { color: var(--label); }
.crumbs i { color: var(--label-3); display: grid; transform: rotate(-90deg); }
.pill.solid { background: var(--blue); color: #fff; box-shadow: 0 4px 12px var(--blue-glow); }
.pill.solid:hover { background: var(--blue); filter: brightness(1.08); }

.space { margin-bottom: 20px; padding: 14px 16px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.space-top { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 9px; }
.space-top strong { font-size: 15px; font-weight: 600; }
.space-top small { font-size: 12.5px; color: var(--label-2); }
.space.low .space-top small { color: var(--tone); font-weight: 600; }
.space-bar { display: flex; gap: 2px; height: 10px; border-radius: 5px; background: var(--fill); overflow: hidden; }
.space-bar i { display: block; width: 0; min-width: 0; transition: width 1s var(--spring); }
.space-bar .seg-files { background: var(--blue); }
.space-bar .seg-chats { background: color-mix(in srgb, var(--blue) 50%, var(--label-3)); }
.space-bar .seg-other { background: var(--label-3); }
.space-key { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 9px; font-size: 12.5px; color: var(--label-2); }
.space-key span { display: inline-flex; align-items: center; gap: 6px; }
.space-key span::before { content: ""; width: 8px; height: 8px; border-radius: 3px; background: var(--dot); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; }
.tile {
  position: relative; display: flex; flex-direction: column; min-height: 132px; padding: 14px;
  border-radius: 18px; background: var(--panel); border: 1px solid var(--line); cursor: pointer;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  transition: transform 0.4s var(--spring), box-shadow 0.3s, background 0.2s, border-color 0.2s;
  animation: file-in 0.5s var(--bounce) both;
}
.tile:hover, .tile:focus-within { transform: translateY(-3px); background: var(--card); box-shadow: var(--shadow-1); border-color: color-mix(in srgb, var(--blue) 35%, transparent); }
.tile:active { transform: scale(0.98); }
.tile-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: auto; padding-bottom: 14px; }
.tile .badge { width: 44px; height: 44px; border-radius: 12px; font-size: 11px; }
.folder-ico { color: var(--blue); filter: drop-shadow(0 4px 8px var(--blue-glow)); }
.tile-actions { display: flex; gap: 2px; opacity: 0; transform: translateY(-4px); transition: opacity 0.2s, transform 0.3s var(--spring); }
.tile:hover .tile-actions, .tile:focus-within .tile-actions { opacity: 1; transform: none; }
.tile-actions button {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--label-2);
  transition: background 0.15s, color 0.15s, transform 0.25s var(--bounce);
}
.tile-actions button:hover { background: var(--fill-2); color: var(--blue); transform: scale(1.1); }
.tile-actions button.danger:hover, .tile-actions button.armed { background: var(--red); color: #fff; }
.tile-name {
  font-weight: 600; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile small { margin-top: 2px; font-size: 12px; color: var(--label-2); }
.tile input {
  width: 100%; padding: 3px 7px; margin: -4px -8px; border-radius: 8px; border: 0; outline: 0;
  font-weight: 600; font-size: 14px; background: var(--solid); box-shadow: 0 0 0 3px var(--blue-glow);
}
.tile.loading { pointer-events: none; }
.tile.loading .badge { animation: pulse 1.1s ease-in-out infinite; }
.tile.leaving { animation: chip-out 0.25s ease forwards; }
.tiles-empty {
  grid-column: 1 / -1; display: grid; justify-items: center; gap: 4px; padding: 80px 20px; text-align: center;
  border-radius: 24px; border: 2px dashed var(--line); color: var(--label-2);
}
.tiles-empty [data-icon] { color: var(--blue); margin-bottom: 10px; }
.tiles-empty strong { font-size: 19px; letter-spacing: -0.03em; color: var(--label); }

.file .keep {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  color: var(--label-3); transition: background 0.2s, color 0.2s, transform 0.35s var(--bounce);
}
.file .keep:hover { background: var(--fill); color: var(--blue); transform: scale(1.08); }
.file .keep.saved { color: var(--blue); }

/* ── Composer ──────────────────────────────────────────────────────────── */
.composer {
  width: 100%; max-width: 768px;
  padding: 10px 10px 8px;
  border-radius: 26px;
  background: var(--card);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  backdrop-filter: saturate(180%) blur(28px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  transition: box-shadow 0.35s var(--spring), border-color 0.25s, transform 0.35s var(--spring);
}
.composer:focus-within {
  border-color: color-mix(in srgb, var(--blue) 45%, transparent);
  box-shadow: 0 0 0 4px var(--blue-soft), var(--shadow-2);
}
.composer textarea {
  display: block; width: 100%; max-height: 220px;
  padding: 7px 10px 8px; border: 0; outline: 0; resize: none; background: none;
  font-size: 16px; line-height: 1.45;
}
.composer textarea::placeholder { color: var(--label-3); }
.composer-bar { display: flex; align-items: center; gap: 6px; }
.grow { flex: 1; }

.tool-btn {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; color: var(--label-2);
  background: var(--fill);
  transition: transform 0.35s var(--bounce), background 0.2s, color 0.2s;
}
.tool-btn:hover { background: var(--fill-2); color: var(--label); transform: rotate(90deg); }
.tool-btn:active { transform: rotate(90deg) scale(0.88); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px 0 10px; border-radius: 17px;
  background: var(--fill); color: var(--label-2); font-size: 13.5px; font-weight: 500;
  transition: background 0.25s, color 0.25s, transform 0.3s var(--spring);
}
.pill:hover { background: var(--fill-2); }
.pill:active { transform: scale(0.95); }
.pill[aria-pressed="true"] { background: var(--blue-soft); color: var(--blue); }
.pill[aria-pressed="true"] [data-icon] { animation: spin-once 0.7s var(--spring); }
@keyframes spin-once { from { transform: rotate(-120deg) scale(0.7); } }
.pill.quiet { background: none; padding: 0 8px 0 12px; }
.pill.quiet:hover, .pill.quiet[aria-expanded="true"] { background: var(--fill); }
.pill.quiet [data-icon] { transition: transform 0.35s var(--spring); opacity: 0.6; }
.pill.quiet[aria-expanded="true"] [data-icon] { transform: rotate(180deg); }

.send {
  position: relative; width: 34px; height: 34px; border-radius: 50%;
  background: var(--blue); color: #fff;
  box-shadow: 0 4px 12px var(--blue-glow);
  transition: transform 0.35s var(--bounce), background 0.25s, box-shadow 0.25s, opacity 0.25s;
}
.send:hover { transform: scale(1.08); }
.send:active { transform: scale(0.9); }
.send:disabled { background: var(--fill-2); color: var(--label-3); box-shadow: none; transform: none; cursor: default; }
.send > span { position: absolute; inset: 0; display: grid; place-items: center; transition: transform 0.35s var(--bounce), opacity 0.2s; }
.send-stop::after { content: ""; width: 11px; height: 11px; border-radius: 3px; background: currentColor; }
.send-stop { transform: scale(0); opacity: 0; }
.send.busy .send-arrow { transform: scale(0) rotate(90deg); opacity: 0; }
.send.busy .send-stop { transform: none; opacity: 1; }

.picker { position: relative; }
.menu {
  position: absolute; right: 0; bottom: calc(100% + 10px); width: min(250px, calc(100vw - 32px)); padding: 6px;
  border-radius: 16px; background: var(--card);
  -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px);
  border: 1px solid var(--line); box-shadow: var(--shadow-2);
  transform-origin: 85% 100%;
  animation: pop 0.34s var(--bounce);
  z-index: 20;
}
@keyframes pop { from { opacity: 0; transform: scale(0.82) translateY(8px); } }
.menu button {
  display: grid; grid-template-columns: 1fr 18px; align-items: center;
  width: 100%; padding: 8px 10px; border-radius: 10px; text-align: left;
  transition: background 0.15s;
}
.menu button:hover { background: var(--blue); color: #fff; }
.menu button:hover small, .menu button:hover [data-icon] { color: rgba(255, 255, 255, 0.85); }
.menu strong, .menu small { grid-column: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu strong { display: block; font-size: 14px; font-weight: 500; }
.menu small { display: block; font-size: 12px; color: var(--label-2); }
.menu [data-icon] { grid-row: 1 / span 2; grid-column: 2; color: var(--blue); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 2px; }
.chips:not(:empty) { padding: 2px 2px 8px; }
.chip {
  display: flex; align-items: center; gap: 9px;
  max-width: 240px; padding: 6px 8px 6px 6px; border-radius: 13px;
  background: var(--fill);
  animation: chip-in 0.4s var(--bounce) both;
}
.chip.leaving { animation: chip-out 0.22s ease forwards; }
@keyframes chip-in { from { opacity: 0; transform: scale(0.7) translateY(6px); } }
@keyframes chip-out { to { opacity: 0; transform: scale(0.7); } }
.chip .meta { min-width: 0; }
.chip .meta b { display: block; font-size: 13px; font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chip .meta small { display: block; font-size: 11px; color: var(--label-2); }
.chip .x {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: var(--label-2); background: var(--fill-2);
  transition: background 0.15s, color 0.15s, transform 0.2s var(--spring);
}
.chip .x:hover { background: var(--red); color: #fff; transform: scale(1.1); }
.chip.loading { opacity: 0.6; }

.badge {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  font: 700 9.5px var(--font); letter-spacing: 0.03em; color: #fff;
  background: linear-gradient(160deg, color-mix(in srgb, var(--tint) 78%, #fff), var(--tint));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.starters {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  width: 100%; max-width: 768px;
  max-height: 0; opacity: 0; overflow: hidden; pointer-events: none;
  transition: max-height 0.6s var(--spring), opacity 0.25s, margin 0.6s var(--spring);
}
.main.empty .starters { max-height: 260px; opacity: 1; margin-top: 18px; overflow: visible; pointer-events: auto; }
.starter {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 16px; text-align: left;
  background: var(--panel); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  transition: transform 0.4s var(--spring), box-shadow 0.3s, background 0.2s;
  animation: rise 0.6s var(--spring) both;
}
.starter:nth-child(2) { animation-delay: 0.05s; }
.starter:nth-child(3) { animation-delay: 0.1s; }
.starter:nth-child(4) { animation-delay: 0.15s; }
.starter:hover { transform: translateY(-3px); box-shadow: var(--shadow-1); background: var(--card); }
.starter:active { transform: scale(0.97); }
.starter b { display: block; font-size: 14px; font-weight: 600; }
.starter small { display: block; font-size: 12.5px; color: var(--label-2); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.fineprint { margin: 10px 0 0; font-size: 11.5px; color: var(--label-3); text-align: center; }

/* ── Messages ──────────────────────────────────────────────────────────── */
.msg { margin-bottom: 22px; animation: msg-in 0.5s var(--spring) both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(14px) scale(0.985); } }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.bubble {
  max-width: min(78%, 560px); padding: 9px 15px; border-radius: 20px 20px 6px 20px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--blue) 88%, #fff), var(--blue));
  color: #fff; font-size: 16px; line-height: 1.42; white-space: pre-wrap; overflow-wrap: anywhere;
  box-shadow: 0 6px 18px var(--blue-glow);
  transform-origin: 100% 100%;
  animation: bubble 0.5s var(--bounce) both;
}
@keyframes bubble { from { transform: scale(0.6); opacity: 0; } }
.msg.user .attached { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 78%; }

.msg.bot { display: grid; grid-template-columns: 26px 1fr; gap: 14px; }
.msg.bot > .mark { margin-top: 1px; }
.msg.bot.live > .mark { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(0.86); box-shadow: 0 0 0 7px var(--blue-soft); } }
.body { min-width: 0; }

.prose { font-size: 16px; line-height: 1.6; overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol, .prose pre, .prose table, .prose blockquote { margin: 0 0 12px; }
.prose h1, .prose h2, .prose h3, .prose h4 { margin: 20px 0 8px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.25; }
.prose h1 { font-size: 22px; } .prose h2 { font-size: 19px; } .prose h3, .prose h4 { font-size: 17px; }
.prose p:empty { display: none; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 3px 0; }
.prose li::marker { color: var(--blue); }
.prose a { color: var(--blue); text-decoration: none; }
.prose a:hover { text-decoration: underline; }
.prose code { font: 13.5px var(--mono); padding: 2px 5px; border-radius: 6px; background: var(--fill); }
.prose pre { padding: 13px 15px; border-radius: 14px; background: var(--fill); overflow-x: auto; }
.prose pre code { padding: 0; background: none; }
.prose blockquote { padding-left: 14px; border-left: 3px solid var(--blue); color: var(--label-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; font-size: 14.5px; }
.prose th, .prose td { padding: 7px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.prose th { font-weight: 600; color: var(--label-2); font-size: 13px; }
.prose.streaming > :last-child::after {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-left: 5px; border-radius: 50%;
  background: var(--blue); vertical-align: baseline; animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.25; transform: scale(0.7); } }

.steps { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 12px; }
.step {
  display: flex; align-items: center; gap: 9px; height: 28px;
  color: var(--label-2); font-size: 13.5px;
  animation: rise 0.4s var(--spring) both;
}
.step span:last-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.step .state { width: 18px; height: 18px; display: grid; place-items: center; flex: none; color: var(--label-3); }
.step.running { color: var(--label); }
.step.running .state::before {
  content: ""; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--blue-soft); border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
}
.step.running .state svg { display: none; }
.step.running span:last-child {
  background: linear-gradient(90deg, var(--label-2) 30%, var(--blue) 50%, var(--label-2) 70%) 0 0 / 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.8s linear infinite;
}
.step.done .state { color: var(--blue); animation: tick 0.4s var(--bounce); }
.step.failed .state { color: var(--orange); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -220% 0; } }
@keyframes tick { from { transform: scale(0.3); } }

.typing { display: flex; gap: 5px; height: 26px; align-items: center; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--label-3); animation: hop 1.2s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; } .typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes hop { 30% { transform: translateY(-5px); background: var(--blue); } 60% { transform: none; } }

.files { display: grid; gap: 8px; margin-top: 14px; max-width: 440px; }
.file {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 12px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-1);
  color: inherit; text-decoration: none;
  transition: transform 0.4s var(--spring), box-shadow 0.3s, border-color 0.2s;
  animation: file-in 0.6s var(--bounce) both;
}
.file:nth-child(2) { animation-delay: 0.07s; } .file:nth-child(3) { animation-delay: 0.14s; }
@keyframes file-in { from { opacity: 0; transform: translateY(16px) scale(0.92); } }
.file:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: color-mix(in srgb, var(--blue) 40%, transparent); }
.file:active { transform: scale(0.98); }
.file .badge { width: 40px; height: 40px; border-radius: 11px; font-size: 10.5px; }
.file .meta { flex: 1; min-width: 0; }
.file .meta b { display: block; font-weight: 600; font-size: 14.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.file .meta small { display: block; font-size: 12.5px; color: var(--label-2); }
.file .get {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: var(--blue-soft); color: var(--blue);
  transition: background 0.25s, color 0.25s, transform 0.4s var(--bounce);
}
.file:hover .get { background: var(--blue); color: #fff; transform: scale(1.08); }
.file.got .get svg { animation: drop-in 0.5s var(--bounce); }
@keyframes drop-in { 40% { transform: translateY(7px); opacity: 0; } 41% { transform: translateY(-7px); } }

.note { margin-top: 10px; padding: 10px 13px; border-radius: 13px; font-size: 14px; line-height: 1.4; }
.note.error { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.note.stopped { display: inline-block; padding: 4px 11px; background: var(--fill); color: var(--label-2); font-size: 12.5px; }

/* ── Usage sheet ───────────────────────────────────────────────────────── */
.account[role="button"] { cursor: pointer; transition: background 0.2s, transform 0.3s var(--spring); }
.account[role="button"]:hover { background: var(--fill-2); }
.account[role="button"]:active { transform: scale(0.98); }

.sheet-wrap {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px;
  background: rgba(0, 0, 0, 0.28);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: sheet-fade 0.3s ease both;
}
@keyframes sheet-fade { from { opacity: 0; } }
.sheet {
  width: min(100%, 560px); max-height: min(100%, 760px); display: flex; flex-direction: column;
  border-radius: 28px; background: var(--solid); border: 1px solid var(--line); box-shadow: var(--shadow-2);
  animation: sheet-in 0.5s var(--spring) both;
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(40px) scale(0.96); } }
.sheet-wrap.leaving { opacity: 0; transition: opacity 0.25s ease; }
.sheet-wrap.leaving .sheet { transform: translateY(30px) scale(0.97); transition: transform 0.3s var(--spring); }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 18px 16px 6px 24px; }
.sheet-head h2 { margin: 0; font: 700 24px "SF Pro Display", var(--font); letter-spacing: -0.035em; }
.plan { padding: 3px 10px; border-radius: 10px; background: var(--blue-soft); color: var(--blue); font-size: 12.5px; font-weight: 600; }
.plan:empty { display: none; }
.sheet-head .icon-btn { background: var(--fill); border-radius: 50%; }
.sheet-body { overflow-y: auto; padding: 8px 24px 24px; }
.sheet-body h3 { margin: 22px 0 10px; font-size: 13px; font-weight: 600; color: var(--label-2); }
.sheet-body h3:first-child { margin-top: 8px; }
.sheet-note { margin: 10px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--label-3); }

/* Rings show what is left: a full ring is a full allowance. */
.rings { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.ring-card { display: flex; align-items: center; gap: 16px; padding: 16px; border-radius: 20px; background: var(--fill); }
.ring { position: relative; width: 84px; height: 84px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring .track { stroke: var(--fill-2); }
.ring .left { stroke: var(--tone); transition: stroke-dashoffset 1.1s var(--spring); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font: 700 20px "SF Pro Display", var(--font); letter-spacing: -0.03em; }
.ring-card strong { display: block; font-size: 15px; font-weight: 600; }
.ring-card small { display: block; font-size: 12.5px; color: var(--label-2); line-height: 1.35; }
.ring-card em { display: block; margin-top: 3px; font-style: normal; font-size: 12.5px; font-weight: 600; color: var(--tone); }

.meters { display: grid; gap: 14px; margin-top: 14px; }
.meter-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; font-size: 14px; }
.meter-top strong { font-weight: 600; }
.meter-top small { color: var(--label-2); font-size: 12.5px; }
.meter-top span { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-track { height: 8px; border-radius: 4px; background: var(--fill); overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 4px; background: var(--tone, var(--blue)); transition: width 1s var(--spring); }

.days { display: grid; grid-template-columns: repeat(14, 1fr); gap: 2px; height: 96px; align-items: end; padding-top: 8px; }
.day { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; border-radius: 6px; outline-offset: 0; }
.day i { display: block; width: min(100%, 22px); min-height: 2px; border-radius: 4px 4px 0 0; background: var(--blue); transition: height 0.9s var(--spring), filter 0.15s; }
.day.none i { background: var(--fill-2); }
.day:hover, .day:focus-visible { background: var(--fill); }
.day:hover i, .day:focus-visible i { filter: brightness(1.15); }
.day::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 4px); left: 50%; z-index: 2;
  padding: 5px 9px; border-radius: 9px; white-space: pre; text-align: center;
  background: var(--label); color: var(--bg); font-size: 12px; font-weight: 500; line-height: 1.35;
  transform: translate(-50%, 4px); opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.25s var(--spring);
}
.day:hover::after, .day:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.day:nth-child(-n+2)::after { left: 0; transform: translate(0, 4px); }
.day:nth-child(-n+2):hover::after, .day:nth-child(-n+2):focus-visible::after { transform: none; }
.day:nth-last-child(-n+2)::after { left: auto; right: 0; transform: translate(0, 4px); }
.day:nth-last-child(-n+2):hover::after, .day:nth-last-child(-n+2):focus-visible::after { transform: none; }
.days-axis { display: flex; justify-content: space-between; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--label-3); }
.usage-empty { padding: 22px; border-radius: 16px; background: var(--fill); color: var(--label-2); font-size: 14px; text-align: center; }
.skeleton { height: 116px; border-radius: 20px; background: var(--fill); animation: pulse 1.2s ease-in-out infinite; }

/* ── Password screen ───────────────────────────────────────────────────── */
.lock {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(40px) saturate(180%); backdrop-filter: blur(40px) saturate(180%);
  transition: opacity 0.45s ease;
}
.lock.leaving { opacity: 0; pointer-events: none; }
.lock.leaving .lock-card { transform: scale(1.08); opacity: 0; }
.lock-card {
  width: min(100%, 340px); display: grid; justify-items: center; text-align: center;
  transition: transform 0.5s var(--spring), opacity 0.35s;
}
.lock-card h2 { margin: 18px 0 2px; font: 700 26px "SF Pro Display", var(--font); letter-spacing: -0.04em; }
.lock-card p { margin: 0 0 22px; color: var(--label-2); }
.lock-field {
  display: flex; align-items: center; gap: 6px; width: 100%; padding: 6px 6px 6px 18px;
  border-radius: 26px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-1);
  transition: box-shadow 0.3s var(--spring), border-color 0.25s;
}
.lock-field:focus-within { border-color: color-mix(in srgb, var(--blue) 45%, transparent); box-shadow: 0 0 0 4px var(--blue-soft), var(--shadow-2); }
.lock-field input { flex: 1; min-width: 0; height: 36px; border: 0; outline: 0; background: none; font-size: 16px; }
.lock-field input::placeholder { color: var(--label-3); }
.lock-field .send { flex: none; display: grid; place-items: center; }
.lock.shake .lock-field { animation: shake 0.45s var(--spring); border-color: var(--red); }
@keyframes shake { 20% { transform: translateX(-10px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
#lockError { min-height: 20px; margin-top: 12px; color: var(--red); font-size: 13px; }

/* ── Drop target and toast ─────────────────────────────────────────────── */
.drop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: color-mix(in srgb, var(--blue) 14%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(160%); backdrop-filter: blur(14px) saturate(160%);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.drop.on { opacity: 1; }
.drop-card {
  display: grid; justify-items: center; gap: 4px;
  padding: 34px 54px; border-radius: 30px;
  background: var(--card); border: 2px dashed var(--blue); color: var(--blue);
  box-shadow: var(--shadow-2);
  transform: scale(0.86); transition: transform 0.45s var(--bounce);
}
.drop.on .drop-card { transform: none; }
.drop-card strong { margin-top: 8px; font-size: 20px; letter-spacing: -0.03em; color: var(--label); }
.drop-card small { color: var(--label-2); font-size: 13.5px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 60;
  padding: 10px 18px; border-radius: 20px; max-width: min(90vw, 460px);
  background: color-mix(in srgb, var(--label) 88%, transparent); color: var(--bg);
  font-size: 14px; font-weight: 500; text-align: center;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  transform: translate(-50%, 80px); opacity: 0;
  transition: transform 0.5s var(--bounce), opacity 0.3s;
  pointer-events: none;
}
.toast.on { transform: translate(-50%, 0); opacity: 1; }

/* ── Small screens ─────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  /* The sidebar becomes a drawer over the page, closed by tapping outside it. */
  .sidebar {
    position: absolute; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: 30;
    padding-top: calc(14px + env(safe-area-inset-top)); padding-bottom: calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    box-shadow: var(--shadow-2);
    transition: transform 0.5s var(--spring), opacity 0.3s ease;
  }
  .app.collapsed .sidebar { margin-left: 0; transform: translateX(-105%); }
  .scrim {
    display: block; position: absolute; inset: 0; z-index: 25;
    background: rgba(0, 0, 0, 0.32); transition: opacity 0.35s ease;
  }
  .app.collapsed .scrim { opacity: 0; pointer-events: none; }
  #expand { opacity: 1; pointer-events: auto; transform: none; }
  #topNew { display: grid; color: var(--blue); }
  .new-chat kbd { display: none; }
  .topbar { height: calc(48px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0; }
  .chat-title { font-size: 16px; }
  .stage { padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important; }
  .main.empty .stage { justify-content: flex-end; }
  .main.empty .hero { margin: auto 0; max-height: none; }
  .hero h2 { font-size: 30px; }
  .hero p { font-size: 15px; padding: 0 8px; }
  .mark-lg { width: 50px; height: 50px; }
  .main.empty .starters { order: 1; margin: 0 0 10px; }
  .composer { order: 2; }
  .starter { padding: 10px 12px; }
  .starter small { display: none; }
  .fineprint { display: none; }
  .composer { border-radius: 22px; }
  .search input, .tile input, .lock-field input { font-size: 16px; }
  .msg { margin-bottom: 18px; }
  .msg.bot { grid-template-columns: 22px 1fr; gap: 10px; }
  .msg.bot > .mark { width: 22px; height: 22px; }
  .files { max-width: none; }
  .chat .del { opacity: 1; transform: none; }
  .chat { height: 42px; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
  .drop { display: none; }
  .sheet-wrap { padding: 0; place-items: end stretch; }
  .sheet { width: 100%; max-height: 92dvh; border-radius: 26px 26px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  @keyframes sheet-in { from { transform: translateY(100%); } }
  .sheet-body { padding: 8px 18px 22px; }
  .starters { grid-template-columns: 1fr 1fr; gap: 8px; }
  .drive-inner { padding: 0 14px 30px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .tile-actions { opacity: 1; transform: none; margin-left: -6px; }
  .tile-top { flex-direction: column; gap: 6px; padding-bottom: 8px; }
  .tile-actions button { width: 34px; height: 34px; }
  .crumbs button { font-size: 21px; }
  .thread-inner { padding: 14px 16px 24px; }
  .stage { padding: 0 12px 10px; }
  .pill#web span:last-child { display: none; }
  .pill#web { padding: 0 9px; }
  .bubble, .msg.user .attached { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
