:root {
  --bg: #f2eee8;
  --bg-deep: #e8e1d8;
  --paper: rgba(255, 253, 249, .78);
  --paper-solid: #fffdf9;
  --paper-soft: rgba(255, 255, 255, .52);
  --ink: #26231f;
  --text: #26231f;
  --muted: #766f67;
  --muted-2: #9a9288;
  --accent: #d56f4b;
  --accent-deep: #ac4f31;
  --accent-soft: rgba(213, 111, 75, .12);
  --accent-line: rgba(213, 111, 75, .27);
  --blue: #4779a7;
  --ok: #397b5a;
  --warn: #c27832;
  --bad: #bd4a43;
  --glass: rgba(255, 253, 249, .74);
  --glass-strong: rgba(255, 254, 251, .91);
  --glass-line: rgba(81, 69, 57, .13);
  --shadow-sm: 0 1px 2px rgba(57, 47, 37, .05), 0 8px 24px rgba(57, 47, 37, .06);
  --shadow-lg: 0 28px 80px rgba(57, 47, 37, .18), 0 2px 8px rgba(57, 47, 37, .08);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
  isolation: isolate;
}

button,
select,
textarea,
input { font: inherit; }

button,
a,
select { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(213, 111, 75, .22);
  outline-offset: 2px;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -3;
  overflow: hidden;
  background:
    radial-gradient(circle at 8% 12%, rgba(237, 180, 133, .28), transparent 31%),
    radial-gradient(circle at 86% 8%, rgba(142, 171, 193, .24), transparent 30%),
    radial-gradient(circle at 75% 92%, rgba(197, 150, 180, .18), transparent 34%),
    linear-gradient(145deg, #f7f3ed 0%, #f0ebe4 48%, #ebe5dc 100%);
}

.blob {
  position: absolute;
  border-radius: 999px;
  filter: blur(4px);
  opacity: .72;
  animation: workspaceFloat 24s ease-in-out infinite alternate;
}

.blob.a {
  width: 34vw;
  height: 34vw;
  left: -13vw;
  top: -16vw;
  background: radial-gradient(circle at 60% 60%, rgba(225, 133, 93, .34), rgba(225, 133, 93, 0) 69%);
}

.blob.b {
  width: 38vw;
  height: 38vw;
  right: -15vw;
  top: -18vw;
  background: radial-gradient(circle at 40% 62%, rgba(96, 142, 179, .25), rgba(96, 142, 179, 0) 68%);
  animation-delay: -7s;
}

.blob.c {
  width: 42vw;
  height: 42vw;
  right: 16vw;
  bottom: -31vw;
  background: radial-gradient(circle at 50% 35%, rgba(179, 116, 151, .2), rgba(179, 116, 151, 0) 70%);
  animation-delay: -13s;
}

@keyframes workspaceFloat {
  from { transform: translate3d(-2%, -2%, 0) scale(.96); }
  to { transform: translate3d(3%, 2%, 0) scale(1.05); }
}

.grain {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: .055;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.88' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.glass {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, .72);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .82);
  backdrop-filter: blur(28px) saturate(135%);
  -webkit-backdrop-filter: blur(28px) saturate(135%);
}

.glass::before,
.glass::after { display: none; }

.glass > * { position: relative; z-index: auto; }

/* Fast, quiet loader */
#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: #f4f0ea;
  transition: opacity .26s ease, visibility .26s ease;
}

#loader.out {
  opacity: 0;
  visibility: hidden;
  transform: none;
  pointer-events: none;
}

.loader-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(145deg, #df805c, #bd5635);
  box-shadow: 0 14px 30px rgba(177, 77, 45, .22), inset 0 1px 0 rgba(255, 255, 255, .34);
}

.loader-mark::before {
  content: "C";
  font: 700 23px/1 Georgia, serif;
}

.loader-mark span {
  position: absolute;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(213, 111, 75, .22);
  border-radius: 19px;
  animation: loaderPulse 1.3s ease-in-out infinite;
}

.loader-text {
  position: static;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  text-shadow: none;
}

.loader-track {
  width: 150px;
  height: 3px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(80, 68, 56, .09);
}

.loader-track i {
  display: block;
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  animation: loaderSlide 1s ease-in-out infinite;
}

@keyframes loaderPulse {
  50% { transform: scale(1.08); opacity: .35; }
}

@keyframes loaderSlide {
  from { transform: translateX(-110%); }
  to { transform: translateX(335%); }
}

/* Shared brand */
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-lockup > span:last-child {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-lockup b {
  color: var(--ink);
  font: 700 18px/1.05 Georgia, "Times New Roman", serif;
  letter-spacing: -.02em;
}

.brand-lockup small {
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, #dc7956, #b94f30);
  box-shadow: 0 9px 22px rgba(169, 74, 45, .2), inset 0 1px 0 rgba(255, 255, 255, .34);
  font: 700 18px/1 Georgia, serif;
}

/* Login */
#login {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 54px);
  overflow: auto;
}

.login-card {
  width: min(100%, 1000px);
  max-width: 1000px;
  min-height: min(680px, calc(100dvh - 72px));
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr);
  overflow: hidden;
  padding: 0;
  border-radius: 32px;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, .9);
  animation: loginIn .5s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes loginIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
}

.login-story {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100%;
  padding: 42px;
  overflow: hidden;
  color: #fffaf4;
  background:
    radial-gradient(circle at 88% 10%, rgba(255, 203, 154, .26), transparent 34%),
    radial-gradient(circle at 12% 92%, rgba(121, 157, 184, .23), transparent 37%),
    linear-gradient(155deg, #312d29 0%, #3c332d 53%, #5b3a2d 100%);
}

.login-story::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 31px 0 0 31px;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14);
}

