:root {
  color-scheme: light;
  background: #f3f4f6;
  color: #111827;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

body,
html {
  margin: 0;
  min-height: 100%;
}

body {
  min-width: 320px;
}

.page-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  margin-bottom: 18px;
}

.header h1 {
  margin: 0 0 8px;
  font-size: 1.9rem;
}

.header p {
  margin: 0;
  color: #4b5563;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.topic-panel {
  min-height: 620px;
  border-right: 1px solid #e5e7eb;
  padding-right: 14px;
}

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

.topic-header h2 {
  margin: 0;
  font-size: 1rem;
}

.session-list {
  display: grid;
  gap: 8px;
}

.session-search {
  width: 100%;
  min-height: 38px;
  margin-bottom: 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
  color: #111827;
  font: inherit;
  font-size: 0.9rem;
}

.session-empty {
  padding: 12px 8px;
  color: #64748b;
  font-size: 0.88rem;
}

.session-section {
  padding: 10px 4px 2px;
  color: #6b7280;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.session-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: #ffffff;
  color: #111827;
  border: 1px solid #e5e7eb;
  text-align: left;
}

.session-item.active {
  background: #dbeafe;
  border-color: #93c5fd;
}

.session-item.codex {
  border-color: #ccfbf1;
}

.session-item.codex.active {
  background: #ccfbf1;
  border-color: #14b8a6;
}

.session-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-count {
  min-width: 28px;
  border-radius: 999px;
  padding: 3px 7px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 0.78rem;
  text-align: center;
}

.session-item.codex .session-count {
  background: #ccfbf1;
  color: #0f766e;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.messages {
  min-height: 420px;
  max-height: calc(100vh - 300px);
  padding: 18px;
  background: #ffffff;
  border-radius: 20px;
  border: 1px solid #e5e7eb;
  overflow-y: auto;
}

.message {
  margin-bottom: 18px;
  line-height: 1.7;
}

.message.user {
  text-align: right;
}

.message.assistant {
  text-align: left;
}

.message .bubble {
  display: inline-block;
  max-width: 84%;
  padding: 14px 16px;
  border-radius: 18px;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .bubble {
  background: #2563eb;
  color: white;
}

.message.assistant .bubble {
  background: #f3f4f6;
  color: #111827;
}

.message .bubble a {
  color: #1d4ed8;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.message .bubble a:hover {
  color: #1e40af;
}

.message.user .bubble a {
  color: #ffffff;
}

.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 0 8px;
}

.session-bar span {
  color: #374151;
  font-size: 0.98rem;
}

.toolbar {
  display: flex;
  gap: 8px;
}

.command-panel {
  margin: 10px 14px 0;
  padding: 12px;
  background: #ffffff;
  border: 1px solid #d9d9e3;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

.command-panel[hidden] {
  display: none;
}

.command-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.command-grid button {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 0 8px;
  background: #f1f5f9;
  color: #0f172a;
  font-size: 0.84rem;
}

.command-runner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
}

.command-runner input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
}

.more-button {
  display: none;
}

.composer {
  display: grid;
  gap: 10px;
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.voice-status {
  min-height: 20px;
  color: #4b5563;
  font-size: 0.9rem;
  text-align: right;
}

.input-wrap {
  position: relative;
}

textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid #d1d5db;
  padding: 14px 16px;
  resize: vertical;
  font-size: 1rem;
  min-height: 96px;
}

.slash-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 10;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.16);
}

.slash-item {
  width: 100%;
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: transparent;
  color: #111827;
  text-align: left;
}

.slash-item.active,
.slash-item:hover {
  background: #eff6ff;
}

.slash-command {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-weight: 700;
  color: #1d4ed8;
}

.slash-note {
  min-width: 0;
  overflow: hidden;
  color: #4b5563;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar button.active {
  background: #0f766e;
  color: #ffffff;
}

button {
  width: 160px;
  justify-self: end;
  border: none;
  border-radius: 8px;
  padding: 14px 22px;
  background: #2563eb;
  color: white;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  width: auto;
  min-width: 88px;
  background: #e5e7eb;
  color: #111827;
}

button.icon-button {
  width: 48px;
  min-width: 48px;
  padding: 0;
  font-size: 1.15rem;
  line-height: 48px;
}

button.icon-button.listening {
  background: #dc2626;
  color: #ffffff;
}

button.danger {
  width: auto;
  min-width: 88px;
  background: #fee2e2;
  color: #991b1b;
}

button.cancel {
  background: #dc2626;
  color: #ffffff;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  body,
  html {
    height: 100%;
  }

  .page-shell {
    min-height: 100vh;
    padding: 10px;
    display: flex;
    flex-direction: column;
  }

  .header {
    margin-bottom: 10px;
  }

  .header h1 {
    margin-bottom: 0;
    font-size: 1.12rem;
  }

  .header p {
    display: none;
  }

  .workspace {
    flex: 1;
    grid-template-columns: 1fr;
    gap: 10px;
    min-height: 0;
  }

  .topic-panel {
    min-height: auto;
    border-right: 0;
    padding-right: 0;
  }

  .session-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  .session-search {
    display: none;
  }

  .session-section {
    flex: 0 0 auto;
    align-self: center;
    padding: 0 4px;
    white-space: nowrap;
  }

  .session-item {
    min-width: 164px;
    max-width: 220px;
    padding: 10px;
  }

  .slash-item {
    grid-template-columns: 88px minmax(0, 1fr);
    padding: 9px;
  }

  .slash-menu {
    max-height: min(48vh, 300px);
  }

  .chat-panel {
    min-height: 0;
    gap: 8px;
  }

  .session-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 0;
  }

  .session-bar span {
    min-height: 20px;
    overflow: hidden;
    font-size: 0.86rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .toolbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .messages {
    flex: 1;
    min-height: 260px;
    max-height: none;
    padding: 12px;
    border-radius: 10px;
  }

  .message {
    margin-bottom: 12px;
    line-height: 1.55;
  }

  .message .bubble {
    max-width: 92%;
    padding: 11px 12px;
    border-radius: 12px;
    font-size: 0.96rem;
  }

  .composer {
    gap: 8px;
  }

  .composer-actions {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .voice-status {
    text-align: left;
  }

  textarea {
    min-height: 76px;
    max-height: 32vh;
    border-radius: 10px;
    padding: 12px;
    font-size: 16px;
  }

  button {
    width: 100%;
    min-width: 0;
    padding: 11px 10px;
  }

  button.secondary,
  button.danger {
    min-width: 0;
  }

  button.icon-button {
    width: 48px;
    min-width: 48px;
    line-height: 42px;
  }
}

@media (max-width: 380px) {
  .toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .session-item {
    min-width: 150px;
  }

  .slash-item {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .slash-note {
    font-size: 0.82rem;
  }
}

/* Final mobile composer clamp: larger send button, guaranteed inside frame. */
@media (max-width: 760px) {
  .composer {
    width: auto;
    max-width: none;
    margin-left: 16px;
    margin-right: 16px;
    padding: 10px 12px;
    box-sizing: border-box;
    overflow: hidden;
  }

  .composer-actions {
    grid-template-columns: minmax(0, 1fr) 56px;
    gap: 8px;
    overflow: visible;
  }

  .composer-tools {
    min-width: 0;
    overflow-x: auto;
    padding-right: 0;
  }

  .tool-button {
    min-height: 34px;
    max-width: 72px;
  }

  .composer #sendButton {
    width: 52px;
    min-width: 52px;
    max-width: 52px;
    min-height: 42px;
    border-radius: 14px;
    justify-self: end;
  }

  .composer #sendButton::before {
    font-size: 1.28rem;
  }

  body.keyboard-open .composer {
    left: 16px;
    right: 16px;
    width: auto;
    margin-left: 0;
    margin-right: 0;
  }
}

