:root {
  color-scheme: dark;
  --ink: #061426;
  --ink-deep: #04101e;
  --surface: #0d2139;
  --surface-raised: #112b48;
  --surface-soft: #153653;
  --line: #2d5c7d;
  --line-soft: #214765;
  --text: #edf7ff;
  --muted: #a7c0d1;
  --faint: #7291a7;
  --mint: #4de0bd;
  --mint-deep: #168f7a;
  --sun: #ffb36b;
  --danger: #ffabb7;
  --shadow: #000b1d91;
}

html[data-theme="midnight"] {
  --ink: #0c0817;
  --ink-deep: #080611;
  --surface: #19132a;
  --surface-raised: #21193a;
  --surface-soft: #30234c;
  --line: #5a4b82;
  --line-soft: #3c315c;
  --text: #f7f0ff;
  --muted: #c5b9d6;
  --faint: #978aad;
  --mint: #b393ff;
  --mint-deep: #7961c4;
  --sun: #ffbe84;
  --shadow: #05030cb3;
}

html[data-theme="light"] {
  color-scheme: light;
  --ink: #eaf4f8;
  --ink-deep: #e1eef5;
  --surface: #ffffff;
  --surface-raised: #f8fcfe;
  --surface-soft: #ddecf4;
  --line: #a8c5d6;
  --line-soft: #c5dae5;
  --text: #142b3d;
  --muted: #49687a;
  --faint: #6c8798;
  --mint: #087d70;
  --mint-deep: #05665c;
  --sun: #a6561d;
  --danger: #b42845;
  --shadow: #46677926;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--line), var(--mint) 20%) color-mix(in srgb, var(--ink-deep), transparent 2%);
}

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

*::-webkit-scrollbar-track {
  border: 2px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink-deep), transparent 18%);
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb {
  min-height: 36px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line), var(--mint) 20%);
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, color-mix(in srgb, var(--line), var(--mint) 54%), color-mix(in srgb, var(--mint), var(--sun) 17%));
  background-clip: padding-box;
}

.task-list {
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}

html {
  background: var(--ink-deep);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 82% 6%, color-mix(in srgb, var(--mint), transparent 83%), transparent 31%),
    radial-gradient(circle at 18% 88%, color-mix(in srgb, var(--sun), transparent 89%), transparent 29%),
    var(--ink);
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  transition: background .36s ease, color .24s ease;
}

button, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--mint), transparent 40%);
  outline-offset: 3px;
}

.app { min-height: 100vh; padding-left: 64px; }

.rail {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  display: flex;
  width: 64px;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  border-right: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--ink-deep), transparent 5%);
  backdrop-filter: blur(22px);
}

.rail button, .rail a {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  text-decoration: none;
  transition: transform .22s cubic-bezier(.16, 1, .3, 1), background .22s ease, color .22s ease, border-color .22s ease;
}

.rail button:hover, .rail a:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--line), transparent 24%);
  background: color-mix(in srgb, var(--surface-raised), transparent 8%);
  transform: translateY(-1px);
}

.rail .profile-dot {
  display: grid;
  width: 28px;
  height: 28px;
  margin-top: auto;
  place-items: center;
  border: 1px solid #ffffff52;
  border-radius: 50%;
  color: #04231f;
  background: linear-gradient(145deg, var(--mint), var(--sun));
  box-shadow: 0 8px 22px color-mix(in srgb, var(--mint), transparent 72%);
  font-size: 10px;
  font-weight: 900;
}

.history {
  position: fixed;
  z-index: 25;
  top: 0;
  bottom: 0;
  left: 64px;
  width: 304px;
  padding: 22px 16px 18px;
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, color-mix(in srgb, var(--ink-deep), transparent 2%), color-mix(in srgb, var(--surface), transparent 12%));
  box-shadow: 22px 0 62px transparent;
  transform: translateX(-108%);
  transition: transform .42s cubic-bezier(.16, 1, .3, 1), box-shadow .42s ease;
}

.sidebar-open .history {
  box-shadow: 22px 0 62px var(--shadow);
  transform: translateX(0);
}

.history-head { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 24px; }
.brand { color: var(--text); font: 700 26px/1 Georgia, serif; letter-spacing: -.07em; }
.brand b { color: var(--mint); }
.close { width: 34px; height: 34px; border: 0; border-radius: 10px; color: var(--faint); background: transparent; font-size: 22px; }
.close:hover { color: var(--text); background: color-mix(in srgb, var(--surface-raised), transparent 7%); }

