[hidden] { display: none !important; }

.app-shell {
  height: 100vh;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  grid-template-rows: minmax(0, 1fr);
}

#side { overflow: hidden; }
#side .brand, #side .new-chat, #side .side-base { flex-shrink: 0; }
.project-link span:last-child { min-width: 0; overflow-wrap: anywhere; }
.project-link.selected { color: #d6c5ff; background: #24202f; }

.app-shell > main {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
}

.content {
  width: 100%;
  min-height: 0;
  margin: 0 auto;
  overflow-y: auto;
}

.content.thread-view { overflow: hidden; padding-bottom: 14px; }
.top-actions { display: flex; flex: none; align-items: center; gap: 7px; }
#notifications {
  position: relative;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #16171d;
}
#notifications:hover { border-color: #68557e; }
#notification-count {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 17px;
  padding: 1px 4px;
  border-radius: 10px;
  background: #c5a6f0;
  color: #21142e;
  font: 600 11px/15px var(--mono);
  text-align: center;
}
.notification-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.notification-item { width: 100%; min-width: 0; }
.notification-item > span { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.notification-item.unread { box-shadow: inset 3px 0 #c5a6f0; }
.modal-list .notification-item > svg:first-child { color: #c5a6f0; }
.thread {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
}

.thread-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.thread-head > div { min-width: 0; }
.thread-head .thread-title { margin-bottom: 0; }
.chat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #16151c;
}
.chat-row:hover { border-color: #484051; }
.chat-row .list-row { border: 0; background: transparent; }
.chat-row .list-row:hover { background: #1c1a23; }
.chat-delete { min-width: 44px; min-height: 44px; color: #cf9fad; }
.chat-row .chat-delete { margin-inline-end: 6px; }
.chat-delete:hover { color: #ffc3cd; background: #3c252c; }
.danger { background: #ed9cac; color: #2e151e; }
.danger:hover { background: #ffc0cd; }
.delete-actions { flex-wrap: wrap; }
.delete-actions > button { min-height: 44px; }
#delete-chat-title { color: #f1e9ee; overflow-wrap: anywhere; }
#turns {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  scrollbar-color: #665779 #15141d;
  padding-right: 12px;
}
.thread .composer { position: static; min-width: 0; margin-top: 12px; }
.attachment-row { margin: 0 0 20px 43px; }
.attachment-row > .list-row { width: min(100%, 525px); }
.list-row .icon-btn { flex: none; }
.attachment-row .info b { font-size: 14px; }
.model-tools, .model-btn { min-width: 0; }
.attach-btn, .tool-divider, .send { flex-shrink: 0; }
.send.stopping {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding-inline: 9px;
  width: auto;
  font-size: 13px;
  font-weight: 600;
}
.list-row .generation-indicator { color: #c8aaf6; }
.reply-progress { color: #c8aaf6; }
.compose-actions { display: flex; align-items: center; min-width: 0; gap: 3px; }
.format-btn.selected, .access-btn.selected { color: #e0cbff; background: #2b2138; }
.web-sources { font-size: 13px; margin-top: 10px; color: var(--muted); }
.web-sources summary { cursor: pointer; width: fit-content; }
.web-sources ol { padding-left: 22px; margin-top: 6px; }
.web-sources a { color: #d4b0ff; overflow-wrap: anywhere; }
.assistant-proposal { display: grid; gap: 6px; margin: 10px 0; padding: 13px 15px; border: 1px solid #494051; border-radius: 10px; background: #201b28; }
.assistant-proposal b, .assistant-proposal p { overflow-wrap: anywhere; }
.assistant-proposal p { white-space: pre-wrap; font-size: 14px; }
.assistant-proposal .secondary { justify-self: start; margin-top: 4px; }
.proposal-dates { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 10px; }
#proposal-form select { max-width: 100%; padding: 9px 10px; border: 1px solid #494051; border-radius: 7px; background: #15131a; color: #f3eefb; font: inherit; }
#personal-form a { color: #d4b0ff; }
.format-list b, .format-list small { display: block; }
.format-list small { margin-top: 3px; color: var(--muted); }
.reply-tools a { display: flex; gap: 5px; align-items: center; font-size: 12px; text-decoration: none; }
.artifact-preview {
  display: block;
  width: min(100%, 560px);
  max-height: 460px;
  object-fit: contain;
  margin: 12px 0;
  border-radius: 10px;
  background: #111116;
}
.artifact-download {
  display: flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  gap: 10px;
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid #51425f;
  border-radius: 9px;
  background: #201a2a;
  color: #e0cbff;
  text-decoration: none;
}
.artifact-download:hover { border-color: #9e7dc5; }
.artifact-name { min-width: 0; overflow-wrap: anywhere; }
.artifact-name b, .artifact-name small { display: block; }
.artifact-name small { color: var(--muted); margin-top: 2px; }

.auth-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: var(--app-height, 100dvh);
  padding: 18px;
  background: radial-gradient(ellipse at 50% 20%, #21182f, var(--bg) 60%);
}
.auth-card {
  width: min(100%, 420px);
  border: 1px solid #403949;
  border-radius: 15px;
  padding: 26px;
  background: #19181f;
}
.auth-card .brand { height: auto; padding: 0; }
.auth-card h1 { margin: 24px 0 16px; font-size: 24px; font-weight: 550; letter-spacing: -.04em; }
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 18px;
  background: var(--bg);
}
.auth-tabs button { padding: 8px; border-radius: 6px; font-size: 14px; color: var(--muted); }
.auth-tabs button[aria-pressed="true"] { color: #e0cbff; background: #282133; }
.field textarea {
  border: 1px solid #433c4c;
  background: #111116;
  color: #eee8f6;
  border-radius: 7px;
  padding: 10px 11px;
  width: 100%;
  resize: vertical;
}
.field textarea:focus { outline: 1px solid #ad86ce; }
.menu-open #menu { visibility: hidden; }
.mobile-close { display: none; }

@media (max-width: 760px), (pointer: coarse) and (max-height: 520px) {
  #side {
    width: min(19rem, calc(100% - 40px));
    height: var(--app-height, 100dvh);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: max(13px, env(safe-area-inset-left));
    overflow: auto;
    overscroll-behavior-y: contain;
  }
  #side .side-group, #side .side-projects { flex-shrink: 0; }
  #side .side-projects { overflow: visible; }
  #side .new-chat kbd { display: none; }
  #side .nav-link, #side .project-link { min-height: 44px; }
  #side .account { width: 100%; margin: 0; padding-inline: 8px; }
  .top {
    height: calc(55px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  }
  .crumb { min-width: 0; }
  .crumb strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #health { min-height: 44px; }
  #notifications { width: 44px; height: 44px; }
  .notification-actions > button, .notification-item, #push-panel > button { min-height: 44px; }
  .content {
    padding: 16px max(12px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }
  .content.thread-view { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .thread-head { margin-bottom: 12px; }
  .thread .thread-title {
    font-size: 23px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  #turns { scrollbar-gutter: auto; padding-right: 4px; }
  .thread .composer, .composer { padding: 10px; }
  .thread .composer { margin-top: 8px; }
  .composer textarea { min-height: 48px; max-height: clamp(48px, calc(var(--app-height, 100dvh) * .24), 150px); }
  .composer .attach-btn, .composer .model-btn, .send { min-height: 44px; }
  .send, .mobile-menu, .mobile-close, .modal-head .icon-btn, .list-row .icon-btn { min-width: 44px; min-height: 44px; }
  .mobile-close { display: inline-flex; position: absolute; top: calc(19px + env(safe-area-inset-top)); right: 10px; }
  .page-title h1, .page-title p, .list-row small, .format-list button { overflow-wrap: anywhere; }
  .page-title .action, .modal-list button, .auth-tabs button, .auth-card .action, .reply-tools > * { min-height: 44px; }
  .assistant-proposal .secondary { min-height: 44px; }
  .list-row { padding: 10px; gap: 8px; }
  .list-row > .tile-icon { flex: none; }
  .field input, .field textarea, .search input { font-size: 16px; }
  dialog { padding: 16px; max-height: calc(var(--app-height, 100dvh) - 24px); overflow: auto; }
  #toast { bottom: max(12px, env(safe-area-inset-bottom)); }
  .compact-viewport .content.thread-view { padding-top: 7px; }
  .compact-viewport .thread-head { margin-bottom: 5px; }
  .compact-viewport .thread-head .eyebrow { display: none; }
  .compact-viewport .thread .thread-title { font-size: 19px; -webkit-line-clamp: 1; }
}

@media (max-width: 510px) {
  .composer-tools {
    display: grid;
    grid-template-columns: auto auto auto minmax(0, 1fr) auto;
    gap: 3px;
  }
  .compose-actions, .model-tools { display: contents; }
  .composer .tool-divider { display: none; }
  .composer .attach-btn, .composer .model-btn { padding-inline: 5px; }
  .composer .model-btn span { max-width: none; }
  .composer .model-btn > svg:last-child { display: none; }
  .utterance { grid-template-columns: 28px minmax(0, 1fr); gap: 8px; }
  .speaker { width: 27px; height: 27px; }
  .attachment-row { margin-left: 0; }
  .auth-card { padding: 19px; }
}

@media (max-width: 380px) {
  .composer .attach-btn { width: 44px; justify-content: center; }
  .composer .attach-btn span { display: none; }
  .composer .model-btn { font-size: 12px; }
  .composer .format-btn > svg:first-child, .composer .access-btn > svg:first-child { display: none; }
}

@media (orientation: landscape) and (pointer: coarse) and (max-height: 520px) {
  #side .brand { height: 60px; }
  .mobile-close { top: calc(8px + env(safe-area-inset-top)); }
  .content.thread-view { padding-top: 8px; }
  .thread-head { margin-bottom: 6px; }
  .thread .thread-title { font-size: 19px; }
}

.mib-head { align-items: center; gap: 14px; }
.mib-head .eyebrow { color: #d4acff; }
.mib-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.mib-actions button { display: inline-flex; align-items: center; gap: 6px; }
.mib-intro { align-content: center; max-width: 32rem; min-height: 55%; margin: 0 auto; padding: 24px 10px; text-align: center; }
.mib-intro h2 { margin: 0 0 10px; font-size: clamp(1.5rem, 5vw, 2.4rem); color: #f3eff9; }
.mib-intro p { margin: 0; color: #b7afc5; line-height: 1.55; }
#mib-mic[aria-pressed="true"] { background: #372240; color: #f2c6ff; }
.mib-voice-status { margin: 8px 0 0; }
.mib-audio { display: block; max-width: 100%; height: 36px; margin: 8px 0 0; }
.mib-events { margin: 12px 0 0; padding: 0; list-style: none; }
.mib-events li { display: flex; gap: 12px; align-items: center; justify-content: space-between; border-bottom: 1px solid #ffffff16; padding: 10px 0; }
.mib-events li > div { min-width: 0; overflow-wrap: anywhere; }
.mib-events small { display: block; color: #b7afc5; margin-top: 4px; }
.mib-check { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.mib-check input { width: auto; accent-color: #c091f6; }

@media (max-width: 510px) {
  .composer:has(#mib-mic) .composer-tools { grid-template-columns: auto auto auto auto minmax(0, 1fr) auto; }
  .composer:has(#mib-mic) .attach-btn span { display: none; }
  .composer:has(#mib-mic) .attach-btn { justify-content: center; width: 36px; }
  .mib-head .eyebrow { display: none; }
  .mib-actions { flex-wrap: nowrap; }
  .mib-actions .secondary { min-height: 44px; padding-inline: 7px; font-size: 12px; }
}

@media (max-width: 430px) {
  .composer:has(#mib-mic) #model-select { justify-self: end; justify-content: center; width: 36px; }
  .composer:has(#mib-mic) #model-name { display: none; }
}

.mib-task-list { margin: 0; padding: 0; list-style: none; }
.mib-task { padding: 12px 0; border-bottom: 1px solid #ffffff16; overflow-wrap: anywhere; }
.mib-task p { color: #b7afc5; font-size: 13px; margin: 5px 0; }
.mib-task .dialog-actions { flex-wrap: wrap; margin-top: 8px; }
@media (max-width: 375px) {
  .mib-actions { flex-wrap: wrap; }
}