.login-story .brand-lockup,
.login-story-copy,
.login-orbit { position: relative; z-index: 1; }

.login-story .brand-lockup b { color: #fffaf4; }
.login-story .brand-lockup small { color: rgba(255, 250, 244, .58); }

.login-orbit {
  align-self: center;
  width: min(31vw, 280px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 50%;
  box-shadow: inset 0 0 70px rgba(255, 189, 140, .05);
}

.login-orbit::before,
.login-orbit::after {
  content: "";
  position: absolute;
  inset: 17%;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 50%;
}

.login-orbit::after { inset: 34%; }

.orbit-core {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 24px;
  color: #3b2a22;
  background: linear-gradient(145deg, #fff0dc, #e6ab7c);
  box-shadow: 0 18px 36px rgba(11, 8, 6, .28), inset 0 1px 0 rgba(255, 255, 255, .72);
  font: 700 30px/1 Georgia, serif;
}

.login-orbit i {
  position: absolute;
  min-width: 58px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  color: rgba(255, 250, 244, .83);
  background: rgba(255, 255, 255, .07);
  box-shadow: 0 10px 22px rgba(0, 0, 0, .12);
  backdrop-filter: blur(12px);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  text-align: center;
  letter-spacing: .03em;
}

.orbit-one { left: -8px; top: 26%; }
.orbit-two { right: -12px; top: 38%; }
.orbit-three { left: 27%; bottom: -9px; }

.eyebrow,
.login-kicker,
.title-eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.login-story-copy .eyebrow { color: #e9ac82; }

.login-story-copy h2 {
  max-width: 460px;
  margin: 13px 0 12px;
  color: #fffaf4;
  font: 500 clamp(28px, 3.2vw, 43px)/1.08 Georgia, "Times New Roman", serif;
  letter-spacing: -.035em;
}

.login-story-copy p {
  max-width: 430px;
  margin: 0;
  color: rgba(255, 250, 244, .64);
  font-size: 14px;
  line-height: 1.65;
}

.login-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(36px, 5vw, 66px);
  background: rgba(255, 253, 249, .64);
}

.login-kicker { color: var(--accent-deep); }

.login-content h1,
.login-card h1 {
  margin: 12px 0 14px;
  color: var(--ink);
  font: 500 clamp(34px, 4vw, 48px)/1.02 Georgia, "Times New Roman", serif;
  letter-spacing: -.04em;
}

.login-content > p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.login-points {
  display: grid;
  gap: 12px;
  margin: 30px 0;
}

.login-points span {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #575049;
  font-size: 13px;
  font-weight: 600;
}

.login-points i {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  color: var(--accent-deep);
  background: var(--accent-soft);
  font-size: 11px;
  font-style: normal;
}

.tg-btn {
  width: 100%;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 0 17px;
  border: 1px solid #a7472c;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(180deg, #d87350, #c35b39);
  box-shadow: 0 10px 24px rgba(173, 73, 43, .2), inset 0 1px 0 rgba(255, 255, 255, .24);
  text-decoration: none;
  font-size: 14px;
  font-weight: 750;
  transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}

.tg-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.03);
  box-shadow: 0 16px 30px rgba(173, 73, 43, .25), inset 0 1px 0 rgba(255, 255, 255, .28);
}

.tg-btn:active { transform: translateY(0); }

.tg-btn svg {
  width: 21px;
  height: 21px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.55;
}

.tg-btn span { flex: 1; }
.tg-btn b { font-size: 18px; font-weight: 500; }

.login-status {
  min-height: 24px;
  margin-top: 15px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.login-status .spinner {
  width: 15px;
  height: 15px;
  margin-right: 9px;
  border: 2px solid rgba(213, 111, 75, .22);
  border-top-color: var(--accent);
}

.login-privacy {
  margin-top: 10px !important;
  color: var(--muted-2) !important;
  font-size: 11px !important;
}

/* Workspace shell */
#app {
  width: 100%;
  height: 100dvh;
  max-width: none;
  display: none;
  align-items: stretch;
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

.sidebar,
.main {
  min-height: 0;
  border-radius: var(--radius-lg);
}

.sidebar {
  width: 296px;
  min-width: 296px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: panelIn .42s cubic-bezier(.2, .8, .2, 1) both;
  transition: width .32s cubic-bezier(.2, .8, .2, 1), min-width .32s cubic-bezier(.2, .8, .2, 1), opacity .24s ease, transform .32s ease;
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(8px); }
}

.sidebar-head {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 17px 11px;
}

.sidebar-brand { min-width: 0; }

#sbCloseBtn,
#sbOpenBtn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}

#sbCloseBtn:hover,
#sbOpenBtn:hover {
  color: var(--ink);
  border-color: var(--glass-line);
  background: rgba(255, 255, 255, .58);
}

#sbCloseBtn svg,
#sbOpenBtn svg,
#newChatBtn svg,
.chat-search svg,
.side-nav svg,
#send svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#sbCloseBtn svg,
#sbOpenBtn svg { width: 18px; height: 18px; }

.sidebar-tools {
  display: grid;
  gap: 9px;
  padding: 7px 13px 13px;
}

#newChatBtn {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid var(--accent-line);
  border-radius: 13px;
  color: var(--accent-deep);
  background: linear-gradient(180deg, rgba(255, 249, 244, .9), rgba(251, 238, 228, .88));
  box-shadow: 0 5px 14px rgba(166, 80, 49, .08), inset 0 1px 0 rgba(255, 255, 255, .92);
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

#newChatBtn:hover {
  transform: translateY(-1px);
  background: #fff9f4;
  box-shadow: 0 8px 20px rgba(166, 80, 49, .12), inset 0 1px 0 #fff;
}

#newChatBtn svg { width: 18px; height: 18px; }