@media (max-width: 380px) {
  .composer {
    margin-left: 12px;
    margin-right: 12px;
    padding: 9px 10px;
  }

  .composer-actions {
    grid-template-columns: minmax(0, 1fr) 52px;
    gap: 7px;
  }

  .tool-button {
    max-width: 62px;
  }

  .composer #sendButton {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
    min-height: 40px;
  }

  body.keyboard-open .composer {
    left: 12px;
    right: 12px;
  }
}

/* Mobile app shell refresh */
body {
  background: linear-gradient(180deg, #f8fafc 0%, #eef1f4 44%, #e7edf0 100%);
}

.page-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header h1 {
  font-size: 1.45rem;
  font-weight: 760;
}

.header p {
  color: #64748b;
  font-size: 0.92rem;
}

.workspace {
  flex: 1;
  min-height: 0;
}

.topic-panel,
.chat-panel,
.login-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 8px;
  box-shadow: 0 16px 45px rgba(15, 23, 42, 0.08);
}

.topic-panel {
  padding: 14px;
  overflow: hidden;
}

.session-list {
  max-height: calc(100vh - 142px);
  overflow-y: auto;
  padding-right: 2px;
}

.session-item {
  min-height: 48px;
  border-color: #e2e8f0;
  border-radius: 8px;
}

.session-item.active {
  background: #ecfdf5;
  border-color: #86efac;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.session-bar {
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
}

.messages {
  min-height: 0;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.message .bubble {
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}

.message.user .bubble {
  background: #0f766e;
  text-align: left;
}

.message.assistant .bubble {
  background: #ffffff;
  border: 1px solid #e2e8f0;
}

.composer {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "input actions"
    "status status";
  align-items: end;
  padding: 12px;
  background: rgba(248, 250, 252, 0.96);
  border-top: 1px solid #e2e8f0;
}

.input-wrap {
  grid-area: input;
}

.composer-actions {
  grid-area: actions;
}

.voice-status {
  grid-area: status;
  color: #64748b;
}

.attachment-list {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.attachment-chip {
  width: auto;
  min-width: 0;
  max-width: 100%;
  min-height: 30px;
  padding: 0 9px;
  overflow: hidden;
  background: #dbeafe;
  color: #1e3a8a;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

textarea {
  border-color: #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  font: inherit;
  line-height: 1.45;
}

textarea:focus,
input:focus {
  border-color: #0f766e;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
  outline: none;
}

button {
  min-height: 42px;
  border-radius: 8px;
  background: #0f766e;
  font: inherit;
  font-weight: 700;
}

button.secondary {
  background: #e2e8f0;
}

.install-button {
  min-width: 64px;
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.84rem;
}

.refresh-button {
  min-width: 64px;
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.84rem;
}

.install-button[hidden] {
  display: none;
}

.slash-command {
  color: #0f766e;
}

.slash-item.active,
.slash-item:hover {
  background: #f0fdfa;
}

.login-shell {
  width: min(440px, 100%);
  justify-content: center;
}

.login-shell .header {
  display: block;
  text-align: center;
}

.login-panel {
  padding: 18px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: #475569;
  font-size: 0.92rem;
  font-weight: 650;
}

.login-form input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0 12px;
  background: #ffffff;
  color: #111827;
  font: inherit;
}

.login-form button {
  width: 100%;
}

.login-error {
  min-height: 20px;
  color: #b91c1c;
  font-size: 0.9rem;
}

@media (max-width: 760px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body {
    background: #f8fafc;
  }

  .page-shell {
    height: 100dvh;
    min-height: 100dvh;
    padding: 0;
    gap: 0;
  }

  .header {
    min-height: 58px;
    padding: max(10px, env(safe-area-inset-top)) 14px 9px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .header h1 {
    font-size: 1.08rem;
  }

  .header p {
    display: block;
    font-size: 0.78rem;
  }

  .workspace {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-columns: 1fr;
    gap: 0;
  }

  .topic-panel,
  .chat-panel {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .topic-panel {
    min-height: auto;
    padding: 8px 12px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
  }

  .topic-header {
    display: none;
  }

  .session-list {
    display: flex;
    gap: 8px;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 0 3px;
    scrollbar-width: none;
  }

  .session-search {
    display: none;
  }

  .session-list::-webkit-scrollbar {
    display: none;
  }

  .session-item {
    width: auto;
    min-width: 132px;
    max-width: 208px;
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 999px;
    background: #f8fafc;
  }

  .session-count {
    min-width: 22px;
    padding: 2px 6px;
    font-size: 0.7rem;
  }

  .chat-panel {
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: #f8fafc;
  }

  .session-bar {
    padding: 8px 12px;
    gap: 8px;
    background: #ffffff;
  }

  .session-bar span {
    font-size: 0.8rem;
  }

  .toolbar {
    display: flex;
    gap: 6px;
  }

  .command-panel {
    margin: 0;
    border-width: 0 0 1px;
    border-radius: 0;
    box-shadow: none;
  }

  .command-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    overflow-x: auto;
  }

  .command-grid button {
    min-width: 68px;
    font-size: 0.74rem;
  }

  .toolbar button {
    min-width: 44px;
    min-height: 34px;
    padding: 0 9px;
    font-size: 0.78rem;
  }

  .messages {
    padding: 14px 12px 18px;
    background: #f8fafc;
    -webkit-overflow-scrolling: touch;
  }

  .message {
    margin-bottom: 11px;
    line-height: 1.52;
  }

  .message .bubble {
    max-width: 88%;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.95rem;
  }

  .composer {
    grid-template-columns: 40px 40px minmax(0, 1fr) 56px;
    grid-template-areas:
      "attach voice input send"
      "attachments attachments attachments attachments"
      "status status status status";
    gap: 8px;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.98);
  }

  .composer-actions {
    display: contents;
  }

  #voiceButton {
    grid-area: voice;
  }

  #attachButton {
    grid-area: attach;
  }

  #sendButton {
    grid-area: send;
    min-width: 56px;
  }

  .attachment-list {
    grid-area: attachments;
    max-height: 68px;
    overflow-y: auto;
  }

  .attachment-chip {
    max-width: 100%;
    min-height: 28px;
    font-size: 0.74rem;
  }

  .voice-status {
    text-align: left;
    min-height: 16px;
    font-size: 0.78rem;
  }

  textarea {
    min-height: 44px;
    max-height: 132px;
    padding: 10px 11px;
    border-radius: 8px;
    font-size: 16px;
    resize: none;
  }

  button.icon-button {
    width: 40px;
    min-width: 40px;
  }

  .slash-menu {
    max-height: min(42vh, 280px);
  }

  .slash-item {
    grid-template-columns: 86px minmax(0, 1fr);
    padding: 9px;
  }

  .login-shell {
    height: 100dvh;
    padding: 18px;
  }

  .login-shell .header {
    position: static;
    display: block;
    padding: 0;
    margin-bottom: 12px;
    border: 0;
    background: transparent;
  }
}

@media (max-width: 380px) {
  .header p {
    display: none;
  }

  .toolbar button {
    min-width: 38px;
    padding: 0 7px;
  }
}