.new-chat, .operator-create, .create, .gmail-action, .permission-card button, .permission-card a {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid color-mix(in srgb, #fff, transparent 62%);
  border-radius: 13px;
  color: #062622;
  background: linear-gradient(135deg, var(--mint), color-mix(in srgb, var(--mint), var(--sun) 38%));
  box-shadow: inset 0 1px 0 #ffffff8c, 0 13px 30px color-mix(in srgb, var(--mint), transparent 76%);
  font-weight: 850;
  text-decoration: none;
  transition: transform .2s cubic-bezier(.16, 1, .3, 1), filter .2s ease, box-shadow .2s ease;
}

.new-chat::after, .operator-create::after, .create::after, .gmail-action::after, .permission-card button::after, .permission-card a::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background: linear-gradient(116deg, #fff8 0 13%, transparent 38% 66%, #ffffff33 88%);
}

.new-chat:hover, .operator-create:hover, .create:hover, .gmail-action:hover, .permission-card button:hover, .permission-card a:hover {
  filter: saturate(1.08) brightness(1.05);
  box-shadow: inset 0 1px 0 #ffffffa8, 0 17px 38px color-mix(in srgb, var(--mint), transparent 67%);
  transform: translateY(-2px);
}

.new-chat { width: 100%; padding: 12px 13px; text-align: left; }
.history-label { display: block; margin: 26px 8px 9px; color: var(--faint); font-size: 10px; font-weight: 900; letter-spacing: .14em; }
.task-list { display: grid; gap: 4px; max-height: calc(100vh - 260px); overflow: auto; }
.task-item { display: block; overflow: hidden; padding: 10px 11px; border: 1px solid transparent; border-radius: 10px; color: var(--muted); text-decoration: none; text-overflow: ellipsis; white-space: nowrap; transition: .2s ease; }
.task-item:hover, .task-item[aria-current="page"] { border-color: color-mix(in srgb, var(--line), transparent 23%); color: var(--text); background: color-mix(in srgb, var(--surface-raised), transparent 12%); transform: translateX(2px); }
.history-footer { position: absolute; right: 16px; bottom: 18px; left: 16px; display: grid; gap: 3px; padding-top: 15px; border-top: 1px solid var(--line-soft); }
.history-footer a, .history-footer button { width: fit-content; padding: 7px 5px; border: 0; color: var(--faint); background: none; text-align: left; text-decoration: none; }
.history-footer a:hover, .history-footer button:hover { color: var(--text); }

.main { display: flex; min-height: 100vh; flex-direction: column; }
.workspace-header { display: flex; min-height: 72px; align-items: center; justify-content: flex-end; padding: 18px clamp(22px, 4vw, 58px); }
.account { max-width: min(360px, 45vw); overflow: hidden; color: var(--faint); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.start { display: grid; width: min(760px, calc(100% - 38px)); flex: 1; align-content: center; justify-items: center; margin: auto; padding: 8vh 0 13vh; text-align: center; animation: surface-enter .48s cubic-bezier(.16, 1, .3, 1) both; }
.start-mark { display: grid; width: 56px; height: 56px; margin-bottom: 21px; place-items: center; border: 1px solid color-mix(in srgb, var(--mint), transparent 46%); border-radius: 19px; color: var(--mint); background: linear-gradient(145deg, color-mix(in srgb, var(--mint), transparent 87%), color-mix(in srgb, var(--surface-raised), transparent 9%)); box-shadow: 0 19px 40px color-mix(in srgb, var(--mint), transparent 85%); font-size: 25px; }
.start h1 { max-width: 710px; margin: 0; color: var(--text); font: 700 clamp(37px, 5vw, 58px)/1.02 Georgia, serif; letter-spacing: -.065em; }
.start p { max-width: 610px; margin: 18px 0 27px; color: var(--muted); font-size: 16px; line-height: 1.65; }
.operator-create { min-width: 256px; padding: 14px 20px; font-size: 15px; }
.start-note { margin-top: 18px; color: var(--faint); font-size: 12px; }

.conversation { width: min(790px, calc(100% - 38px)); margin: 0 auto; padding: 42px 0 172px; }
.message { width: fit-content; max-width: min(92%, 690px); margin: 0 0 20px; padding: 17px 19px; border: 1px solid var(--line-soft); border-radius: 18px 18px 18px 5px; color: var(--text); background: linear-gradient(145deg, color-mix(in srgb, var(--surface-raised), transparent 2%), color-mix(in srgb, var(--surface), transparent 4%)); box-shadow: 0 13px 33px #00000013; line-height: 1.64; animation: message-in .34s cubic-bezier(.16, 1, .3, 1) both; }
.message b { display: block; margin-bottom: 7px; color: var(--mint); font-size: 12px; letter-spacing: .01em; }
.message p { margin: 0; white-space: normal; }
.message strong { color: color-mix(in srgb, var(--text), #fff 10%); }
.message code { padding: 2px 5px; border-radius: 5px; color: var(--sun); background: color-mix(in srgb, var(--ink-deep), transparent 10%); font: 12px ui-monospace, Consolas, monospace; }
.user-message { margin-left: auto; border-color: color-mix(in srgb, var(--line), transparent 9%); border-radius: 18px 18px 5px 18px; background: color-mix(in srgb, var(--surface-soft), transparent 6%); animation-name: message-out; }
.user-message b { color: color-mix(in srgb, var(--mint), #fff 12%); }
.assistant-message { margin-right: auto; }

.composer { position: fixed; z-index: 12; right: clamp(18px, 4vw, 58px); bottom: 24px; left: max(88px, calc(50% - 395px)); display: grid; grid-template-columns: auto 1fr auto auto auto; width: min(790px, calc(100vw - 108px)); align-items: end; gap: 10px; padding: 8px 9px 8px 12px; border: 1px solid var(--line); border-radius: 19px; background: color-mix(in srgb, var(--surface), transparent 4%); box-shadow: 0 23px 60px var(--shadow); backdrop-filter: blur(24px) saturate(135%); transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease; }
.composer[hidden] { display: none; }
.composer:focus-within { border-color: color-mix(in srgb, var(--mint), var(--line) 50%); box-shadow: 0 0 0 4px color-mix(in srgb, var(--mint), transparent 88%), 0 23px 60px var(--shadow); }
.composer textarea { width: 100%; min-height: 38px; max-height: 180px; padding: 8px 0; border: 0; outline: 0; resize: none; color: var(--text); background: transparent; line-height: 1.5; }
.composer textarea::placeholder { color: var(--faint); }
.composer-tool { display: grid; width: 36px; height: 36px; place-items: center; padding: 0; border: 0; border-radius: 11px; color: var(--faint); background: transparent; transition: color .2s ease, background .2s ease, transform .2s cubic-bezier(.16, 1, .3, 1); }
.composer-tool:hover { color: var(--text); background: color-mix(in srgb, var(--surface-soft), transparent 12%); transform: translateY(-1px); }
.composer-tool svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.composer-tool .stop-icon { display: none; fill: currentColor; stroke: none; }
.voice.is-recording { color: var(--danger); background: color-mix(in srgb, var(--danger), transparent 88%); animation: recording-pulse 1.45s ease-out infinite; }
.voice.is-recording .mic-icon { display: none; }
.voice.is-recording .stop-icon { display: block; }
.mode { padding: 8px 2px; color: var(--faint); font-size: 12px; white-space: nowrap; }
.send { display: grid; width: 40px; height: 40px; place-items: center; padding: 0; border: 0; border-radius: 13px; color: #05231f; background: var(--mint); box-shadow: inset 0 1px #ffffffaa, 0 7px 17px color-mix(in srgb, var(--mint), transparent 60%); font-size: 17px; font-weight: 900; transition: transform .25s cubic-bezier(.16, 1, .3, 1), filter .2s ease, border-radius .25s cubic-bezier(.16, 1, .3, 1); }
.send:hover { filter: brightness(1.07); transform: translateY(-2px) scale(1.03); }
.send:disabled { cursor: wait; opacity: .6; transform: none; }
.send svg { grid-area: 1 / 1; width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.75; transition: opacity .18s ease, transform .25s cubic-bezier(.16, 1, .3, 1); }
.send .stop-icon { opacity: 0; fill: currentColor; stroke: none; transform: scale(.5) rotate(-45deg); }
.send.is-generating { border-radius: 11px; color: #2a1320; background: color-mix(in srgb, var(--danger), #fff 18%); animation: send-generating 1.25s ease-in-out infinite; }
.send.is-generating .send-icon { opacity: 0; transform: scale(.45) rotate(35deg); }
.send.is-generating .stop-icon { opacity: 1; transform: scale(1) rotate(0); }

.attachment-preview { position: fixed; z-index: 13; right: clamp(18px, 4vw, 58px); bottom: 91px; left: max(88px, calc(50% - 395px)); display: flex; width: min(790px, calc(100vw - 108px)); gap: 8px; pointer-events: none; opacity: 0; transform: translateY(10px); transition: opacity .22s ease, transform .25s cubic-bezier(.16, 1, .3, 1); }
.attachment-preview.visible { pointer-events: auto; opacity: 1; transform: none; }
.attachment-chip { position: relative; display: flex; width: 68px; height: 55px; align-items: center; justify-content: center; gap: 5px; overflow: hidden; padding: 5px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: var(--surface-raised); box-shadow: 0 12px 30px var(--shadow); font-size: 10px; }
.attachment-chip img { width: 100%; height: 100%; border-radius: 7px; object-fit: cover; }
.attachment-chip span { color: var(--mint); font-size: 19px; }
.attachment-chip button { position: absolute; top: -5px; right: -5px; display: grid; width: 21px; height: 21px; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--text); background: var(--surface); font-size: 15px; line-height: 1; }
.message-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.message-attachments img { max-width: min(100%, 310px); max-height: 260px; border: 1px solid var(--line-soft); border-radius: 11px; object-fit: cover; }
.message-attachments audio { width: min(100%, 280px); height: 34px; }

.error { width: min(790px, calc(100% - 38px)); min-height: 22px; margin: 8px auto 110px; color: var(--danger); text-align: center; }
.thinking { min-width: 136px; }
.thinking-dots { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; }
.thinking-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); animation: thinking 1.05s ease-in-out infinite; }
.thinking-dots i:nth-child(2) { animation-delay: .14s; }
.thinking-dots i:nth-child(3) { animation-delay: .28s; }
.thinking-dots span { margin-left: 4px; }

.permission-card, .gmail-panel { width: min(100%, 690px); margin: -3px 0 22px; padding: 17px; border: 1px solid color-mix(in srgb, var(--mint), var(--line) 50%); border-radius: 16px; background: linear-gradient(135deg, color-mix(in srgb, var(--mint), transparent 90%), color-mix(in srgb, var(--surface-raised), transparent 2%)); box-shadow: inset 0 1px #ffffff1f; }
.permission-card b, .gmail-panel h3 { display: block; margin: 0 0 6px; color: var(--mint); font-size: 14px; }
.permission-card p, .gmail-panel p { margin: 0 0 13px; color: var(--muted); line-height: 1.5; }
.permission-card button, .permission-card a, .gmail-action { display: inline-flex; align-items: center; padding: 10px 13px; }
.gmail-panel { position: relative; overflow: hidden; display: grid; gap: 2px; padding: 21px; border-color: color-mix(in srgb, var(--mint), var(--line) 35%); background: radial-gradient(circle at 96% 0%, color-mix(in srgb, var(--mint), transparent 76%), transparent 34%), linear-gradient(135deg, color-mix(in srgb, var(--surface-raised), transparent 1%), color-mix(in srgb, var(--mint), transparent 93%)); box-shadow: inset 0 1px #ffffff22, 0 24px 55px color-mix(in srgb, var(--shadow), transparent 38%); animation: panel-arrive .55s cubic-bezier(.16, 1, .3, 1) both; }
.gmail-panel::before { position: absolute; top: -150px; right: -75px; width: 235px; height: 235px; border: 1px solid color-mix(in srgb, var(--mint), transparent 57%); border-radius: 48% 52% 61% 39%; content: ""; opacity: .7; animation: gmail-orbit 10s linear infinite; }
.gmail-panel > * { position: relative; z-index: 1; }
.gmail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 7px; }
.gmail-kicker { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 7px; color: var(--faint); font-size: 10px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.gmail-kicker i, .gmail-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 5px color-mix(in srgb, var(--mint), transparent 84%); animation: gmail-pulse 2.4s ease-out infinite; }
.gmail-panel h3 { margin: 0; color: var(--text); font: 700 22px/1.1 Georgia, serif; letter-spacing: -.04em; }
.gmail-status { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid color-mix(in srgb, var(--mint), transparent 58%); border-radius: 999px; color: var(--mint); background: color-mix(in srgb, var(--mint), transparent 90%); font-size: 12px; font-weight: 800; white-space: nowrap; }
.gmail-status i { width: 6px; height: 6px; }
.gmail-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
.gmail-action { gap: 8px; min-height: 42px; border-radius: 12px; }
.gmail-action span { display: inline-grid; width: 16px; place-items: center; font-size: 16px; transition: transform .25s cubic-bezier(.16, 1, .3, 1); }
.gmail-action:hover span { transform: rotate(28deg) scale(1.12); }
.gmail-action.is-loading span { animation: button-spin 1.05s linear infinite; }
.gmail-hint { color: var(--faint); font-size: 12px; }
.gmail-preview { display: grid; gap: 8px; margin-top: 14px; }
.gmail-row { padding: 11px 12px; border: 1px solid var(--line-soft); border-radius: 10px; color: var(--muted); background: color-mix(in srgb, var(--ink-deep), transparent 18%); font-size: 13px; animation: row-in .35s cubic-bezier(.16, 1, .3, 1) both; }
.gmail-row b { color: var(--text); }
.gmail-row-error { border-color: color-mix(in srgb, var(--danger), var(--line) 50%); }
.gmail-row a { display: inline-block; margin-top: 7px; color: var(--mint); }

.resource-modal { max-width: 620px; }
.resource-icon { display: grid; width: 42px; height: 42px; margin-bottom: 13px; place-items: center; border: 1px solid color-mix(in srgb, var(--mint), transparent 48%); border-radius: 14px; color: var(--mint); background: color-mix(in srgb, var(--mint), transparent 89%); font-size: 20px; }
.resource-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 19px 0 15px; }
.resource-choices button { min-height: 112px; padding: 15px; border: 1px solid var(--line-soft); border-radius: 14px; color: var(--text); background: color-mix(in srgb, var(--surface-soft), transparent 14%); text-align: left; transition: border-color .22s ease, transform .22s cubic-bezier(.16, 1, .3, 1), background .22s ease; }
.resource-choices button:hover { border-color: var(--mint); background: color-mix(in srgb, var(--mint), transparent 91%); transform: translateY(-3px); }
.resource-choices b { display: block; margin-bottom: 6px; font-size: 14px; }
.resource-choices span, .resource-note { color: var(--muted); font-size: 13px; line-height: 1.5; }
.resource-note { padding: 10px 12px; border-left: 2px solid var(--mint); border-radius: 0 8px 8px 0; background: color-mix(in srgb, var(--mint), transparent 93%); }

.modal-backdrop { position: fixed; z-index: 70; inset: 0; display: grid; place-items: center; padding: 20px; background: #020917a8; backdrop-filter: blur(14px); animation: overlay-in .22s ease; }
.modal { width: min(590px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 22px; color: var(--text); background: linear-gradient(145deg, var(--surface-raised), var(--surface)); box-shadow: 0 32px 100px #000c; animation: modal-in .34s cubic-bezier(.16, 1, .3, 1); }
.modal h2 { margin: 0; font: 700 30px/1.12 Georgia, serif; letter-spacing: -.05em; }
.modal p { color: var(--muted); line-height: 1.55; }
.modal label { display: block; margin: 20px 0 8px; color: var(--text); font-size: 13px; font-weight: 800; }
.modal textarea { width: 100%; min-height: 145px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; outline: none; resize: vertical; color: var(--text); background: color-mix(in srgb, var(--ink-deep), transparent 8%); line-height: 1.5; }
.modal textarea:focus { border-color: var(--mint); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mint), transparent 84%); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 19px; }
.modal-actions button { padding: 11px 15px; }
.cancel { border: 0; border-radius: 11px; color: var(--muted); background: transparent; font-weight: 750; }
.cancel:hover { color: var(--text); background: color-mix(in srgb, var(--surface-soft), transparent 25%); }
.modal-error { min-height: 18px; color: var(--danger) !important; font-size: 13px; }
.calibration-private { padding: 11px 12px; border-left: 3px solid var(--mint); border-radius: 0 9px 9px 0; background: color-mix(in srgb, var(--mint), transparent 91%); font-size: 13px; }

.toast { position: fixed; z-index: 90; bottom: 28px; left: 50%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: var(--surface-raised); box-shadow: 0 14px 36px var(--shadow); font-size: 13px; opacity: 0; pointer-events: none; transform: translate(-50%, 15px); transition: .24s ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@keyframes surface-enter { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes message-in { from { opacity: 0; transform: translate(-10px, 10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes message-out { from { opacity: 0; transform: translate(16px, 10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes thinking { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-6px); } }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(15px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes panel-arrive { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes gmail-orbit { to { transform: rotate(360deg); } }
@keyframes gmail-pulse { 0%, 70%, 100% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--mint), transparent 84%); } 35% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--mint), transparent 96%); } }
@keyframes button-spin { to { transform: rotate(360deg); } }
@keyframes row-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes recording-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger), transparent 75%); } 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--danger), transparent 93%); } }
@keyframes send-generating { 0%, 100% { box-shadow: inset 0 1px #ffffffaa, 0 7px 17px color-mix(in srgb, var(--danger), transparent 68%); } 50% { box-shadow: inset 0 1px #ffffffaa, 0 10px 24px color-mix(in srgb, var(--danger), transparent 50%); } }

@media (max-width: 720px) {
  .app { padding-left: 0; }
  .rail { width: 54px; }
  .history { left: 0; width: min(304px, 88vw); }
  .workspace-header { min-height: 58px; padding: 15px 17px 15px 70px; }
  .start { width: min(100% - 32px, 760px); padding: 12vh 0 17vh; }
  .start h1 { font-size: 40px; }
  .conversation { width: min(100% - 24px, 790px); padding: 24px 0 144px; }
  .message { max-width: 96%; }
  .composer { right: 12px; bottom: 12px; left: 66px; width: calc(100vw - 78px); border-radius: 17px; }
  .attachment-preview { right: 12px; bottom: 79px; left: 66px; width: calc(100vw - 78px); }
  .mode { display: none; }
  .error { width: calc(100% - 24px); }
}

@media (max-width: 520px) {
  .gmail-head { align-items: flex-start; flex-direction: column; gap: 9px; }
  .resource-choices { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  .start h1 { font-size: 35px; }
  .start p { font-size: 15px; }
  .operator-create { width: 100%; }
  .modal { padding: 21px; }
  .modal h2 { font-size: 26px; }
  .composer { grid-template-columns: auto 1fr auto auto; gap: 5px; }
  .mode { display: none; }
}


/* Final interaction polish: deliberate motion, visible keyboard focus and themed scrollbars. */
:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}

.history, .task-list {
  scrollbar-color: color-mix(in srgb, var(--mint), transparent 35%) transparent;
  scrollbar-width: thin;
}

.history::-webkit-scrollbar, .task-list::-webkit-scrollbar { width: 9px; height: 9px; }
.history::-webkit-scrollbar-thumb, .task-list::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--mint), transparent 40%);
  background-clip: padding-box;
}

.new-chat, .operator-create, .create, .gmail-action, .permission-card button, .permission-card a {
  overflow: hidden;
  isolation: isolate;
}

.new-chat::after, .operator-create::after, .create::after, .gmail-action::after, .permission-card button::after, .permission-card a::after {
  transform: translateX(-115%);
  transition: transform .58s cubic-bezier(.16, 1, .3, 1);
}

.new-chat:hover::after, .operator-create:hover::after, .create:hover::after, .gmail-action:hover::after, .permission-card button:hover::after, .permission-card a:hover::after {
  transform: translateX(115%);
}

.composer-tool:disabled, .send:disabled { cursor: not-allowed; opacity: .52; }
body.is-generating .composer { animation: composer-working 1.8s ease-in-out infinite; }

@keyframes composer-working {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mint), transparent 100%), 0 23px 60px var(--shadow); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--mint), transparent 91%), 0 23px 60px var(--shadow); }
}

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