kbd {
  min-width: 32px;
  margin-left: auto;
  padding: 3px 6px;
  border: 1px solid rgba(83, 69, 55, .11);
  border-radius: 6px;
  color: var(--muted-2);
  background: rgba(255, 255, 255, .56);
  box-shadow: 0 1px 0 rgba(83, 69, 55, .06);
  font: 600 9px/1.2 ui-sans-serif, sans-serif;
  text-align: center;
}

.chat-search {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 11px;
  border: 1px solid rgba(81, 69, 57, .1);
  border-radius: 12px;
  background: rgba(255, 255, 255, .42);
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.chat-search:focus-within {
  border-color: var(--accent-line);
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 0 0 3px rgba(213, 111, 75, .08);
}

.chat-search svg { width: 16px; height: 16px; color: var(--muted-2); }

.chat-search input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 12px;
}

.chat-search input::placeholder { color: var(--muted-2); }
.chat-search input::-webkit-search-cancel-button { opacity: .45; }

.sidebar-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 19px 8px;
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.sidebar-section-title span:last-child {
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 99px;
  background: rgba(81, 69, 57, .06);
  text-align: center;
}

.chat-list {
  min-height: 0;
  flex: 1;
  padding: 0 9px 12px;
  overflow-x: hidden;
  overflow-y: auto;
}

.chat-item {
  position: relative;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0;
  padding: 9px 10px 9px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #5f5851;
  background: transparent;
  cursor: pointer;
  animation: chatItemIn .28s ease both;
  transition: color .18s ease, background .18s ease, border-color .18s ease, transform .18s ease;
}

@keyframes chatItemIn {
  from { opacity: 0; transform: translateY(4px); }
}

.chat-item::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: rgba(81, 69, 57, .2);
  transition: background .18s ease, box-shadow .18s ease;
}

.chat-item:hover {
  color: var(--ink);
  border-color: rgba(81, 69, 57, .08);
  background: rgba(255, 255, 255, .46);
  transform: translateX(1px);
}

.chat-item.active {
  color: var(--ink);
  border-color: rgba(213, 111, 75, .17);
  background: linear-gradient(90deg, rgba(213, 111, 75, .12), rgba(255, 255, 255, .48));
  box-shadow: inset 3px 0 0 var(--accent);
}

.chat-item.active::before {
  position: static;
  width: 6px;
  height: 6px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(213, 111, 75, .12);
}

.chat-item .t {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item .del {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 8px;
  opacity: 0;
  color: var(--muted-2);
  font-size: 12px;
  filter: grayscale(1);
  transition: opacity .18s ease, color .18s ease, background .18s ease;
}

.chat-item:hover .del,
.chat-item:focus-within .del { opacity: 1; }

.chat-item .del:hover {
  color: var(--bad);
  background: rgba(189, 74, 67, .09);
  transform: none;
}

.chat-item.search-hidden { display: none; }

.chat-search-empty {
  padding: 18px 12px;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.sidebar-foot {
  padding: 11px 11px 12px;
  border-top: 1px solid rgba(81, 69, 57, .09);
  background: rgba(255, 253, 249, .3);
}

.side-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.side-nav button {
  min-width: 0;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
  text-align: left;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}

.side-nav button:hover {
  color: var(--ink);
  border-color: rgba(81, 69, 57, .08);
  background: rgba(255, 255, 255, .48);
}

.side-nav button svg { width: 16px; height: 16px; flex: none; }

.side-nav #logout {
  grid-column: 1 / -1;
  justify-content: center;
  margin-top: 2px;
  color: #9b6960;
}

.side-nav #logout:hover {
  color: var(--bad);
  background: rgba(189, 74, 67, .07);
}

.side-user {
  margin: 9px 3px 0;
  padding: 9px 11px 0;
  border-top: 1px solid rgba(81, 69, 57, .07);
  color: var(--muted-2);
  font-size: 10.5px;
  line-height: 1.35;
  text-align: center;
}

body.sb-collapsed .sidebar {
  width: 0;
  min-width: 0;
  opacity: 0;
  transform: translateX(-18px);
  pointer-events: none;
  overflow: hidden;
}

#sbOpenBtn { display: none; }
body.sb-collapsed #sbOpenBtn { display: grid; }

/* Main chat */
.main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: panelIn .45s .04s cubic-bezier(.2, .8, .2, 1) both;
}

.workspace-header {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(81, 69, 57, .09);
  background: rgba(255, 253, 249, .32);
}

.header-leading,
.title-line,
.header-controls,
.model-control,
.effort-control {
  display: flex;
  align-items: center;
}

.header-leading { min-width: 0; gap: 11px; }
.title-stack { min-width: 0; }
.title-eyebrow { margin-bottom: 4px; color: var(--muted-2); font-size: 8.5px; }
.title-line { min-width: 0; gap: 9px; }

.workspace-header h1 {
  min-width: 0;
  max-width: min(34vw, 440px);
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font: 600 18px/1.18 Georgia, "Times New Roman", serif;
  letter-spacing: -.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  color: var(--accent-deep);
  background: var(--accent-soft);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.promo-tag {
  max-width: 210px;
  overflow: hidden;
  color: #7f5b1f;
  border-color: rgba(194, 120, 50, .24);
  background: rgba(229, 179, 93, .14);
  text-overflow: ellipsis;
}

.header-controls { min-width: 0; justify-content: flex-end; gap: 9px; }

.model-control,
.effort-control {
  min-height: 44px;
  gap: 9px;
  padding: 5px 7px 5px 11px;
  border: 1px solid rgba(81, 69, 57, .1);
  border-radius: 12px;
  background: rgba(255, 255, 255, .48);
}

.model-control > span,
.effort-control > span {
  color: var(--muted-2);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

select,
.model-control select,
.api-body select {
  min-height: 32px;
  padding: 0 31px 0 10px;
  border: 1px solid rgba(81, 69, 57, .1);
  border-radius: 9px;
  color: var(--ink);
  background-color: rgba(255, 253, 249, .82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 650;
}

.model-control select { width: clamp(145px, 15vw, 205px); }

.model-usage {
  --usage-color: var(--ok);
  position: relative;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid rgba(81, 69, 57, .1);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, .46);
  cursor: default;
  font-size: 9px;
  font-weight: 750;
}

.model-usage[data-level="warning"] { --usage-color: var(--warn); }
.model-usage[data-level="danger"] { --usage-color: var(--bad); }

.model-usage > i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--usage-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--usage-color) 13%, transparent);
}