/* Keep the mobile app shell inside the viewport. */
@media (max-width: 760px) {
  .page-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .header {
    min-height: 50px;
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  }

  .header p {
    max-width: 62vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .install-button {
    min-width: 54px;
    min-height: 30px;
    padding: 0 10px;
    font-size: 0.76rem;
  }

  .refresh-button {
    min-width: 54px;
    min-height: 30px;
    padding: 0 10px;
    font-size: 0.76rem;
  }

  .workspace {
    height: 100%;
    overflow: hidden;
  }

  .topic-panel {
    max-height: 52px;
    overflow: hidden;
    padding: 7px 10px;
  }

  .session-list {
    min-height: 35px;
  }

  .session-item {
    min-height: 34px;
    padding: 6px 10px;
  }

  .chat-panel {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .session-bar {
    min-height: 42px;
    padding: 6px 10px;
  }

  .session-bar span {
    min-width: 0;
  }

  .toolbar {
    flex-shrink: 0;
  }

  .toolbar button {
    min-height: 32px;
  }

  .messages {
    min-height: 0;
    overflow-y: auto;
  }

  .composer {
    align-self: end;
    max-height: 132px;
    overflow: hidden;
    padding: 8px 9px calc(8px + env(safe-area-inset-bottom));
  }

  textarea {
    min-height: 40px;
    max-height: 72px;
    overflow-y: auto;
  }

  .voice-status {
    min-height: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* App-like interaction polish */
:root {
  --app-height: 100dvh;
  --keyboard-inset: 0px;
  -webkit-tap-highlight-color: transparent;
}

button,
.session-item {
  touch-action: manipulation;
  transition:
    transform 120ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

button:active,
.session-item:active {
  transform: scale(0.97);
}

.message {
  animation: messageIn 180ms ease-out both;
}

.pending-message .bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #475569;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #0f766e;
  animation: typingPulse 1s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

.pending-text {
  margin-left: 4px;
  font-size: 0.88rem;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes typingPulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (max-width: 760px) {
  .page-shell {
    height: var(--app-height);
    min-height: var(--app-height);
    width: 100vw;
    max-width: 100vw;
  }

  .header {
    backdrop-filter: blur(14px);
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 6px;
    align-items: center;
    overflow: hidden;
  }

  .header h1,
  .header p {
    min-width: 0;
  }

  .session-list {
    scroll-snap-type: x proximity;
  }

  .session-item {
    scroll-snap-align: start;
  }

  .session-item.active {
    box-shadow: 0 6px 18px rgba(15, 118, 110, 0.16);
  }

  .messages {
    overscroll-behavior: contain;
  }

  .composer {
    box-shadow: 0 -12px 32px rgba(15, 23, 42, 0.08);
  }

  textarea {
    height: auto;
    transition: height 120ms ease;
  }

  #sendButton {
    font-size: 0;
    position: relative;
  }

  #sendButton::before {
    content: "↑";
    font-size: 1.18rem;
    line-height: 1;
  }

  body.keyboard-open .header,
  body.keyboard-open .topic-panel,
  body.keyboard-open .session-bar {
    display: none;
  }

  body.keyboard-open .page-shell {
    grid-template-rows: minmax(0, 1fr);
  }

  body.keyboard-open .workspace {
    grid-template-rows: minmax(0, 1fr);
  }

  body.keyboard-open .chat-panel {
    grid-template-rows: minmax(0, 1fr);
  }

  body.keyboard-open .messages {
    padding-bottom: 112px;
  }

  body.keyboard-open .composer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: max(var(--keyboard-inset), env(safe-area-inset-bottom));
    z-index: 50;
    max-height: 112px;
    border-top: 1px solid #dbe4ef;
  }

  body.keyboard-open textarea {
    max-height: 58px;
  }
}

/* PWA overflow guard: keep narrow standalone windows from expanding. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

@media (max-width: 760px) {
  .header p {
    max-width: none;
  }

  .refresh-button,
  .install-button {
    width: auto;
    min-width: 44px;
    padding: 0 8px;
    white-space: nowrap;
  }

  .settings-panel {
    top: auto;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    max-height: min(78dvh, 620px);
  }

  .install-button[hidden] {
    display: none;
  }

  .workspace,
  .topic-panel,
  .chat-panel,
  .messages,
  .composer,
  .attachment-list {
    min-width: 0;
    max-width: 100vw;
  }
}

@media (max-width: 430px) {
  .header {
    grid-template-columns: auto minmax(0, auto) minmax(0, auto);
  }

  .header p {
    display: none;
  }
}

/* Final PWA frame clamp: prevent nested 100% heights from exceeding the viewport. */
@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
  }

  body {
    position: fixed;
    inset: 0;
  }

  .page-shell {
    position: fixed;
    inset: 0;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: 100%;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .workspace {
    height: auto;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
  }

  .topic-panel {
    flex: none;
  }

  .chat-panel {
    height: auto;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
  }

  .messages {
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
  }

  .composer {
    flex: none;
  }

  body.keyboard-open .page-shell {
    inset: 0;
    height: auto;
    min-height: 0;
  }
}

/* Mobile toolbar clamp: keep Clear/Delete/Logout inside the visible frame. */
@media (max-width: 760px) {
  .session-bar {
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    overflow: visible;
  }

  .session-bar span {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .more-button {
    display: block;
    width: 36px;
    min-width: 36px;
    min-height: 30px;
    padding: 0;
    font-size: 1.15rem;
    line-height: 1;
  }

  .toolbar {
    position: absolute;
    top: calc(100% + 6px);
    right: 10px;
    z-index: 60;
    width: min(220px, calc(100vw - 20px));
    min-width: 0;
    max-width: calc(100vw - 20px);
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #dbe4ef;
    border-radius: 8px;
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 140ms ease, transform 140ms ease;
  }

  body.more-open .toolbar {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .toolbar button {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 36px;
    padding: 0 10px;
    overflow: hidden;
    font-size: 0.86rem;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chat-panel {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
}

/* ChatGPT-like app surface */
.sidebar-button {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 130;
  background: rgba(15, 23, 42, 0.28);
}

.settings-backdrop[hidden],
.settings-panel[hidden] {
  display: none;
}

.settings-panel {
  position: fixed;
  top: 72px;
  right: 18px;
  z-index: 140;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100dvh - 96px);
  display: grid;
  gap: 12px;
  padding: 14px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #d9d9e3;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.settings-panel::after {
  content: "Profile、OSS、本地模型和 add-dir 仅在当前 Codex 子命令支持时透传。";
  display: block;
  padding: 9px 10px;
  border-radius: 8px;
  background: #f8fafc;
  color: #64748b;
  font-size: 0.76rem;
  line-height: 1.45;
}

.settings-head,
.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.settings-panel label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 0.86rem;
  font-weight: 650;
}

.settings-panel input,
.settings-panel select,
.settings-panel textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 9px 10px;
  background: #ffffff;
  color: #111827;
  font: inherit;
}

.settings-panel textarea {
  min-height: 76px;
  resize: vertical;
}

.settings-toggle {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.settings-toggle input {
  width: 22px;
  height: 22px;
}

.settings-panel textarea#settingsAddDirs {
  min-height: 92px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
}

.settings-meta {
  min-height: 18px;
  color: #64748b;
  font-size: 0.78rem;
}

@media (min-width: 761px) {
  body {
    background: #ffffff;
  }

  .page-shell {
    max-width: none;
    padding: 0;
    gap: 0;
  }

  .header {
    height: 54px;
    padding: 0 18px;
    border-bottom: 1px solid #ececf1;
    background: #ffffff;
  }

  .workspace {
    grid-template-columns: 292px minmax(0, 1fr);
    gap: 0;
  }

  .topic-panel {
    border: 0;
    border-right: 1px solid #ececf1;
    border-radius: 0;
    background: #f7f7f8;
    box-shadow: none;
  }

  .chat-panel {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #ffffff;
  }

  .session-bar {
    border-bottom: 1px solid #ececf1;
  }

  .messages {
    width: min(840px, 100%);
    margin: 0 auto;
    background: #ffffff;
  }

  .composer {
    width: min(840px, calc(100% - 32px));
    margin: 0 auto 16px;
    border: 1px solid #d9d9e3;
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  }
}

@media (max-width: 760px) {
  body {
    background: #ffffff;
  }

  .header {
    grid-template-columns: 40px minmax(0, 1fr) auto auto;
    height: 50px;
    min-height: 50px;
    padding: max(6px, env(safe-area-inset-top)) 10px 6px;
    background: #ffffff;
    border-bottom: 1px solid #ececf1;
  }

  .sidebar-button {
    display: block;
    width: 36px;
    min-width: 36px;
    min-height: 34px;
    padding: 0;
    font-size: 1rem;
  }

  .header h1 {
    justify-self: center;
    font-size: 1rem;
    font-weight: 650;
  }

  .header p {
    display: none;
  }

  .refresh-button,
  .install-button {
    min-width: 38px;
    min-height: 30px;
    padding: 0 7px;
    font-size: 0.72rem;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(0, 0, 0, 0.34);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .topic-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 80;
    width: min(84vw, 320px);
    max-height: none;
    padding: max(14px, env(safe-area-inset-top)) 12px 14px;
    border-right: 1px solid #ececf1;
    background: #f7f7f8;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  body.sidebar-open .topic-panel {
    transform: translateX(0);
  }

  .topic-header {
    display: flex;
  }

  .session-list {
    display: grid;
    gap: 6px;
    max-height: calc(100dvh - 70px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0;
  }

  .session-search {
    display: block;
    margin: 8px 0 10px;
  }

  .session-item {
    width: 100%;
    max-width: 100%;
    border-radius: 8px;
    background: transparent;
    border-color: transparent;
  }

  .session-item.active {
    background: #ececf1;
    border-color: transparent;
    box-shadow: none;
  }

  .chat-panel {
    background: #ffffff;
  }

  .session-bar {
    background: #ffffff;
    border-bottom: 1px solid #ececf1;
  }

  .messages {
    background: #ffffff;
    padding: 18px 14px 20px;
  }

  .message .bubble {
    max-width: 92%;
    box-shadow: none;
  }

  .message.assistant .bubble {
    border: 0;
    background: #f7f7f8;
  }

  .message.user .bubble {
    background: #10a37f;
  }

  .composer {
    width: calc(100% - 20px);
    margin: 0 10px calc(8px + env(safe-area-inset-bottom));
    border: 1px solid #d9d9e3;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
  }

  .composer-actions button {
    border-radius: 8px;
  }

  #sendButton {
    background: #10a37f;
  }

  body.keyboard-open .topic-panel {
    display: block;
  }

  body.keyboard-open .composer {
    width: calc(100% - 20px);
    left: 10px;
    right: 10px;
    margin: 0;
  }
}

/* Final mobile layout reset: one stable app frame, no hidden primary controls. */
@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  body {
    position: fixed;
    inset: 0;
    background: #ffffff;
  }

  .page-shell {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100svh;
    min-height: 0;
    max-height: 100svh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 0;
    overflow: hidden;
  }

  @supports (height: 100dvh) {
    .page-shell {
      height: 100dvh;
      max-height: 100dvh;
    }
  }

  .header {
    position: relative;
    z-index: 20;
    height: auto;
    min-height: 48px;
    max-height: 56px;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 6px;
    padding: max(6px, env(safe-area-inset-top)) 10px 6px;
    overflow: hidden;
  }

  .header h1 {
    min-width: 0;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header p {
    display: none;
  }

  .workspace {
    height: auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
  }

  .chat-panel {
    height: auto;
    min-height: 0;
    max-height: none;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
  }

  .session-bar {
    position: relative;
    z-index: 15;
    min-height: 38px;
    max-height: 44px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    overflow: visible;
  }

  .messages {
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    padding: 14px 14px 18px;
  }

  .composer {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    z-index: 10;
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    max-height: 168px;
    margin: 0 10px calc(8px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: 34px 34px minmax(0, 1fr) 48px;
    grid-template-areas:
      "attach voice input send"
      "attachments attachments attachments attachments"
      "status status status status";
    gap: 6px;
    padding: 8px;
    overflow: hidden;
  }

  #attachButton {
    grid-area: attach;
  }

  #voiceButton {
    grid-area: voice;
  }

  .input-wrap {
    grid-area: input;
    min-width: 0;
  }

  #sendButton {
    grid-area: send;
    min-width: 48px;
  }

  .composer-actions {
    display: contents;
  }

  .icon-button,
  button.icon-button {
    width: 34px;
    min-width: 34px;
    min-height: 34px;
    padding: 0;
  }

  textarea {
    min-height: 34px;
    max-height: 72px;
    padding: 7px 9px;
    overflow-y: auto;
  }

  .attachment-list {
    grid-area: attachments;
    max-height: 44px;
    overflow-y: auto;
  }

  .voice-status {
    grid-area: status;
    min-height: 14px;
    max-height: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topic-panel {
    display: block;
    height: auto;
    max-height: none;
  }

  body:not(.sidebar-open) .topic-panel {
    pointer-events: none;
  }

  body.keyboard-open .header,
  body.keyboard-open .topic-panel,
  body.keyboard-open .session-bar {
    display: none;
  }

  body.keyboard-open .page-shell {
    grid-template-rows: minmax(0, 1fr);
  }

  body.keyboard-open .workspace,
  body.keyboard-open .chat-panel {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  body.keyboard-open .composer {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: max(var(--keyboard-inset), env(safe-area-inset-bottom));
    width: calc(100vw - 20px);
    margin: 0;
  }

  body.keyboard-open .messages {
    padding-bottom: 96px;
  }

  .slash-menu {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(96px + env(safe-area-inset-bottom));
    z-index: 120;
    max-height: min(46vh, 320px);
    overflow-y: auto;
    border: 1px solid #d9d9e3;
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
  }

  body.keyboard-open .slash-menu {
    bottom: calc(max(var(--keyboard-inset), env(safe-area-inset-bottom)) + 86px);
  }

  .slash-item {
    grid-template-columns: 92px minmax(0, 1fr);
    min-height: 42px;
  }

}

/* Button alignment pass: keep app controls compact and consistently centered. */
.header button,
.toolbar button,
.command-panel button,
.composer-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  white-space: nowrap;
}

.toolbar {
  align-items: center;
  justify-content: flex-end;
}

.toolbar button {
  width: auto;
  min-width: 66px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.header .refresh-button,
.header .install-button {
  width: auto;
  min-width: 56px;
  min-height: 34px;
  padding: 0 12px;
}

@media (max-width: 760px) {
  .header {
    grid-template-columns: 48px minmax(0, 1fr) auto auto auto;
    min-height: 54px;
    max-height: none;
    gap: 7px;
    padding: max(7px, env(safe-area-inset-top)) 10px 7px;
  }

  .sidebar-button {
    width: 44px;
    min-width: 44px;
    min-height: 42px;
    border-radius: 10px;
    font-size: 1.26rem;
  }

  .header .refresh-button,
  .header .install-button {
    min-width: 44px;
    min-height: 36px;
    padding: 0 9px;
    font-size: 0.78rem;
  }

  .session-bar {
    grid-template-columns: minmax(0, 1fr) 42px;
    min-height: 44px;
  }

  .more-button {
    width: 40px;
    min-width: 40px;
    min-height: 36px;
    border-radius: 10px;
    font-size: 1.24rem;
  }

  .toolbar button {
    min-height: 38px;
    text-align: center;
  }
}

@media (max-width: 430px) {
  .header {
    grid-template-columns: 48px minmax(0, 1fr) auto auto;
  }

  .header .install-button[hidden] {
    display: none;
  }

  .header .refresh-button {
    min-width: 42px;
    padding: 0 8px;
  }
}

@media (max-width: 360px) {
  .header h1 {
    font-size: 0.94rem;
  }

  .header .refresh-button {
    font-size: 0.72rem;
    min-width: 38px;
    padding: 0 7px;
  }
}

/* PWA interaction layer: mobile-first app chrome and bottom sheets. */
@media (max-width: 760px) {
  body {
    background: #f6f7f9;
  }

  body.standalone-app .header {
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .header {
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid rgba(217, 217, 227, 0.9);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
    backdrop-filter: blur(18px);
  }

  .header h1 {
    font-weight: 760;
    letter-spacing: 0;
  }

  .header .refresh-button,
  .header .install-button,
  .sidebar-button,
  .more-button {
    background: #f1f5f9;
    color: #0f172a;
    border: 1px solid #e2e8f0;
    box-shadow: none;
  }

  .sidebar-button:active,
  .more-button:active,
  .header .refresh-button:active {
    background: #e2e8f0;
  }

  .session-bar {
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
  }

  .session-bar span {
    color: #475569;
    font-size: 0.82rem;
  }

  .messages {
    background:
      linear-gradient(180deg, #ffffff 0%, #f8fafc 40%, #f6f7f9 100%);
    padding-bottom: 22px;
  }

  .message .bubble {
    border-radius: 14px;
  }

  .message.assistant .bubble {
    background: #ffffff;
    border: 1px solid #edf0f4;
  }

  .message.user .bubble {
    background: #0f766e;
  }

  .composer {
    border-color: #d9e0e8;
    border-radius: 18px;
    box-shadow: 0 16px 38px rgba(15, 23, 42, 0.15);
  }

  .composer .icon-button,
  #sendButton {
    border-radius: 14px;
  }

  #sendButton {
    min-width: 48px;
    box-shadow: 0 8px 20px rgba(15, 118, 110, 0.24);
  }

  textarea {
    border: 0;
    background: #f8fafc;
  }

  textarea:focus {
    box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.28);
  }

  body.more-open::before,
  body.command-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(15, 23, 42, 0.22);
    pointer-events: none;
  }

  .toolbar {
    position: fixed;
    left: 10px;
    right: 10px;
    top: auto;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 90;
    width: auto;
    max-width: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 12px;
    border-radius: 18px;
    border-color: #e2e8f0;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
    transform: translateY(16px);
  }

  body.more-open .toolbar {
    transform: translateY(0);
  }

  .toolbar button {
    min-height: 44px;
    border-radius: 12px;
    background: #f8fafc;
    text-align: center;
    justify-content: center;
  }

  .toolbar button.danger {
    background: #fee2e2;
  }

  .command-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 95;
    margin: 0;
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.26);
    transform: translateY(0);
  }

  body.command-open::before {
    display: none;
  }

  body.command-open .command-panel {
    z-index: 200;
    pointer-events: auto;
  }

  .command-panel-head {
    min-height: 34px;
  }

  .command-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 190px;
    overflow-y: auto;
  }

  .command-grid button {
    min-height: 42px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
  }

  .command-runner {
    grid-template-columns: minmax(0, 1fr) 64px;
  }

  .command-runner input {
    min-height: 42px;
    border-radius: 12px;
  }

  .settings-panel {
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -22px 70px rgba(15, 23, 42, 0.24);
  }

  .slash-menu {
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.22);
  }
}

