:root {
  color-scheme: dark;
  --bg: #111315;
  --panel: #1a1d21;
  --panel-strong: #23272d;
  --line: #2f343c;
  --text: #f2f5f7;
  --muted: #9aa4af;
  --accent: #5ed3a8;
  --assistant: #1e252c;
  --user: #285043;
  --danger: rgba(0, 0, 0, 0.68);
  --app-height: 100dvh;
  --composer-height: 88px;
  --telegram-top-clearance: 32px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  font-size: 13px;
  background:
    radial-gradient(circle at top, rgba(94, 211, 168, 0.12), transparent 28%),
    linear-gradient(180deg, #0f1113 0%, #15191d 100%);
  color: var(--text);
  overscroll-behavior: none;
}

button,
textarea,
select {
  font: inherit;
}

svg {
  display: block;
}

.hidden {
  display: none !important;
}

.app-shell {
  position: relative;
  height: var(--app-height);
  min-height: var(--app-height);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: var(--telegram-top-clearance);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding:
    calc(10px + env(safe-area-inset-top) + var(--telegram-top-clearance))
    calc(12px + env(safe-area-inset-right))
    8px
    calc(12px + env(safe-area-inset-left));
  backdrop-filter: blur(18px);
  background: rgba(17, 19, 21, 0.88);
  border-bottom: 1px solid rgba(47, 52, 60, 0.5);
}

.topbar.hidden {
  display: none;
}

.topbar-copy {
  min-width: 0;
  flex: 1;
}

.topbar-actions {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
}

.back-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.back-button {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 0;
  flex: 0 0 auto;
}

.back-arrow {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke: currentColor;
}

.topbar-menu {
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 0;
  flex: 0 0 auto;
}

.topbar-menu svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.workspace-warning {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 99, 99, 0.16);
  border: 1px solid rgba(255, 99, 99, 0.42);
  color: #ff7a7a;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.eyebrow {
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

h1 {
  margin: 4px 0 0;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-drawer {
  position: absolute;
  inset: 0;
  z-index: 10;
  background:
    radial-gradient(circle at top, rgba(94, 211, 168, 0.1), transparent 30%),
    linear-gradient(180deg, rgba(15, 17, 19, 0.96) 0%, rgba(21, 25, 29, 0.98) 100%);
  opacity: 1;
  transition: opacity 180ms ease, transform 220ms ease;
  overflow: hidden;
}

.project-drawer.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  visibility: hidden;
}

.drawer-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding:
    calc(10px + env(safe-area-inset-top) + var(--telegram-top-clearance))
    calc(12px + env(safe-area-inset-right))
    calc(var(--composer-height) + 12px + env(safe-area-inset-bottom))
    calc(12px + env(safe-area-inset-left));
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.drawer-header-main {
  min-width: 0;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
}

.drawer-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.drawer-profile-button svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.drawer-nav-button {
  width: 42px;
  height: 42px;
  padding: 0;
  flex: 0 0 auto;
}

.drawer-nav-button svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

.drawer-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  white-space: nowrap;
}

.drawer-action {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
}

.sync-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.sync-icon-button {
  position: relative;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  display: grid;
  place-items: center;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    transform 180ms ease;
  isolation: isolate;
  --ring-progress: 0%;
}

.sync-icon-button::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  background: conic-gradient(var(--accent) 0 var(--ring-progress), rgba(94, 211, 168, 0.15) 0 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
  opacity: 0;
  transition: opacity 180ms ease;
  z-index: -1;
}

.sync-icon-button:active {
  transform: scale(0.97);
}

.sync-glyph {
  position: absolute;
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.84);
  transform-origin: 50% 50%;
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.sync-icon-button[data-state="idle"] .sync-glyph-idle,
.sync-icon-button[data-state="syncing"] .sync-glyph-idle,
.sync-icon-button[data-state="completed"] .sync-glyph-success,
.sync-icon-button[data-state="error"] .sync-glyph-error {
  opacity: 1;
  transform: scale(1);
}

.sync-icon-button[data-state="syncing"] .sync-glyph-idle {
  animation: sync-spin 0.95s linear infinite;
}

.sync-icon-button[data-state="syncing"]::before,
.sync-icon-button[data-state="completed"]::before {
  opacity: 1;
}

.sync-icon-button[data-state="completed"] {
  color: var(--accent);
  border-color: rgba(94, 211, 168, 0.45);
  background: rgba(94, 211, 168, 0.08);
}