.model-usage > b {
  color: var(--usage-color);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.usage-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 9px);
  z-index: 20;
  width: 230px;
  padding: 13px;
  border: 1px solid rgba(81, 69, 57, .12);
  border-radius: 14px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px) scale(.985);
  color: var(--ink);
  background: rgba(255, 253, 249, .97);
  box-shadow: 0 18px 42px rgba(54, 42, 31, .16), inset 0 1px 0 #fff;
  pointer-events: none;
  transition: opacity .17s ease, visibility .17s ease, transform .17s ease;
}

.model-usage:is(:hover, :focus-visible, :focus-within) .usage-popover {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.usage-popover-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
  padding-bottom: 9px;
  border-bottom: 1px solid rgba(81, 69, 57, .08);
}

.usage-popover-head b { color: var(--ink); font-size: 11px; }
.usage-popover-head span { color: var(--muted-2); font-size: 8px; }

.usage-popover-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 1px;
  color: var(--muted);
  font-size: 10px;
}

.usage-popover-row b { color: var(--usage-color); font-size: 11px; font-variant-numeric: tabular-nums; }

.model-score-caption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  padding: 10px 1px 5px;
  border-top: 1px solid rgba(81, 69, 57, .08);
}

.model-score-caption b { color: var(--ink); font-size: 10px; }
.model-score-caption span { color: var(--muted-2); font-size: 8px; }

.model-score-row {
  display: grid;
  grid-template-columns: 60px 1fr 30px;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: var(--muted);
  font-size: 10px;
}

.model-score-row > b { color: var(--ink); text-align: right; font-size: 10px; font-variant-numeric: tabular-nums; }
.model-score-pips { display: flex; align-items: center; gap: 4px; }
.model-score-pips i {
  width: 13px;
  height: 6px;
  border-radius: 999px;
  background: rgba(81, 69, 57, .12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6);
}
.model-score-pips i.on {
  background: linear-gradient(90deg, var(--accent), #e7ae78);
  box-shadow: 0 2px 7px color-mix(in srgb, var(--accent) 22%, transparent);
}
.profile-model-score {
  margin-top: 13px;
  padding: 10px 12px;
  border: 1px solid rgba(81, 69, 57, .1);
  border-radius: 14px;
  background: rgba(255,255,255,.42);
}

select:hover,
select:focus {
  border-color: var(--accent-line);
  background-color: #fffdf9;
}

select option { color: var(--ink); background: #fffdf9; }

.effort-control:has(.eff-slot[style*="display: none"]),
.effort-control:has(.eff-slot:empty) { display: none; }

.eff-slot { min-width: 92px; }
.eff-wrap.compact { width: 98px; }
.eff { height: 24px; }
.eff input { cursor: pointer; }
.eff-track { height: 4px; background: rgba(81, 69, 57, .12); }
.eff-fill { background: linear-gradient(90deg, var(--accent), #9b6da5); }
.eff-thumb { width: 13px; height: 13px; border: 2px solid #fff; background: var(--accent); box-shadow: 0 2px 6px rgba(76, 56, 43, .23); }
.eff-read { min-width: 32px; color: var(--muted); font-size: 9px; }

#fastToggle {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px 0 12px;
  border: 1px solid rgba(81, 69, 57, .1);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, .46);
  cursor: pointer;
  font-size: 10px;
  font-weight: 750;
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}

#fastToggle i {
  position: relative;
  width: 28px;
  height: 16px;
  border-radius: 999px;
  background: rgba(81, 69, 57, .16);
  transition: background .2s ease;
}

#fastToggle i::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(61, 48, 36, .2);
  transition: transform .2s ease;
}

#fastToggle.on {
  color: var(--accent-deep);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

#fastToggle.on i { background: var(--accent); }
#fastToggle.on i::after { transform: translateX(12px); }

.connection-strip {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 4px 16px;
  border-bottom: 1px solid rgba(81, 69, 57, .06);
  color: var(--muted-2);
  background: rgba(255, 253, 249, .18);
  font-size: 9.5px;
  font-weight: 650;
}

.connection-strip i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(57, 123, 90, .1);
}

.connection-strip.offline i { background: var(--bad); box-shadow: 0 0 0 3px rgba(189, 74, 67, .1); }

#messages {
  position: relative;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 32px clamp(22px, 5vw, 76px) 22px;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

.msg {
  position: relative;
  width: fit-content;
  max-width: min(78%, 780px);
  padding: 14px 16px;
  border: 1px solid rgba(81, 69, 57, .09);
  border-radius: 17px;
  color: var(--ink);
  background: rgba(255, 253, 249, .78);
  box-shadow: 0 7px 22px rgba(66, 53, 41, .055), inset 0 1px 0 rgba(255, 255, 255, .86);
  font-size: inherit;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
  animation: messageIn .3s cubic-bezier(.2, .75, .2, 1) both;
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(6px); }
}

.msg.assistant {
  width: min(78%, 780px);
  align-self: flex-start;
  margin-right: auto;
  border-bottom-left-radius: 5px;
  color: var(--ink);
  background: rgba(255, 253, 249, .82);
}