@media (min-width: 761px) {
  .header button {
    min-height: 36px;
  }

  .toolbar button {
    min-width: 72px;
  }

  .command-panel {
    width: min(840px, calc(100% - 32px));
    margin: 10px auto 0;
  }
}

/* Feishu-inspired composer: input card, chips, and tool rail. */
.composer {
  position: relative;
  gap: 0;
  padding: 10px;
  background: #ffffff;
  border: 1px solid #d8dee8;
  border-radius: 14px;
  box-shadow:
    0 18px 48px rgba(15, 23, 42, 0.10),
    0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.composer:focus-within {
  border-color: #7dd3c7;
  box-shadow:
    0 20px 52px rgba(15, 23, 42, 0.13),
    0 0 0 3px rgba(15, 118, 110, 0.10);
}

.composer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 2px 8px;
}

.composer-meta span {
  min-width: 0;
  max-width: 100%;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  overflow: hidden;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.76rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-meta span:first-child {
  background: #ecfdf5;
  color: #0f766e;
}

.composer-meta span[hidden] {
  display: none !important;
}

.composer-meta .work-timer-chip {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
  font-variant-numeric: tabular-nums;
}

.composer .input-wrap {
  padding: 2px 2px 8px;
}

.composer textarea {
  min-height: 74px;
  max-height: 180px;
  border: 0;
  border-radius: 10px;
  padding: 10px 8px;
  background: #ffffff;
  color: #0f172a;
  line-height: 1.52;
}

.composer textarea:focus {
  box-shadow: none;
}

.composer-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid #edf1f6;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.composer-tools::-webkit-scrollbar {
  display: none;
}