.sync-icon-button[data-state="error"] {
  color: #ff8b8b;
  border-color: rgba(255, 139, 139, 0.4);
  background: rgba(255, 139, 139, 0.07);
}

.sync-error-popup {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 8;
  width: max-content;
  max-width: min(260px, calc(100vw - 32px));
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(26, 29, 33, 0.98);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.26);
  white-space: normal;
}

.sync-error-popup::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 14px;
  width: 10px;
  height: 10px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: rgba(26, 29, 33, 0.98);
  transform: rotate(45deg);
}

.workspace-sync-strip {
  position: sticky;
  top: var(--telegram-top-clearance);
  z-index: 19;
  padding: 0 calc(12px + env(safe-area-inset-right)) 0 calc(12px + env(safe-area-inset-left));
  background: rgba(17, 19, 21, 0.88);
  opacity: 1;
  transition: opacity 260ms ease;
}

.workspace-sync-strip-track {
  position: relative;
  height: 3px;
  width: 100%;
  border-radius: 999px;
  background: rgba(94, 211, 168, 0.1);
  overflow: hidden;
}

.workspace-sync-strip-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--workspace-progress, 0%);
  min-width: 0;
  background: linear-gradient(90deg, rgba(94, 211, 168, 0.3), rgba(94, 211, 168, 1));
  border-radius: inherit;
  transition: width 160ms linear, opacity 180ms ease;
}

.workspace-sync-strip.is-active .workspace-sync-strip-fill {
  animation: workspace-progress-glow 1.2s linear infinite;
}

.workspace-sync-strip.is-complete .workspace-sync-strip-fill {
  width: 100%;
}

.workspace-sync-strip.is-complete {
  animation: workspace-strip-fadeout 0.45s ease 0.55s forwards;
}

.workspace-sync-strip-done {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-size: 12px;
  line-height: 1;
  padding-left: 8px;
  background: linear-gradient(90deg, rgba(17, 19, 21, 0) 0%, rgba(17, 19, 21, 1) 35%);
}

.project-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 18px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.project-row {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  flex: 0 0 auto;
  background: transparent;
}

.project-row-actions {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  gap: 1px;
  background: transparent;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease;
}

.project-swipe-button {
  min-width: 72px;
  border: none;
  color: #fff;
  font-weight: 600;
  pointer-events: auto;
  display: grid;
  place-items: center;
  padding: 0;
}

.project-swipe-button svg {
  width: 22px;
  height: 22px;
}

.project-swipe-button.archive {
  background: #4d6270;
}

.project-swipe-button.delete {
  background: #d95858;
}

.project-item {
  position: relative;
  z-index: 1;
  width: 100%;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text);
  border-radius: 16px;
  min-height: 94px;
  padding: 14px 15px 13px;
  text-align: left;
  display: flex;
  align-items: flex-start;
  overflow: hidden;
  cursor: pointer;
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1), border-color 180ms ease, background 180ms ease, opacity 180ms ease;
  will-change: transform;
}

.project-row.active .project-item {
  border-color: var(--accent);
  background: rgba(35, 39, 45, 0.95);
}

.project-row.swiped .project-row-actions {
  opacity: 1;
}

.project-item-copy {
  min-width: 0;
  width: 100%;
}

.project-item-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: #f2f5f7 !important;
  -webkit-text-fill-color: #f2f5f7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-item-subtitle {
  display: -webkit-box;
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.35;
  color: #9aa4af !important;
  -webkit-text-fill-color: #9aa4af;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.messages {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  z-index: 11;
  padding:
    6px
    calc(12px + env(safe-area-inset-right))
    calc(var(--composer-height) + 14px + env(safe-area-inset-bottom))
    calc(12px + env(safe-area-inset-left));
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  scroll-behavior: smooth;
  background:
    radial-gradient(circle at top, rgba(94, 211, 168, 0.08), transparent 30%),
    linear-gradient(180deg, #0f1113 0%, #15191d 100%);
  isolation: isolate;
}

.sheet-thread-actions {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
}

.workspace-sheet-panel {
  display: grid;
  gap: 12px;
}

.profile-sheet-panel {
  display: grid;
  gap: 12px;
}

.profile-options {
  display: grid;
  gap: 8px;
  max-height: min(42dvh, 340px);
  overflow-y: auto;
}