.msg.assistant:not(.typing)::before {
  content: "Clop";
  position: absolute;
  left: 3px;
  top: -16px;
  color: var(--accent-deep);
  font: 700 9px/1 ui-sans-serif, sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.msg.user {
  align-self: flex-end;
  margin-left: auto;
  border-color: #b14f31;
  border-bottom-right-radius: 5px;
  color: #fffaf6;
  background: linear-gradient(145deg, #d77350, #bd5637);
  box-shadow: 0 9px 23px rgba(163, 69, 41, .16), inset 0 1px 0 rgba(255, 255, 255, .2);
}

.msg.user.unsent {
  border-color: rgba(189, 74, 67, .25);
  background: rgba(189, 74, 67, .07);
  box-shadow: none;
}

.unsent-note {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(189, 74, 67, .16);
  color: var(--bad);
  font-size: 8.5px;
  font-weight: 700;
}

.unsent-note button {
  min-height: 25px;
  padding: 0 8px;
  border: 1px solid rgba(189, 74, 67, .2);
  border-radius: 7px;
  color: var(--bad);
  background: rgba(255, 255, 255, .52);
  cursor: pointer;
  font-size: 8.5px;
  font-weight: 750;
}

.msg-body { min-width: 0; }
.msg-body > :first-child { margin-top: 0; }
.msg-body > :last-child { margin-bottom: 0; }

.msg-body p {
  margin: .42em 0;
  white-space: pre-wrap;
}

.msg-body h2,
.msg-body h3,
.msg-body h4 {
  margin: 1.05em 0 .42em;
  color: inherit;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.25;
}

.msg-body h2 { font-size: 1.28em; }
.msg-body h3 { font-size: 1.15em; }
.msg-body h4 { font-size: 1.06em; }

.msg-body ul,
.msg-body ol {
  margin: .55em 0 .65em;
  padding-left: 1.45em;
}

.msg-body li { margin: .22em 0; padding-left: .12em; }

.msg-body strong { font-weight: 760; }

.msg-body a {
  color: var(--accent-deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.msg.user .msg-body a { color: #fff4e9; }

.msg-body code:not(.code-block code) {
  padding: .12em .38em;
  border: 1px solid rgba(81, 69, 57, .09);
  border-radius: 6px;
  background: rgba(81, 69, 57, .065);
  font: .88em/1.45 "Cascadia Code", Consolas, monospace;
}

.msg.user .msg-body code:not(.code-block code) {
  border-color: rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .12);
}

.msg-body blockquote {
  margin: .65em 0;
  padding: .25em 0 .25em .9em;
  border-left: 3px solid var(--accent-line);
  color: var(--muted);
}

.rich-gap { display: block; height: .45em; }

.code-block {
  margin: .75em 0;
  overflow: hidden;
  border: 1px solid rgba(81, 69, 57, .15);
  border-radius: 12px;
  background: #2b2927;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}

.code-head {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 8px 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  color: #a9a29b;
  background: rgba(255, 255, 255, .035);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.code-head button {
  min-height: 25px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 7px;
  color: #d8d2cb;
  background: rgba(255, 255, 255, .05);
  cursor: pointer;
  font-size: 9px;
  text-transform: none;
  letter-spacing: 0;
}

.code-head button:hover { background: rgba(255, 255, 255, .1); }

.code-block pre {
  max-width: 100%;
  margin: 0;
  padding: 14px;
  overflow: auto;
  color: #ece7e1;
  background: transparent;
  tab-size: 2;
}

.code-block code {
  font: 11.5px/1.6 "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  white-space: pre;
}

.msg.error {
  color: #8e3732;
  border-color: rgba(189, 74, 67, .2);
  background: rgba(255, 239, 236, .85);
}

.msg.typing {
  min-width: 190px;
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
}

.thinking-dots { display: inline-flex; align-items: center; gap: 4px; }

.msg.typing .thinking-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.thinking-label { color: var(--muted); font-size: 10.5px; font-weight: 650; }
.thinking-time { margin-left: auto; color: var(--muted-2); font-size: 9.5px; font-variant-numeric: tabular-nums; }

.message-meta {
  margin-top: 11px;
  padding-top: 8px;
  border-top: 1px solid rgba(81, 69, 57, .08);
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 600;
}

.artifact-list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.artifact-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 36px minmax(70px, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid rgba(81, 69, 57, .10);
  border-radius: 12px;
  background: rgba(255, 253, 249, .58);
}

.artifact-type {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--accent-deep);
  background: var(--accent-soft);
  font-size: 8px;
  font-weight: 850;
  letter-spacing: .04em;
}

.artifact-name { min-width: 0; display: grid; gap: 2px; }
.artifact-name b { overflow: hidden; color: var(--ink); font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.artifact-name small,
.artifact-size { color: var(--muted-2); font-size: 8.5px; }
.artifact-size { font-variant-numeric: tabular-nums; white-space: nowrap; }

.artifact-download {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 8px;
  color: var(--accent-deep);
  background: var(--accent-soft);
  text-decoration: none;
  font-size: 8.5px;
  font-weight: 750;
}

.artifact-download:hover { background: rgba(213, 111, 75, .19); }

.zip-link,
.response-file-link {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--accent-line);
  border-radius: 11px;
  color: var(--accent-deep);
  background: var(--accent-soft);
  text-decoration: none;
  font-size: 11.5px;
  font-weight: 750;
}

.zip-link:hover,
.response-file-link:hover { background: rgba(213, 111, 75, .17); }

.empty-hint {
  width: min(100%, 620px);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: center;
  margin: auto;
  padding: 44px 22px;
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
}

.empty-hint .empty-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border: 1px solid var(--accent-line);
  border-radius: 20px;
  color: var(--accent-deep);
  background: linear-gradient(145deg, rgba(255, 255, 255, .8), var(--accent-soft));
  box-shadow: var(--shadow-sm);
  font: 700 24px/1 Georgia, serif;
}

.empty-hint b {
  margin-bottom: 7px;
  color: var(--ink);
  font: 600 22px/1.15 Georgia, serif;
}

.empty-hint span { max-width: 430px; font-size: 12.5px; }

.empty-prompts {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 23px;
}

.empty-prompts button {
  min-height: 58px;
  padding: 10px 11px;
  border: 1px solid rgba(81, 69, 57, .1);
  border-radius: 12px;
  color: #5f5851;
  background: rgba(255, 255, 255, .46);
  cursor: pointer;
  font-size: 10.5px;
  line-height: 1.35;
  text-align: left;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.empty-prompts button:hover {
  transform: translateY(-2px);
  border-color: var(--accent-line);
  background: rgba(255, 255, 255, .76);
}

/* Composer */
.composer {
  flex: none;
  padding: 9px clamp(13px, 3vw, 38px) 17px;
  border: 0;
  background: linear-gradient(180deg, rgba(242, 238, 232, 0), rgba(248, 244, 238, .7) 34%);
}

.composer-inner {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 9px 10px 7px;
  border: 1px solid rgba(81, 69, 57, .14);
  border-radius: 19px;
  background: rgba(255, 253, 249, .9);
  box-shadow: 0 16px 42px rgba(64, 50, 38, .1), inset 0 1px 0 rgba(255, 255, 255, .96);
  backdrop-filter: blur(20px) saturate(135%);
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.composer-inner:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 18px 48px rgba(64, 50, 38, .13), 0 0 0 3px rgba(213, 111, 75, .07);
  transform: translateY(-1px);
}

.composer-inner.drag-over {
  border-color: var(--accent);
  background: #fff8f2;
  box-shadow: 0 18px 48px rgba(166, 80, 49, .15), 0 0 0 4px rgba(213, 111, 75, .1);
}

.composer-inner .row { display: flex; align-items: flex-end; gap: 8px; }

.queue-strip {
  min-width: 0;
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  margin: 0 3px 7px;
  padding: 7px 8px;
  border: 1px solid rgba(71, 121, 167, .18);
  border-radius: 11px;
  background: rgba(71, 121, 167, .07);
}

.queue-strip[hidden] { display: none; }

.queue-mark {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--blue);
  background: rgba(71, 121, 167, .1);
  font-size: 14px;
  font-weight: 800;
}

.queue-copy { min-width: 0; display: grid; gap: 1px; }
.queue-copy b { color: var(--ink); font-size: 9.5px; }
.queue-copy small { overflow: hidden; color: var(--muted); font-size: 8.5px; text-overflow: ellipsis; white-space: nowrap; }

#queueClear {
  min-height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  color: var(--blue);
  background: transparent;
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
}

#queueClear:hover { background: rgba(71, 121, 167, .09); }

#attachBtn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: none;
  margin: 1px 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}

#attachBtn:hover {
  color: var(--accent-deep);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

#attachBtn svg { width: 20px; height: 20px; }

#input {
  min-height: 42px;
  max-height: 170px;
  flex: 1;
  padding: 10px 6px 8px;
  border: 0;
  outline: 0;
  resize: none;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
  font-size: 13.5px;
  line-height: 1.48;
}

#input::placeholder { color: var(--muted-2); }

#send {
  min-width: 112px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: none;
  padding: 0 15px;
  border: 1px solid #ad492c;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(180deg, #d97350, #bf5737);
  box-shadow: 0 7px 16px rgba(168, 70, 42, .17), inset 0 1px 0 rgba(255, 255, 255, .22);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  transition: transform .18s ease, filter .18s ease, box-shadow .18s ease;
}