.tool-button {
  width: auto;
  min-width: 0;
  min-height: 34px;
  flex: 0 0 auto;
  border-radius: 10px;
  padding: 0 10px;
  background: #f8fafc;
  color: #334155;
  border: 1px solid #e2e8f0;
  font-size: 0.84rem;
}

.tool-button:hover {
  background: #eef2f7;
}

.tool-button.listening {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}

#recordSendButton.recording {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
  font-variant-numeric: tabular-nums;
}

.composer #sendButton {
  width: auto;
  min-width: 74px;
  min-height: 38px;
  border-radius: 11px;
  padding: 0 16px;
  background: #0f766e;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.20);
}

.composer #sendButton.cancel {
  background: #dc2626;
  box-shadow: 0 10px 24px rgba(220, 38, 38, 0.18);
}

.attachment-list {
  padding-top: 8px;
}

.voice-status {
  padding-top: 6px;
  text-align: left;
}

@media (max-width: 760px) {
  .composer {
    width: auto;
    max-width: calc(100vw - 28px);
    max-height: 214px;
    margin: 0 14px calc(10px + env(safe-area-inset-bottom));
    padding: 10px 12px 10px 10px;
    border-radius: 16px;
    grid-template-columns: 1fr;
    grid-template-areas:
      "meta"
      "input"
      "actions"
      "attachments"
      "status";
    gap: 0;
  }

  .composer-meta {
    grid-area: meta;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: none;
  }

  .composer-meta::-webkit-scrollbar {
    display: none;
  }

  .composer-meta span {
    flex: 0 0 auto;
    max-width: 180px;
  }

  .composer .input-wrap {
    grid-area: input;
    padding-bottom: 6px;
  }

  .composer textarea {
    min-height: 54px;
    max-height: 86px;
    padding: 8px 4px;
  }

  .composer-actions {
    grid-area: actions;
    grid-template-columns: minmax(0, 1fr) 48px;
    gap: 10px;
    min-width: 0;
    padding-top: 7px;
    overflow: hidden;
  }

  .composer-tools {
    min-width: 0;
    max-width: 100%;
    gap: 5px;
    overflow-x: auto;
    padding-right: 2px;
  }

  .tool-button {
    min-height: 32px;
    max-width: 76px;
    padding: 0 8px;
    overflow: hidden;
    font-size: 0.76rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .composer #sendButton {
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    min-height: 36px;
    padding: 0;
    font-size: 0;
    justify-self: end;
  }

  .composer #sendButton::before {
    content: "↑";
    font-size: 1.12rem;
    line-height: 1;
  }

  .attachment-list {
    grid-area: attachments;
    max-height: 42px;
    padding-top: 6px;
  }

  .voice-status {
    grid-area: status;
    min-height: 16px;
    max-height: 18px;
    padding-top: 4px;
    font-size: 0.76rem;
  }

  body.keyboard-open .composer {
    width: auto;
    left: 14px;
    right: 14px;
    max-height: 190px;
  }

  body.keyboard-open .messages {
    padding-bottom: 150px;
  }

  body.keyboard-open .slash-menu {
    bottom: calc(max(var(--keyboard-inset), env(safe-area-inset-bottom)) + 150px);
  }
}