.profile-option {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  -webkit-text-fill-color: var(--text);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.profile-option-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.profile-option-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-option-subtitle {
  font-size: 11px;
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
}

.profile-option-check {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 140ms ease, transform 140ms ease;
}

.profile-option-check svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.profile-option.active {
  border-color: var(--accent);
  background: rgba(94, 211, 168, 0.08);
}

.profile-option.active .profile-option-check {
  opacity: 1;
  transform: scale(1);
  color: var(--accent);
}

.profile-add-row {
  width: 100%;
  border: 1px dashed rgba(154, 164, 175, 0.35);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0.72;
  cursor: pointer;
}

.profile-add-plus {
  font-size: 20px;
  line-height: 1;
}

.profile-add-row.is-connecting {
  border-style: solid;
  border-color: rgba(94, 211, 168, 0.34);
  background: rgba(94, 211, 168, 0.08);
  opacity: 1;
  cursor: default;
}

.profile-connect-body {
  width: 100%;
  display: grid;
  gap: 8px;
}

.profile-connect-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.profile-connect-text {
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
}

.profile-connect-code {
  width: fit-content;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(94, 211, 168, 0.32);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.profile-connect-open {
  width: fit-content;
  border: 1px solid rgba(94, 211, 168, 0.38);
  border-radius: 12px;
  background: rgba(94, 211, 168, 0.14);
  color: var(--text);
  padding: 8px 12px;
}

.workspace-create-toggle {
  width: 100%;
  border: 1px solid rgba(94, 211, 168, 0.34);
  border-radius: 14px;
  background: rgba(94, 211, 168, 0.08);
  color: var(--text);
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 14px;
  overflow: hidden;
  cursor: pointer;
}

.workspace-create-prefix,
.workspace-create-label {
  transition: opacity 180ms ease, transform 180ms ease;
}

.workspace-create-prefix {
  font-size: 18px;
  line-height: 1;
}

.workspace-create-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  animation: workspace-input-in 180ms ease forwards;
}

.workspace-create-cancel {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 0;
  flex: 0 0 auto;
}

.workspace-create-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  outline: none;
  padding: 0;
}

.workspace-options {
  display: grid;
  gap: 8px;
  max-height: min(42dvh, 340px);
  overflow-y: auto;
}

.workspace-option {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  -webkit-text-fill-color: var(--text);
  padding: 11px 12px;
  text-align: left;
  display: grid;
  gap: 4px;
  overflow: hidden;
  cursor: pointer;
}

.workspace-option.active {
  border-color: var(--accent);
  background: rgba(94, 211, 168, 0.08);
}

.workspace-option-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  -webkit-text-fill-color: var(--text);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-option-subtitle {
  font-size: 11px;
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-option-input {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(94, 211, 168, 0.34);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 8px 10px;
  outline: none;
  font: inherit;
}

.workspace-option-input:focus {
  border-color: rgba(94, 211, 168, 0.5);
}

.workspace-sheet-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.sheet-action-button {
  width: 100%;
  border: 1px solid rgba(94, 211, 168, 0.34);
  border-radius: 14px;
  background: rgba(94, 211, 168, 0.1);
  color: var(--text);
  padding: 11px 14px;
  position: relative;
  overflow: hidden;
  --button-progress: 0%;
}

.sheet-action-button.is-progress::before,
.sheet-action-button.is-complete::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--button-progress, 0%);
  background: rgba(94, 211, 168, 0.22);
  transition: width 160ms linear;
  z-index: 0;
}

.sheet-action-button > * {
  position: relative;
  z-index: 1;
}

.sheet-action-button.secondary {
  border-color: var(--line);
  background: var(--panel);
}

.sheet-action-button:disabled {
  opacity: 0.56;
  pointer-events: none;
}

.message {
  display: flex;
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px);
  animation: message-in 220ms ease forwards;
}

.message.user {
  justify-content: flex-end;
}

.message.system {
  justify-content: center;
}

.bubble {
  width: auto;
  max-width: min(560px, 86%, calc(100% - 10px));
  padding: 9px 11px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--assistant);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.message.user .bubble {
  background: var(--user);
}

.message.system .bubble {
  min-width: min(240px, 100%);
  max-width: min(92%, 560px);
  background: rgba(111, 118, 128, 0.14);
  border-color: rgba(154, 164, 175, 0.22);
  box-shadow: none;
}

.message.assistant.task-progress .bubble {
  background: rgba(111, 118, 128, 0.14);
  border-color: rgba(154, 164, 175, 0.22);
  box-shadow: none;
}