#send svg { width: 16px; height: 16px; }

#send:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow: 0 10px 20px rgba(168, 70, 42, .22), inset 0 1px 0 rgba(255, 255, 255, .25);
}

#send:active:not(:disabled) { transform: translateY(0); }
#send:disabled { opacity: .58; cursor: wait; }

#send.queue-mode {
  border-color: #375f82;
  background: linear-gradient(180deg, #5887b1, #3f6d94);
  box-shadow: 0 7px 16px rgba(47, 91, 128, .16), inset 0 1px 0 rgba(255, 255, 255, .2);
}

#send.queue-mode svg { display: none; }
#send.queue-mode::after { content: '+'; font-size: 18px; font-weight: 500; line-height: 1; }

.composer-foot {
  min-height: 19px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 7px 0 49px;
  color: var(--muted-2);
  font-size: 8.5px;
}

#draftCount { font-variant-numeric: tabular-nums; }

.file-chip {
  width: fit-content;
  max-width: calc(100% - 12px);
  display: none;
  align-items: center;
  gap: 8px;
  margin: 0 4px 7px;
  padding: 7px 9px 7px 11px;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  color: var(--accent-deep);
  background: var(--accent-soft);
  font-size: 10.5px;
  font-weight: 650;
}

.file-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip button {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: var(--bad);
  background: transparent;
  cursor: pointer;
}

.file-chip button:hover { transform: none; background: rgba(189, 74, 67, .08); }

/* Modals and sheets */
body.modal-open #app,
body.modal-open #app * { filter: none; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 32px);
  background: rgba(43, 37, 31, .42);
  backdrop-filter: blur(10px) saturate(90%);
  animation: overlayIn .2s ease both;
}

@keyframes overlayIn { from { opacity: 0; } }