@media (max-width: 380px) {
  .composer-actions {
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 8px;
  }

  .tool-button {
    max-width: 64px;
    padding: 0 7px;
    font-size: 0.72rem;
  }

  .composer #sendButton {
    width: 42px;
    min-width: 42px;
    max-width: 42px;
  }
}

/* Final override: keep the mobile send button large and inside the composer. */
@media (max-width: 760px) {
  .composer {
    width: auto !important;
    max-width: none !important;
    margin-left: 16px !important;
    margin-right: 16px !important;
    padding: 10px 12px !important;
    box-sizing: border-box;
    overflow: hidden;
  }

  .composer-actions {
    grid-template-columns: minmax(0, 1fr) 56px !important;
    gap: 8px !important;
    overflow: visible !important;
  }

  .composer-tools {
    min-width: 0 !important;
    overflow-x: auto !important;
    padding-right: 0 !important;
  }

  .tool-button {
    min-height: 34px !important;
    max-width: 72px !important;
  }

  .composer #sendButton {
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    min-height: 42px !important;
    border-radius: 14px !important;
    justify-self: end;
  }

  .composer #sendButton::before {
    font-size: 1.28rem !important;
  }

  body.keyboard-open .composer {
    left: 16px !important;
    right: 16px !important;
    width: auto !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

@media (max-width: 380px) {
  .composer {
    margin-left: 12px !important;
    margin-right: 12px !important;
    padding: 9px 10px !important;
  }

  .composer-actions {
    grid-template-columns: minmax(0, 1fr) 52px !important;
    gap: 7px !important;
  }

  .tool-button {
    max-width: 62px !important;
  }

  .composer #sendButton {
    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
    min-height: 40px !important;
  }

  body.keyboard-open .composer {
    left: 12px !important;
    right: 12px !important;
  }
}

/* Hard fix: send button is anchored inside the composer action row, not part of the scrollable tools. */
@media (max-width: 760px) {
  .composer {
    position: relative !important;
    margin-left: 16px !important;
    margin-right: 16px !important;
    padding: 10px 12px !important;
    overflow: hidden !important;
  }

  .composer-actions {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    min-width: 0 !important;
    padding-right: 64px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
  }

  .composer-tools {
    flex: 1 1 auto !important;
    width: auto !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
  }

  .composer #sendButton {
    grid-area: auto !important;
    position: absolute !important;
    top: 50% !important;
    right: 0 !important;
    transform: translateY(-50%) !important;
    width: 56px !important;
    min-width: 56px !important;
    max-width: 56px !important;
    height: 44px !important;
    min-height: 44px !important;
    border-radius: 14px !important;
    padding: 0 !important;
    z-index: 2 !important;
  }

  .composer #sendButton:active {
    transform: translateY(-50%) scale(0.96) !important;
  }
}

@media (max-width: 380px) {
  .composer {
    margin-left: 12px !important;
    margin-right: 12px !important;
    padding: 9px 10px !important;
  }

  .composer-actions {
    padding-right: 58px !important;
  }

  .composer #sendButton {
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    height: 42px !important;
    min-height: 42px !important;
  }
}

/* Hard fix: make the top-right More menu visible and clickable when opened. */
@media (max-width: 760px) {
  body.more-open::before {
    display: none !important;
  }

  body.more-open .toolbar {
    display: grid !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    position: fixed !important;
    left: 12px !important;
    right: 12px !important;
    top: auto !important;
    bottom: calc(14px + env(safe-area-inset-bottom)) !important;
    z-index: 220 !important;
    width: auto !important;
    max-width: none !important;
    transform: translateY(0) !important;
  }

  body.more-open .toolbar button {
    pointer-events: auto !important;
  }
}

/* More menu is now session management only. */
@media (max-width: 760px) {
  body.more-open .toolbar {
    grid-template-columns: 1fr !important;
  }

  body.more-open .toolbar button {
    justify-content: flex-start !important;
    min-height: 46px !important;
    padding: 0 14px !important;
    text-align: left !important;
  }
}

/* More menu contrast fix. */
@media (max-width: 760px) {
  body.more-open .toolbar button {
    background: #f8fafc !important;
    color: #0f172a !important;
    border: 1px solid #e2e8f0 !important;
    font-weight: 700 !important;
  }

  body.more-open .toolbar button:hover,
  body.more-open .toolbar button:active {
    background: #eef2f7 !important;
    color: #0f172a !important;
  }

  body.more-open .toolbar button.danger {
    background: #fee2e2 !important;
    color: #991b1b !important;
    border-color: #fecaca !important;
  }

  body.more-open .toolbar button.secondary {
    background: #f1f5f9 !important;
    color: #334155 !important;
  }
}

/* More menu sizing: compact anchored sheet instead of full-width bottom container. */
@media (max-width: 760px) {
  body.more-open .toolbar {
    left: auto !important;
    right: 12px !important;
    bottom: calc(76px + env(safe-area-inset-bottom)) !important;
    width: min(232px, calc(100vw - 24px)) !important;
    max-width: min(232px, calc(100vw - 24px)) !important;
    padding: 8px !important;
    gap: 6px !important;
    border-radius: 14px !important;
    box-shadow: 0 18px 46px rgba(15, 23, 42, 0.20) !important;
  }

  body.more-open .toolbar button {
    min-height: 40px !important;
    padding: 0 12px !important;
    border-radius: 10px !important;
    font-size: 0.86rem !important;
  }
}

@media (max-width: 380px) {
  body.more-open .toolbar {
    right: 10px !important;
    width: min(216px, calc(100vw - 20px)) !important;
    max-width: min(216px, calc(100vw - 20px)) !important;
  }
}