.meta {
  font-size: 9px;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.content {
  white-space: pre-wrap;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

.message.system .meta {
  color: #b5bec7;
}

.message.assistant.task-progress .meta {
  color: #b5bec7;
}

.message.system .content {
  color: #d7dde3;
}

.message.assistant.task-progress .content {
  color: #d7dde3;
}

.content.loading-text {
  background: linear-gradient(90deg, rgba(152, 161, 170, 0.36) 0%, rgba(246, 248, 249, 0.96) 50%, rgba(152, 161, 170, 0.36) 100%);
  background-size: 220% 100%;
  color: transparent;
  -webkit-text-fill-color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  animation: thinking-wave 1.4s linear infinite;
}

.text-block + .text-block {
  margin-top: 10px;
}

.content code {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.95em;
}

.content pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 10, 12, 0.92);
  overflow-x: auto;
}

.content pre code {
  display: block;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #e8edf1;
  font-size: 12px;
  line-height: 1.5;
}

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 18;
  width: 100%;
  padding:
    8px
    calc(12px + env(safe-area-inset-right))
    calc(12px + env(safe-area-inset-bottom))
    calc(12px + env(safe-area-inset-left));
  backdrop-filter: blur(18px);
  background: rgba(17, 19, 21, 0.88);
  border-top: 1px solid rgba(47, 52, 60, 0.45);
}

.project-list-empty {
  margin-top: 4px;
}

.attachments-preview {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.attachment-card {
  position: relative;
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 16px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
}

.attachment-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-file-box {
  width: 100%;
  height: 100%;
  padding: 8px;
  color: var(--muted);
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 10px;
  line-height: 1.3;
}

.attachment-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.composer-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.message-input {
  width: 100%;
  min-height: 44px;
  max-height: 168px;
  resize: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 22px;
  padding: 11px 14px 10px;
  line-height: 1.35;
  overflow-y: auto;
  outline: none;
  box-shadow: none;
}

.message-input:focus {
  outline: none;
  box-shadow: none;
  border-color: var(--line);
}

.composer-icon {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  padding: 0;
  flex: 0 0 auto;
}

.composer-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.send-button {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #0e1714;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.send-button:active {
  transform: scale(0.97);
}

.send-button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.send-button.is-stop {
  border-radius: 14px;
}

.send-stop-icon {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: currentColor;
}

.send-button.loading {
  background: #76dfbb;
}

.send-button:disabled,
.icon-button:disabled,
.back-button:disabled {
  opacity: 0.58;
}

.controls-panel {
  display: grid;
  gap: 10px;
}

.controls-panel label {
  display: grid;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}

.controls-panel select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  padding: 10px 12px;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 24;
  display: grid;
  align-items: end;
  background: rgba(0, 0, 0, 0);
  transition: background 180ms ease;
}

.sheet-backdrop.visible {
  background: rgba(0, 0, 0, 0.5);
}

.bottom-sheet {
  width: 100%;
  border-radius: 24px 24px 0 0;
  background: rgba(26, 29, 33, 0.98);
  border-top: 1px solid rgba(47, 52, 60, 0.5);
  box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.3);
  padding:
    10px
    calc(14px + env(safe-area-inset-right))
    calc(16px + env(safe-area-inset-bottom))
    calc(14px + env(safe-area-inset-left));
  transform: translateY(100%);
  transition: transform 220ms ease;
}

.sheet-backdrop.visible .bottom-sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: rgba(154, 164, 175, 0.45);
  margin: 0 auto 12px;
}

.sheet-header {
  margin-bottom: 14px;
}

.sheet-title {
  font-size: 14px;
  font-weight: 600;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(14, 23, 20, 0.25);
  border-top-color: #0e1714;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.status-card {
  margin: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  line-height: 1.45;
}

.preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.76);
  z-index: 28;
  display: grid;
  place-items: center;
  padding: 16px;
}

.preview-shell {
  width: min(100%, 560px);
  display: grid;
  gap: 12px;
}

.preview-close {
  justify-self: end;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 0;
}

.preview-image {
  width: 100%;
  max-height: 72dvh;
  object-fit: contain;
  border-radius: 18px;
  background: #0d0f11;
}

.preview-file {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 16px;
  padding: 14px;
}

@media (max-width: 420px) {
  .bubble {
    max-width: min(90%, calc(100% - 8px));
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes sync-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes thinking-wave {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -20% 0;
  }
}

@keyframes workspace-progress-glow {
  0% {
    filter: brightness(0.95);
  }
  50% {
    filter: brightness(1.2);
  }
  100% {
    filter: brightness(0.95);
  }
}

@keyframes workspace-strip-fadeout {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes message-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes workspace-input-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