.api-modal {
  width: min(100%, 1040px);
  max-width: 1040px;
  max-height: min(900px, calc(100dvh - 40px));
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .82);
  border-radius: 25px;
  background: rgba(250, 247, 242, .95);
  box-shadow: var(--shadow-lg), inset 0 1px 0 #fff;
  animation: modalIn .3s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
}

.api-head {
  min-height: 66px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px 0 24px;
  border-bottom: 1px solid rgba(81, 69, 57, .09);
  background: rgba(255, 253, 249, .62);
}

.api-head b {
  flex: 1;
  color: var(--ink);
  font: 600 19px/1.2 Georgia, serif;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(81, 69, 57, .1);
  border-radius: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, .5);
  cursor: pointer;
  font-size: 15px;
}

.modal-close:hover { color: var(--ink); background: #fff; }

.api-body {
  min-height: 0;
  flex: 1;
  padding: 22px;
  overflow-x: hidden;
  overflow-y: auto;
  color: var(--ink);
}

.api-body section {
  margin: 0 0 14px;
  padding: 20px;
  border: 1px solid rgba(81, 69, 57, .1);
  border-radius: 17px;
  background: rgba(255, 253, 249, .72);
  box-shadow: 0 5px 18px rgba(67, 52, 39, .04), inset 0 1px 0 rgba(255, 255, 255, .85);
}

.api-body h3,
.api-section-head h3 {
  margin: 0 0 15px;
  color: var(--ink);
  font: 600 16px/1.25 Georgia, serif;
}

.api-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 13px;
}

.api-section-head h3 { margin: 0; }
.muted-sm { color: var(--muted); font-size: 11px; line-height: 1.5; }