/* More menu final interaction: expand one compact action row under the session bar. */
@media (max-width: 760px) {
  body.more-open::before {
    display: none !important;
  }

  .session-bar {
    grid-template-columns: minmax(0, 1fr) 44px !important;
    align-items: center !important;
    padding: 6px 10px 0 !important;
    gap: 8px !important;
    overflow: visible !important;
  }

  .more-button {
    width: 44px !important;
    min-width: 44px !important;
    min-height: 36px !important;
    border-radius: 12px !important;
  }

  .toolbar,
  body.more-open .toolbar {
    position: static !important;
    grid-column: 1 / -1 !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: none !important;
    transition: max-height 160ms ease, opacity 120ms ease, padding 160ms ease !important;
    -webkit-overflow-scrolling: touch;
  }

  body.more-open .toolbar {
    max-height: 48px !important;
    padding: 4px 0 8px !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .toolbar button,
  body.more-open .toolbar button {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 78px !important;
    min-height: 36px !important;
    padding: 0 12px !important;
    border-radius: 999px !important;
    justify-content: center !important;
    text-align: center !important;
    font-size: 0.84rem !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
  }
}

@media (max-width: 380px) {
  body.more-open .toolbar {
    max-height: 46px !important;
  }

  .toolbar button,
  body.more-open .toolbar button {
    min-width: 72px !important;
    min-height: 34px !important;
    padding: 0 10px !important;
    font-size: 0.8rem !important;
  }
}

/* More menu layout correction: the action row must occupy real vertical space. */
@media (max-width: 760px) {
  .session-bar {
    max-height: none !important;
    grid-template-rows: auto 0fr !important;
    transition: padding-bottom 160ms ease !important;
  }

  body.more-open .session-bar {
    grid-template-rows: auto auto !important;
    padding-bottom: 8px !important;
  }

  .toolbar,
  body.more-open .toolbar {
    min-height: 0 !important;
    box-sizing: border-box !important;
  }

  body.more-open .toolbar {
    margin-top: 4px !important;
    padding: 8px 0 0 !important;
    border-top: 1px solid #e2e8f0 !important;
  }

  .messages {
    position: relative !important;
    z-index: 1 !important;
  }
}

/* App-style composer based on the attached mobile references. */
.composer-input-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: stretch;
}

.voice-keyboard-button,
.hold-voice-button,
.expand-input-button {
  display: none;
}

.composer .input-wrap {
  position: relative;
  min-width: 0;
}

.composer .expand-input-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #64748b;
  font-size: 1.2rem;
}

.composer .expand-input-button:hover,
.composer .expand-input-button:active {
  background: #f1f5f9;
  color: #0f172a;
}

.composer.voice-mode .composer-meta {
  display: none;
}

.composer.voice-mode .composer-input-row {
  grid-template-columns: 56px minmax(0, 1fr);
}

.composer.voice-mode .voice-keyboard-button {
  display: inline-flex;
  width: 56px;
  min-width: 56px;
  height: 56px;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: #ffffff;
  color: #64748b;
  border: 1px solid #e5e7eb;
  font-size: 1.45rem;
}

.composer.voice-mode textarea,
.composer.voice-mode .expand-input-button,
.composer.voice-mode .composer-actions {
  display: none !important;
}

.composer.voice-mode .hold-voice-button {
  display: inline-flex;
  width: 100%;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 14px;
  background: #ffffff;
  color: #111827;
  font-size: 1.08rem;
  font-weight: 750;
  letter-spacing: 0;
  touch-action: none;
}

.composer.voice-mode .hold-voice-button:active {
  background: #ecfdf5;
  color: #0f766e;
  transform: scale(0.99);
}

@media (max-width: 760px) {
  .composer {
    background: #f4f6f8 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom)) !important;
    margin: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .composer .composer-meta {
    padding: 0 0 8px !important;
  }

  .composer-input-row {
    grid-area: input !important;
  }

  .composer .input-wrap {
    padding: 0 !important;
    border-radius: 18px;
    background: #ffffff;
  }

  .composer textarea {
    width: 100% !important;
    min-height: 58px !important;
    max-height: 126px !important;
    padding: 16px 54px 16px 18px !important;
    border: 0 !important;
    border-radius: 18px !important;
    background: #ffffff !important;
    color: #0f172a !important;
    font-size: 16px !important;
    line-height: 1.45 !important;
  }

  .composer.composer-expanded textarea {
    min-height: 132px !important;
    max-height: 38vh !important;
  }

  .composer .expand-input-button {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  .composer-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 50px !important;
    gap: 10px !important;
    align-items: center !important;
    padding: 16px 2px 0 !important;
    border-top: 0 !important;
    overflow: visible !important;
  }

  .composer-tools {
    justify-content: space-between !important;
    gap: 14px !important;
    padding: 0 !important;
    overflow-x: auto !important;
  }

  .composer .app-tool-button,
  .composer .tool-button {
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    color: #5f6775 !important;
    font-size: 1.45rem !important;
    font-weight: 650 !important;
    line-height: 1 !important;
  }

  .composer .app-tool-button:active,
  .composer .tool-button:active,
  .composer .tool-button.active {
    background: #e9eef5 !important;
    color: #0f172a !important;
  }

  .composer #sendButton {
    position: static !important;
    transform: none !important;
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    height: 42px !important;
    min-height: 42px !important;
    border-radius: 14px !important;
    padding: 0 !important;
    justify-self: end !important;
  }

  .composer #sendButton:active {
    transform: scale(0.96) !important;
  }

  .composer.voice-mode {
    display: grid !important;
    gap: 0 !important;
  }

  .composer.voice-mode .composer-input-row {
    display: grid !important;
    grid-template-columns: 56px minmax(0, 1fr) !important;
    gap: 10px !important;
  }

  .composer.voice-mode .input-wrap {
    background: transparent !important;
  }

  .composer.voice-mode .voice-keyboard-button,
  .composer.voice-mode .hold-voice-button {
    min-height: 58px !important;
    border-radius: 16px !important;
    box-shadow: none !important;
  }

  .composer.voice-mode .voice-status {
    margin-top: 8px;
  }
}

@media (max-width: 380px) {
  .composer-tools {
    gap: 8px !important;
  }

  .composer .app-tool-button,
  .composer .tool-button {
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    font-size: 1.28rem !important;
  }

  .composer.voice-mode .composer-input-row {
    grid-template-columns: 52px minmax(0, 1fr) !important;
  }
}

/* Composer interaction correction: prevent tool buttons from wrapping or squeezing. */
@media (max-width: 760px) {
  .composer {
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom)) !important;
  }

  .composer .composer-meta {
    flex-wrap: nowrap !important;
    min-height: 24px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
  }

  .composer textarea {
    min-height: 52px !important;
    max-height: 112px !important;
    padding: 14px 50px 14px 16px !important;
  }

  .composer .expand-input-button {
    top: 7px !important;
    right: 8px !important;
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
  }

  .composer-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 44px !important;
    gap: 8px !important;
    padding: 12px 0 0 !important;
  }

  .composer-tools {
    display: grid !important;
    grid-template-columns: repeat(5, 42px) !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 0 !important;
    min-width: 0 !important;
    width: 100% !important;
    overflow: hidden !important;
  }

  .composer .app-tool-button,
  .composer .tool-button {
    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    font-size: 1.22rem !important;
    overflow: hidden !important;
    white-space: nowrap !important;
  }

  .composer #sendButton {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 38px !important;
    min-height: 38px !important;
    border-radius: 13px !important;
  }

  .composer.voice-mode .composer-input-row {
    grid-template-columns: 52px minmax(0, 1fr) !important;
    gap: 8px !important;
  }

  .composer.voice-mode .voice-keyboard-button,
  .composer.voice-mode .hold-voice-button {
    min-height: 54px !important;
  }
}