/* Final interaction polish: responsive, restrained and theme-aware. */
@media (prefers-reduced-motion: no-preference) {
  .message, .permission-card, .gmail-board, .empty-state { animation: ahim-rise .42s cubic-bezier(.16,1,.3,1) both; }
  .task-list button { transition: background .2s ease, color .2s ease, transform .2s cubic-bezier(.16,1,.3,1); }
  .task-list button:hover { transform: translateX(3px); }
  .send:not(.is-stop) { box-shadow: 0 10px 28px color-mix(in srgb,var(--mint),transparent 62%); }
}
@keyframes ahim-rise { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
.send svg, .composer-tool svg { stroke-width: 2.35; stroke-linecap: round; stroke-linejoin: round; }
.send:active, .new-chat:active, .operator-create:active, .create:active { transform: translateY(1px) scale(.98); }
.composer:focus-within { border-color: color-mix(in srgb,var(--mint),var(--line) 42%); box-shadow: 0 0 0 4px color-mix(in srgb,var(--mint),transparent 88%), 0 22px 52px var(--shadow); }
html[data-theme="light"] .composer { box-shadow: 0 14px 36px #46677924; }
@media (max-width: 720px) {
  .app { padding-left: 52px; }
  .rail { width: 52px; }
  .history { left: 52px; width: min(304px, calc(100vw - 52px)); }
  .composer { margin-inline: 12px; }
}