.prof-top { align-items: center; }
.avatar {
  width: 54px;
  height: 54px;
  border: 1px solid var(--accent-line);
  color: var(--accent-deep);
  background: linear-gradient(145deg, #fff, var(--accent-soft));
  box-shadow: var(--shadow-sm);
}
.prof-name { color: var(--ink); font: 600 20px/1.2 Georgia, serif; }
.prof-sub { color: var(--muted); }

.stat-grid { gap: 9px; }
.stat {
  border: 1px solid rgba(81, 69, 57, .09);
  border-radius: 13px;
  background: rgba(255, 255, 255, .55);
}
.stat .k { color: var(--muted-2); }
.stat .v { color: var(--ink); }

.lim-row { margin: 8px 0 13px; }
.lim-head { color: var(--muted); }
.lim-head span:last-child { color: var(--ink); }
.lim-bar { height: 7px; background: rgba(81, 69, 57, .09); }
.lim-fill { background: linear-gradient(90deg, #4f9871, #6eaa83); }
.lim-fill.warn { background: linear-gradient(90deg, #d19146, #e2a55d); }
.lim-fill.hot { background: linear-gradient(90deg, #c75549, #e36c5f); }

.prov-title { color: var(--ink); }

.set-row {
  gap: 18px;
  padding: 15px 0;
  border-color: rgba(81, 69, 57, .08);
}
.set-row .lbl { color: var(--ink); }
.set-row .hint { color: var(--muted); line-height: 1.5; }

.toggle:not(#fastToggle) {
  border-color: rgba(81, 69, 57, .14);
  background: rgba(81, 69, 57, .12);
}
.toggle:not(#fastToggle).on { border-color: var(--accent); background: var(--accent); }

.accent-dot { border-color: rgba(81, 69, 57, .16); }
.accent-dot.sel { box-shadow: 0 0 0 3px #fff, 0 0 0 5px currentColor; }

.plan-card,
.plat,
.key-row,
.pg-result {
  border-color: rgba(81, 69, 57, .1);
  background: rgba(255, 255, 255, .55);
  color: var(--ink);
  box-shadow: 0 4px 16px rgba(64, 50, 38, .035);
}

.plan-card:hover,
.plat:hover { border-color: var(--accent-line); background: rgba(255, 255, 255, .83); }
.plan-card.cur,
.plat.sel { border-color: var(--accent); background: var(--accent-soft); }
.plan-name { color: var(--ink); }
.plan-price { color: var(--accent-deep); }
.plan-perks { color: var(--muted); }
.plan-cur { color: var(--accent-deep); background: var(--accent-soft); }
.promo-banner,
.promo-note { color: #79571f; border-color: rgba(194, 120, 50, .23); background: rgba(236, 189, 105, .13); }

.buy-btn,
#createKeyBtn,
#pgSend,
#installBtn {
  color: #fff;
  border-color: #aa472c;
  background: linear-gradient(180deg, #d87350, #bd5535);
  box-shadow: 0 7px 16px rgba(167, 69, 40, .14), inset 0 1px 0 rgba(255, 255, 255, .2);
}

#pgCurl {
  color: var(--ink);
  border-color: rgba(81, 69, 57, .12);
  background: rgba(255, 255, 255, .67);
}

.danger-btn,
.key-row .del { color: var(--bad); border-color: rgba(189, 74, 67, .18); background: rgba(189, 74, 67, .07); }

.key-row { gap: 9px; border-radius: 12px; }
.key-row code { color: #685e55; background: rgba(81, 69, 57, .06); }
.key-row button { color: var(--ink); border-color: rgba(81, 69, 57, .1); background: rgba(255, 255, 255, .72); }

.pg-grid { gap: 10px; }
.api-body label { color: var(--muted); }
#pgBody,
.pg-result {
  border-color: rgba(81, 69, 57, .12);
  color: #39342f;
  background: #f5f1eb;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}
#pgBody:focus { border-color: var(--accent); background: #fffdf9; }
.pg-result.ok { border-color: rgba(57, 123, 90, .25); background: rgba(235, 247, 239, .85); }
.pg-result.err { border-color: rgba(189, 74, 67, .22); background: rgba(253, 238, 236, .85); }

.steps { color: var(--muted); }
.steps li { border-color: rgba(81, 69, 57, .09); background: rgba(255, 255, 255, .5); }
.app-note { color: var(--muted); border-color: rgba(81, 69, 57, .1); background: rgba(81, 69, 57, .04); }
.installed-badge { color: var(--ok); background: rgba(57, 123, 90, .1); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 99px;
  background: rgba(81, 69, 57, .17);
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(81, 69, 57, .28); background-clip: content-box; }

.sb-backdrop { display: none; }

/* Medium widths: controls use a second row */
@media (max-width: 1120px) {
  .workspace-header { align-items: flex-start; flex-direction: column; gap: 9px; padding: 11px 16px; }
  .header-leading { width: 100%; }
  .header-controls { width: 100%; justify-content: flex-start; padding-left: 47px; }
  .model-control { flex: 1; }
  .model-control select { width: 100%; }
  .workspace-header h1 { max-width: 55vw; }
}

@media (max-width: 820px) {
  #app { padding: 0; gap: 0; }
  .main { border: 0; border-radius: 0; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(88vw, 326px);
    min-width: min(88vw, 326px);
    border-width: 0 1px 0 0;
    border-radius: 0 23px 23px 0;
    opacity: 1;
    transform: translateX(-104%);
    pointer-events: none;
  }
  body.sb-open .sidebar,
  body.sb-open.sb-collapsed .sidebar {
    width: min(88vw, 326px);
    min-width: min(88vw, 326px);
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
  }
  body.sb-collapsed .sidebar {
    width: min(88vw, 326px);
    min-width: min(88vw, 326px);
    opacity: 1;
    transform: translateX(-104%);
  }
  #sbOpenBtn { display: grid; }
  .sb-backdrop {
    position: fixed;
    inset: 0;
    z-index: 39;
    display: block;
    opacity: 0;
    pointer-events: none;
    background: rgba(42, 36, 30, .4);
    backdrop-filter: blur(4px);
    transition: opacity .22s ease;
  }
  body.sb-open .sb-backdrop { opacity: 1; pointer-events: auto; }
  .workspace-header { border-radius: 0; }
  .connection-strip { display: none; }
  #messages { padding-top: 28px; }
  .composer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .login-card { grid-template-columns: 1fr; width: min(100%, 560px); min-height: 0; }
  .login-story { min-height: 290px; padding: 28px; }
  .login-orbit { position: absolute; right: -8px; top: 54px; width: 210px; opacity: .68; }
  .login-story-copy { max-width: 72%; margin-top: 100px; }
  .login-story-copy h2 { font-size: 29px; }
  .login-story::after { border-radius: 27px 27px 0 0; }
  .login-content { padding: 34px 30px; }
}

@media (max-width: 620px) {
  #login { align-items: flex-start; padding: 10px; }
  .login-card { border-radius: 24px; }
  .login-story { min-height: 230px; padding: 23px; }
  .login-orbit { width: 165px; top: 42px; right: -24px; }
  .login-story-copy { max-width: 82%; margin-top: 60px; }
  .login-story-copy h2 { margin-bottom: 0; font-size: 25px; }
  .login-story-copy p { display: none; }
  .login-content { padding: 28px 23px; }
  .login-content h1 { font-size: 35px; }
  .login-points { margin: 22px 0; }
  .workspace-header { padding: 9px 10px 10px; }
  .title-eyebrow { display: none; }
  .workspace-header h1 { max-width: 50vw; font-size: 16px; }
  .title-line .tag { display: none; }
  .header-controls { gap: 6px; padding-left: 0; overflow-x: auto; scrollbar-width: none; }
  .header-controls::-webkit-scrollbar { display: none; }
  .promo-tag { display: none !important; }
  .model-control { min-width: 195px; flex: 1 0 195px; }
  .model-control > span { display: none; }
  .effort-control { min-width: 112px; padding-left: 8px; }
  .effort-control > span { display: none; }
  #fastToggle { min-width: 45px; padding: 0 8px; }
  #fastToggle > span { display: none; }
  .model-usage { min-width: 58px; padding: 0 9px; }
  .model-usage > span { display: none; }
  .usage-popover { position: fixed; left: 10px; right: 10px; top: 118px; width: auto; }
  #messages { gap: 17px; padding: 28px 13px 14px; }
  .msg { max-width: 90%; padding: 12px 14px; border-radius: 15px; }
  .msg.assistant { width: 90%; }
  .empty-prompts { grid-template-columns: 1fr; }
  .empty-prompts button { min-height: 45px; text-align: center; }
  .composer { padding: 8px 8px max(9px, env(safe-area-inset-bottom)); }
  .composer-inner { padding: 7px 7px 5px; border-radius: 16px; }
  #attachBtn { width: 38px; height: 38px; }
  #input { min-height: 39px; font-size: 13px; }
  #send { min-width: 42px; width: 42px; height: 40px; padding: 0; }
  #send span { display: none; }
  .composer-foot { padding-left: 44px; }
  #composerHint { max-width: 74vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .overlay { align-items: flex-end; padding: 0; }
  .api-modal { width: 100%; max-height: 94dvh; border-width: 1px 0 0; border-radius: 23px 23px 0 0; }
  .api-head { min-height: 58px; padding: 0 13px 0 18px; }
  .api-body { padding: 12px; }
  .api-body section { padding: 15px; border-radius: 14px; }
  .set-row { align-items: flex-start; flex-direction: column; gap: 10px; }
  .set-row > :last-child { width: 100%; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .pg-grid { grid-template-columns: 1fr; }
  .key-row { align-items: stretch; flex-direction: column; }
  .key-row code { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

.no-anim *,
.no-anim *::before,
.no-anim *::after { animation: none !important; transition: none !important; }