@media (max-width: 380px) {
  .composer {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .composer-actions {
    grid-template-columns: minmax(0, 1fr) 40px !important;
    gap: 6px !important;
  }

  .composer-tools {
    grid-template-columns: repeat(5, 38px) !important;
  }

  .composer .app-tool-button,
  .composer .tool-button {
    width: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    height: 34px !important;
    min-height: 34px !important;
    font-size: 1.08rem !important;
  }

  .composer #sendButton {
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    height: 36px !important;
    min-height: 36px !important;
  }
}

/* Composer layout reset after visual inspection: send lives inside input, tools own one row. */
@media (max-width: 760px) {
  .composer {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "meta"
      "input"
      "actions"
      "attachments"
      "status" !important;
    gap: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  .composer .input-wrap {
    position: relative !important;
    min-height: 96px !important;
    overflow: hidden !important;
  }

  .composer textarea {
    min-height: 96px !important;
    max-height: 126px !important;
    padding: 14px 56px 42px 16px !important;
    overflow-y: auto !important;
    resize: none !important;
  }

  .composer .expand-input-button {
    top: 8px !important;
    right: 8px !important;
    color: #6b7280 !important;
  }

  .composer #sendButton {
    position: absolute !important;
    right: 10px !important;
    bottom: 10px !important;
    top: auto !important;
    transform: none !important;
    z-index: 4 !important;
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    height: 38px !important;
    min-height: 38px !important;
    border-radius: 13px !important;
  }

  .composer #sendButton:active {
    transform: scale(0.96) !important;
  }

  .composer-actions {
    grid-template-columns: minmax(0, 1fr) !important;
    padding: 14px 4px 0 !important;
    min-height: 42px !important;
  }

  .composer-tools {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    column-gap: 4px !important;
    width: 100% !important;
    min-width: 0 !important;
    overflow: visible !important;
  }

  .composer-tools > button,
  .composer #voiceButton,
  .composer #attachButton,
  .composer #composerSettingsButton,
  .composer #composerCommandButton {
    grid-area: auto !important;
  }

  .composer .app-tool-button,
  .composer .tool-button {
    justify-self: center !important;
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    font-size: 1rem !important;
    font-weight: 750 !important;
    line-height: 1 !important;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
  }

  .composer.voice-mode .input-wrap {
    min-height: 0 !important;
    overflow: visible !important;
  }

  .composer.voice-mode #sendButton {
    display: none !important;
  }
}

@media (max-width: 380px) {
  .composer .app-tool-button,
  .composer .tool-button {
    width: 34px !important;
    min-width: 34px !important;
    max-width: 34px !important;
    height: 36px !important;
    min-height: 36px !important;
    font-size: 0.9rem !important;
  }
}

/* iOS/PWA hard reset: every composer section spans the full row. */
@media (max-width: 900px) {
  .composer {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .composer-meta,
  .composer-input-row,
  .composer-actions,
  .attachment-list,
  .voice-status {
    grid-column: 1 / -1 !important;
    justify-self: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .composer-input-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .composer.voice-mode .composer-input-row {
    grid-template-columns: 52px minmax(0, 1fr) !important;
  }

  .composer .input-wrap {
    grid-area: auto !important;
    grid-column: 1 / -1 !important;
    width: 100% !important;
    max-width: 100% !important;
    justify-self: stretch !important;
  }

  .composer.voice-mode .input-wrap {
    grid-column: auto !important;
  }

  .composer-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .composer-tools > button {
    grid-area: auto !important;
    position: relative !important;
    inset: auto !important;
  }
}

/* Voice review overlay: live speech text first, editable confirmation after release. */
.voice-review-overlay[hidden] {
  display: none !important;
}

.voice-review-overlay {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.24);
  backdrop-filter: blur(6px);
}

.voice-review-panel {
  width: min(520px, 100%);
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.26);
}

.voice-review-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.voice-review-head strong {
  color: #0f172a;
  font-size: 1rem;
}

.voice-review-head span {
  color: #64748b;
  font-size: 0.82rem;
}

.voice-review-panel textarea {
  width: 100%;
  min-height: 132px;
  max-height: 36vh;
  padding: 12px;
  border: 1px solid #dbe4ef;
  border-radius: 14px;
  background: #f8fafc;
  color: #0f172a;
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  resize: vertical;
}

.voice-review-panel textarea:focus {
  outline: none;
  border-color: #0f766e;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.voice-review-overlay.listening .voice-review-panel {
  border-color: #99f6e4;
}

.voice-review-overlay.transcribing .voice-review-panel {
  border-color: #bfdbfe;
}

.voice-review-overlay.listening .voice-review-head strong::before {
  content: "";
  width: 8px;
  height: 8px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 50%;
  background: #14b8a6;
  box-shadow: 0 0 0 5px rgba(20, 184, 166, 0.14);
}

.voice-review-overlay.transcribing .voice-review-head strong::before {
  content: "";
  width: 8px;
  height: 8px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.14);
}

.voice-review-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.voice-review-actions button {
  min-height: 42px;
  border-radius: 12px;
}

@media (max-width: 760px) {
  .voice-review-overlay {
    align-items: center;
    padding: 14px;
  }

  .voice-review-panel {
    border-radius: 18px;
    padding: 14px;
  }

  .voice-review-panel textarea {
    min-height: 150px;
  }
}

/* Clear press-and-hold recording feedback. */
.composer.voice-mode .hold-voice-button {
  position: relative;
  overflow: hidden;
  gap: 8px;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.composer.voice-mode .hold-voice-button::before {
  content: "";
  width: 9px;
  height: 9px;
  display: none;
  border-radius: 999px;
  background: currentColor;
}

.composer.voice-mode .hold-voice-button.recording {
  background: #0f766e !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 6px rgba(15, 118, 110, 0.14), 0 14px 32px rgba(15, 118, 110, 0.28);
  transform: scale(0.985);
}

.composer.voice-mode .hold-voice-button.recording::before {
  display: inline-block;
  animation: voice-recording-dot 850ms ease-in-out infinite;
}

.composer.voice-mode .hold-voice-button.recording::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  transform: translateX(-100%);
  animation: voice-recording-sheen 1.4s linear infinite;
  pointer-events: none;
}

.voice-review-overlay.listening {
  background: rgba(15, 118, 110, 0.18);
}

.voice-review-overlay.listening .voice-review-panel {
  box-shadow: 0 24px 80px rgba(15, 118, 110, 0.24);
}

.voice-review-overlay.listening .voice-review-head span {
  color: #0f766e;
  font-weight: 700;
}

@keyframes voice-recording-dot {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1.28);
  }
}

@keyframes voice-recording-sheen {
  to {
    transform: translateX(100%);
  }
}

/* Streaming Codex work trace, visually separate from the final answer. */
.work-message .work-bubble {
  width: min(760px, 100%);
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-left: 4px solid #0f766e;
  background: #f8fafc;
  color: #334155;
  box-shadow: none;
}

.work-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.work-title {
  color: #0f766e;
  font-size: 0.82rem;
  font-weight: 800;
}

.work-meta {
  color: #64748b;
  font-size: 0.76rem;
  white-space: nowrap;
}

.work-body {
  max-height: 220px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #475569;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.55;
}

.work-message.done .work-bubble {
  border-left-color: #94a3b8;
  background: #f8fafc;
}

.work-message.done .work-title,
.work-message.done .work-meta {
  color: #64748b;
}

@media (max-width: 760px) {
  .work-message .work-bubble {
    max-width: 100%;
    padding: 11px 12px;
  }

  .work-body {
    max-height: 180px;
    font-size: 0.76rem;
  }
}
