:root {
  color-scheme: light;
  --bg: #f4f5f1;
  --panel: #ffffff;
  --sidebar: #111315;
  --sidebar-hover: #1c1f22;
  --sidebar-active: #272b2f;
  --sidebar-text: #f0f2f2;
  --sidebar-muted: #a0a7ad;
  --line: #d9dcd3;
  --sidebar-line: #25292d;
  --text: #20231f;
  --muted: #687064;
  --accent: #136f63;
  --accent-strong: #0d4f48;
  --warn: #a43e32;
  --shadow: 0 8px 28px rgba(32, 35, 31, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.is-hidden {
  display: none !important;
}

.auth-loading-screen,
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--sidebar);
}

.auth-loading-screen {
  color: var(--sidebar-text);
}

.auth-loading-panel {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.auth-loading-panel h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
  color: #ffffff;
}

.auth-loading-panel p {
  margin: 0;
  color: var(--sidebar-muted);
  font-size: 14px;
}

.auth-loading-mark {
  position: relative;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
}

.auth-loading-mark::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: auth-loading-spin 1s linear infinite;
}

.auth-loading-mark span {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #ffffff;
  opacity: 0.9;
  animation: auth-loading-pulse 1.2s ease-in-out infinite;
}

.auth-loading-mark span:nth-child(1) {
  transform: translate(-18px, 12px);
}

.auth-loading-mark span:nth-child(2) {
  transform: translate(0, -16px);
  animation-delay: 0.15s;
}

.auth-loading-mark span:nth-child(3) {
  transform: translate(18px, 12px);
  animation-delay: 0.3s;
}

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

@keyframes auth-loading-pulse {
  0%,
  100% {
    scale: 0.72;
    opacity: 0.45;
  }

  50% {
    scale: 1;
    opacity: 1;
  }
}

.login-panel {
  width: min(100%, 380px);
  display: grid;
  gap: 12px;
  padding: 28px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.login-panel p {
  margin: 0 0 6px;
  color: var(--muted);
}

.login-panel label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.sidebar-action-button,
.logout-button {
  border: 1px solid var(--accent);
  border-radius: 8px;
  cursor: pointer;
}

.google-signin-button {
  min-height: 44px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.google-signin-button > div,
.google-signin-button iframe {
  max-width: 100%;
}

.line-signin-button {
  min-height: 44px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: #06c755;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
}

.line-signin-button:hover {
  background: #05b64e;
}

.line-signin-mark {
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 11px;
  line-height: 1;
}

.login-error {
  min-height: 20px;
  color: var(--warn);
  font-size: 13px;
}

@media (max-width: 420px) {
  .login-screen {
    padding: 16px;
  }

  .login-panel {
    padding: 22px;
  }
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar-toggle,
.sidebar-backdrop {
  display: none;
}

.sidebar-toggle,
.sidebar-refresh-button,
.usage-refresh-button {
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  user-select: none;
}

.sidebar {
  border-right: 1px solid var(--sidebar-line);
  background: var(--sidebar);
  color: var(--sidebar-text);
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px 8px;
}

.brand-row h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 850;
  line-height: 1.1;
  letter-spacing: 0;
  color: #f8fbf8;
  text-shadow: 0 0 12px rgba(120, 199, 184, 0.28);
  animation: brand-title-motion 3.8s ease-in-out infinite;
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-row p {
  margin: 4px 0 0;
  color: var(--sidebar-muted);
  font-size: 13px;
}

.sidebar-refresh-button,
.usage-refresh-button {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-muted);
  cursor: pointer;
}

.sidebar-refresh-button:hover:not(:disabled),
.usage-refresh-button:hover:not(:disabled) {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.sidebar-refresh-button:active:not(:disabled),
.usage-refresh-button:active:not(:disabled),
.sidebar-toggle:active {
  background: transparent;
  box-shadow: none;
}

.sidebar-refresh-button:disabled,
.usage-refresh-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.sidebar-refresh-button svg,
.usage-refresh-button svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.sidebar-refresh-button.is-refreshing svg {
  animation: refresh-spin 0.8s linear infinite;
}

.icon-button,
.ghost-button,
.send-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.icon-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-color: transparent;
  background: transparent;
  color: var(--sidebar-muted);
  font-size: 24px;
  line-height: 1;
}

.icon-button:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.chat-list {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 8px 8px 18px;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  padding: 12px 10px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--sidebar-line);
}

.codex-usage-card {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: #15181b;
  color: var(--sidebar-text);
}

.codex-usage-head,
.usage-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.codex-usage-head {
  font-size: 12px;
  font-weight: 700;
}

.codex-usage-body {
  display: grid;
  gap: 9px;
}

.usage-plan,
.usage-muted,
.usage-unavailable,
.usage-reset {
  color: var(--sidebar-muted);
  font-size: 12px;
}

.usage-unavailable {
  line-height: 1.35;
}

.usage-row {
  display: grid;
  gap: 5px;
}

.usage-row-top {
  font-size: 12px;
}

.usage-row-top span:last-child {
  color: var(--sidebar-muted);
  font-variant-numeric: tabular-nums;
}

.usage-bar {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #26313a;
}

.usage-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.sidebar-action-button,
.logout-button {
  width: 100%;
  min-height: 40px;
  background: transparent;
  color: var(--sidebar-text);
  border-color: var(--sidebar-line);
}

.sidebar-action-button:hover,
.logout-button:hover {
  background: var(--sidebar-hover);
}

.sidebar-action-button {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 700;
}

.sidebar-action-button svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
  color: var(--sidebar-muted);
}

.sidebar-action-button:hover svg,
.sidebar-action-button:focus-visible svg {
  color: var(--sidebar-text);
}

.sidebar-section-title {
  margin: 4px 8px 8px;
  color: var(--sidebar-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar-primary-action {
  width: calc(100% - 8px);
  min-height: 36px;
  margin: 2px 4px 10px;
  border: 1px solid #30363c;
  border-radius: 6px;
  background: #f0f2f2;
  color: #111315;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
}

.sidebar-primary-action:hover {
  background: #ffffff;
}

.sidebar-primary-action svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 4px 6px;
  padding: 0 4px;
}

.sidebar-section-header .sidebar-section-title {
  margin: 0;
}

.sidebar-section-action {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--sidebar-muted);
  cursor: pointer;
}

.sidebar-section-action:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.sidebar-section-action svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.project-group {
  display: grid;
  gap: 2px;
}

.no-project-group {
  margin-bottom: 10px;
}

.no-project-row {
  width: 100%;
  min-height: 34px;
  border: 1px solid #252a2f;
  border-radius: 6px;
  background: #15181b;
  color: var(--sidebar-text);
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 9px;
  text-align: left;
  cursor: pointer;
}

.no-project-row:hover {
  background: #20262b;
}

.no-project-row.active-project {
  background: #1b2025;
  border-color: #30363c;
  color: #ffffff;
}

.no-project-row svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  color: var(--sidebar-muted);
}

.project-row {
  position: relative;
  width: 100%;
  min-height: 34px;
  border: 1px solid #252a2f;
  border-radius: 6px;
  background: #171b1f;
  color: var(--sidebar-text);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 50px;
  align-items: center;
  gap: 2px;
  padding: 0 7px;
  text-align: left;
}

.project-row:hover {
  background: #20262b;
}

.project-row.active-project {
  background: #1b2025;
  border-color: #30363c;
  color: #ffffff;
}

.project-toggle {
  min-width: 0;
  min-height: 32px;
  border: 0;
  background: transparent;
  color: inherit;
  display: grid;
  grid-template-columns: 16px 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 6px 0;
  text-align: left;
  cursor: pointer;
}

.project-toggle:focus-visible {
  outline: 2px solid rgba(100, 181, 246, 0.65);
  outline-offset: 2px;
}

.folder-icon {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: var(--sidebar-muted);
}

.folder-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.project-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 650;
}

.project-count {
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  background: #ffffff;
  color: #171b1f;
  font-size: 10px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.project-row.is-open .project-count {
  display: none;
}

.project-caret {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  color: var(--sidebar-muted);
  transition: transform 140ms ease;
}

.project-caret svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.project-row.is-open .project-caret {
  transform: rotate(90deg);
}

.project-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.project-menu,
.project-new-icon {
  width: 22px;
  height: 22px;
  border: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--sidebar-muted);
  border-radius: 6px;
  opacity: 0;
  cursor: pointer;
  padding: 0;
}

.project-row:hover .project-menu,
.project-row:hover .project-new-icon,
.project-row:focus-within .project-menu,
.project-row:focus-within .project-new-icon,
.project-row.menu-open .project-menu {
  opacity: 1;
}

.project-menu:hover,
.project-new-icon:hover,
.project-row.menu-open .project-menu {
  background: var(--sidebar-active);
  color: var(--sidebar-text);
}

.project-menu svg,
.project-new-icon svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.project-options-menu {
  position: absolute;
  right: 30px;
  top: calc(100% - 2px);
  z-index: 30;
  min-width: 116px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(13, 22, 18, 0.18);
}

.project-options-menu.is-hidden {
  display: none;
}

.project-options-item {
  display: block;
  width: 100%;
  padding: 7px 9px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
}

.project-options-item:hover,
.project-options-item:focus-visible {
  background: var(--soft);
  outline: none;
}

.project-options-item.danger {
  color: #b5332b;
}

.project-chats {
  display: grid;
  gap: 2px;
  padding-left: 18px;
}

.project-empty {
  margin: 2px 0 4px;
  padding: 6px 8px 6px 32px;
  color: var(--sidebar-muted);
  font-size: 13px;
}

.project-select-hint {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.project-select-hint:hover {
  color: var(--sidebar-text);
}

.chat-item {
  position: relative;
  width: 100%;
  min-height: 34px;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--sidebar-text);
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 14px 24px minmax(30px, auto);
  align-items: center;
  gap: 7px;
}

.chat-item:hover,
.chat-item.active {
  background: var(--sidebar-active);
  border-color: transparent;
}

.chat-item:hover {
  background: var(--sidebar-hover);
}

.chat-item.active {
  color: #ffffff;
}

.chat-item.is-thinking {
  border-color: rgba(19, 111, 99, 0.24);
}

.chat-item-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  color: var(--sidebar-muted);
}

.chat-item.active .chat-item-icon {
  color: var(--sidebar-text);
}

.chat-item-icon svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.chat-menu-button {
  grid-column: 4;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--sidebar-muted);
  opacity: 0;
}

.chat-item:hover .chat-menu-button,
.chat-item:focus-visible .chat-menu-button,
.chat-item.menu-open .chat-menu-button,
.chat-menu-button:focus-visible {
  opacity: 1;
}

.chat-menu-button:hover,
.chat-menu-button:focus-visible,
.chat-item.menu-open .chat-menu-button {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
  outline: none;
}

.chat-menu-button svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.chat-options-menu {
  position: absolute;
  right: 6px;
  top: calc(100% - 2px);
  z-index: 20;
  min-width: 116px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(13, 22, 18, 0.18);
}

.chat-options-menu.is-hidden {
  display: none;
}

.chat-options-item {
  display: block;
  width: 100%;
  padding: 7px 9px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
}

.chat-options-item:hover,
.chat-options-item:focus-visible {
  background: var(--soft);
  outline: none;
}

.chat-options-item.danger {
  color: #b5332b;
}

.chat-status {
  display: none;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(120, 199, 184, 0.28);
  border-top-color: #78c7b8;
  border-radius: 999px;
  box-shadow: 0 0 8px rgba(120, 199, 184, 0.24);
}

.chat-item.is-thinking .chat-status {
  display: block;
  animation: sidebar-thinking-spin 0.8s linear infinite;
}

.chat-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #78c7b8;
  box-shadow: 0 0 0 3px rgba(120, 199, 184, 0.16);
  display: none;
}

.chat-item.has-unread .chat-unread-dot {
  display: block;
}

.chat-item.has-unread .chat-title {
  font-weight: 750;
}

.chat-title,
.chat-time {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-title {
  font-size: 13px;
  font-weight: 500;
}

.chat-time {
  grid-column: 5;
  justify-self: end;
  color: var(--sidebar-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.chat-panel {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--panel);
  overflow: hidden;
}

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

.chat-panel.no-active-chat .chat-header {
  display: none;
}

.chat-header {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.title-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.title-input:focus {
  outline: none;
  border-color: var(--line);
  background: #fbfbf8;
}

.ghost-button {
  background: white;
  color: var(--warn);
  padding: 10px 12px;
}

.ghost-button:disabled {
  color: #87908a;
  cursor: not-allowed;
  opacity: 0.68;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 28px clamp(16px, 4vw, 56px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-state {
  margin: auto;
  max-width: 440px;
  text-align: center;
  color: var(--muted);
  line-height: 1.5;
}

.chat-panel.no-active-chat .messages {
  align-items: center;
  justify-content: center;
  padding-block: 24px;
}

.no-active-chat-state {
  display: grid;
  justify-items: center;
  gap: 12px;
  max-width: 360px;
}

.empty-state-logo {
  margin: 0;
  color: var(--accent);
  font-size: clamp(34px, 5vw, 48px);
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
}

.no-active-chat-state p {
  margin: 0;
  font-size: 15px;
}

.message {
  max-width: min(760px, 88%);
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow);
}

.message.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
}

.message.assistant {
  align-self: flex-start;
  background: #f2f3ee;
  color: var(--text);
}

.message-text {
  min-width: 0;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.message-attachments:empty {
  display: none;
}

.message-image-button {
  width: min(220px, 100%);
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: zoom-in;
  display: inline-flex;
}

.message-image-button:focus-visible {
  outline: 2px solid rgba(19, 111, 99, 0.32);
  outline-offset: 2px;
}

.message-attachments img {
  width: min(220px, 100%);
  max-height: 180px;
  border-radius: 8px;
  border: 1px solid rgba(32, 35, 31, 0.12);
  object-fit: cover;
  background: white;
}

.message-image-button img {
  width: 100%;
}

.message-file {
  display: inline-flex;
  max-width: min(280px, 100%);
  min-height: 34px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message.thinking {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.message.compact-thinking {
  padding: 8px 10px;
  box-shadow: none;
  background: transparent;
  color: var(--muted);
}

.thinking-label {
  font-size: 14px;
}

.compact-thinking .thinking-label {
  font-size: 12px;
}

.thinking-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.35;
  animation: thinking-pulse 1s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.14s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes thinking-pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

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

@keyframes brand-title-motion {
  0%,
  100% {
    transform: translateY(0);
    text-shadow: 0 0 10px rgba(120, 199, 184, 0.22);
  }

  45% {
    transform: translateY(-1px);
    text-shadow: 0 0 18px rgba(120, 199, 184, 0.48);
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .brand-row h1,
  .chat-item.is-thinking .chat-status,
  .sidebar-refresh-button.is-refreshing svg {
    animation: none;
  }
}

.composer {
  display: grid;
  gap: 10px;
  padding: 14px 18px max(18px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fbfbf8;
}

.chat-panel.no-active-chat .composer {
  pointer-events: none;
  border-top-color: rgba(217, 220, 211, 0.55);
  background: #f3f4ef;
  opacity: 0.58;
}

.chat-panel.no-active-chat .composer textarea {
  border-color: rgba(217, 220, 211, 0.78);
  background: #f8f8f4;
}

.chat-panel.no-active-chat .composer textarea::placeholder {
  color: #8f978e;
}

.composer-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.run-options {
  min-width: 0;
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}

.run-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.custom-select {
  position: relative;
  min-width: 0;
}

.custom-select-button {
  min-width: 96px;
  max-width: 150px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  padding: 0 10px;
  box-shadow: 0 1px 0 rgba(23, 43, 39, 0.04);
}

.custom-select-button:hover,
.custom-select-button:focus-visible,
.custom-select.is-open .custom-select-button {
  outline: 2px solid rgba(19, 111, 99, 0.16);
  border-color: var(--accent);
  background: white;
}

.custom-select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-chevron {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  opacity: 0.66;
}

.custom-select-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 30;
  min-width: 100%;
  width: max-content;
  max-width: min(260px, calc(100vw - 24px));
  display: none;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 16px 34px rgba(26, 33, 31, 0.16);
}

.custom-select.is-open .custom-select-menu {
  display: grid;
  gap: 2px;
}

.custom-select-item {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  white-space: nowrap;
  padding: 0 10px;
}

.custom-select-item:hover,
.custom-select-item:focus-visible,
.custom-select-item.is-selected {
  background: rgba(19, 111, 99, 0.09);
  color: var(--accent);
  outline: none;
}

.custom-select-button:disabled {
  color: #87908a;
  cursor: not-allowed;
  opacity: 0.68;
}

.composer textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 76px;
  max-height: 180px;
  background: white;
}

.composer textarea:focus {
  outline: 2px solid rgba(19, 111, 99, 0.2);
  border-color: var(--accent);
}

.file-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-preview-item {
  position: relative;
  min-width: 0;
  max-width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: visible;
  background: white;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 34px 8px 10px;
}

.file-preview-item.image-file {
  width: 76px;
  height: 60px;
  padding: 0;
  overflow: hidden;
}

.file-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.file-preview-item img:focus-visible {
  outline: 2px solid rgba(19, 111, 99, 0.32);
  outline-offset: -3px;
}

.file-preview-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--text);
}

.remove-file-button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(20, 24, 26, 0.78);
  color: white;
  cursor: pointer;
  line-height: 1;
}

.attach-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--accent);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

.attach-button:hover,
.attach-button:focus-visible {
  border-color: var(--accent);
  outline: 2px solid rgba(19, 111, 99, 0.16);
  outline-offset: 0;
}

.attach-button.is-disabled {
  color: #87908a;
  cursor: not-allowed;
  opacity: 0.68;
}

.attach-button.is-disabled:hover,
.attach-button.is-disabled:focus-visible {
  border-color: var(--line);
  outline: none;
}

.attach-button svg,
.voice-button svg,
.send-button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  pointer-events: none;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.send-button {
  margin-left: 0;
  width: 42px;
  height: 42px;
  min-width: 42px;
  padding: 0;
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}

.send-button-label {
  display: none;
}

.send-button.stop-button {
  width: auto;
  min-width: 72px;
  padding: 0 14px;
}

.send-button.stop-button .send-button-label {
  display: inline;
}

.send-button.stop-button svg {
  display: none;
}

.voice-button {
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

.voice-button:hover,
.voice-button:focus-visible,
.voice-button.is-listening {
  color: var(--accent);
  background: rgba(19, 111, 99, 0.08);
}

.voice-button:disabled {
  color: #87908a;
  cursor: not-allowed;
  opacity: 0.68;
}

.send-button:disabled {
  background: #87908a;
  border-color: #87908a;
  cursor: wait;
}

.send-button.stop-button {
  background: var(--warn);
  border-color: var(--warn);
}

.send-button.stop-button:hover,
.send-button.is-stopping {
  background: #8d332a;
  border-color: #8d332a;
}

.send-button.is-disabled:disabled {
  cursor: not-allowed;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: start center;
  padding: max(28px, env(safe-area-inset-top)) 16px 16px;
  background: rgba(20, 24, 26, 0.58);
}

.image-viewer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  background: rgba(8, 10, 11, 0.82);
}

.image-viewer-modal {
  position: relative;
  width: min(100%, 1040px);
  height: min(100%, 760px);
  display: grid;
  place-items: center;
}

.image-viewer-modal img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 22px 64px rgba(0, 0, 0, 0.42);
}

.image-viewer-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(14, 17, 18, 0.78);
  color: white;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

.image-viewer-close:hover,
.image-viewer-close:focus-visible {
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(14, 17, 18, 0.94);
  outline: 2px solid rgba(255, 255, 255, 0.24);
  outline-offset: 2px;
}

.image-viewer-close svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  pointer-events: none;
}

.confirm-modal {
  width: min(100%, 420px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.34);
}

.prompt-modal {
  width: min(100%, 460px);
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.34);
}

.prompt-field {
  display: grid;
  gap: 8px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 700;
}

.prompt-field input {
  min-height: 44px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: #15181b;
  color: var(--sidebar-text);
  padding: 0 12px;
}

.prompt-field input:focus {
  border-color: #ffb4c6;
  outline: 2px solid rgba(255, 180, 198, 0.22);
  outline-offset: 0;
}

.path-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.path-browse-button {
  min-height: 44px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: #20262b;
  color: var(--sidebar-text);
  padding: 0 12px;
  cursor: pointer;
  font-weight: 700;
}

.path-browse-button:hover {
  background: var(--sidebar-active);
}

.path-browser-modal {
  width: min(100%, 560px);
  max-height: min(680px, calc(100dvh - 48px));
  display: grid;
  grid-template-rows: auto auto minmax(180px, 1fr) auto auto;
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.34);
}

.path-browser-current {
  min-height: 34px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: #15181b;
  color: var(--sidebar-muted);
  padding: 8px 10px;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.path-browser-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 4px;
}

.path-browser-item {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--sidebar-text);
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 9px;
  text-align: left;
  cursor: pointer;
}

.path-browser-item:hover {
  background: var(--sidebar-hover);
  border-color: var(--sidebar-line);
}

.path-browser-item svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  color: var(--sidebar-muted);
}

.path-browser-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.path-browser-empty {
  color: var(--sidebar-muted);
  padding: 12px 4px;
  font-size: 13px;
}

.identity-modal {
  width: min(100%, 680px);
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.34);
}

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

.identity-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.identity-close-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-muted);
  cursor: pointer;
}

.identity-close-button:hover,
.identity-close-button:focus-visible {
  background: #202931;
  color: var(--sidebar-text);
}

.identity-close-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.identity-editor {
  width: 100%;
  min-height: 260px;
  max-height: min(52vh, 520px);
  resize: vertical;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  padding: 12px;
  background: #0f1113;
  color: var(--sidebar-text);
  line-height: 1.45;
}

.identity-editor:focus {
  outline: 2px solid rgba(19, 111, 99, 0.45);
  border-color: var(--accent);
}

.identity-status {
  min-height: 18px;
  color: var(--sidebar-muted);
  font-size: 13px;
}

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

.identity-save-button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
}

.identity-save-button:hover,
.identity-save-button:focus-visible {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.identity-save-button:disabled {
  background: #87908a;
  border-color: #87908a;
  cursor: wait;
}

.confirm-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(164, 62, 50, 0.16);
  color: #ffb4aa;
}

.confirm-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.confirm-copy {
  min-width: 0;
}

.confirm-copy h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.confirm-copy p {
  margin: 8px 0 0;
  color: var(--sidebar-muted);
  line-height: 1.45;
}

.confirm-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.confirm-cancel,
.confirm-danger {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 700;
}

.confirm-cancel {
  background: transparent;
  color: var(--sidebar-text);
  border-color: var(--sidebar-line);
}

.confirm-cancel:hover,
.confirm-cancel:focus-visible {
  background: #202931;
}

.confirm-danger {
  background: var(--warn);
  color: white;
}

.confirm-danger:hover,
.confirm-danger:focus-visible {
  background: #8d332a;
}

.confirm-cancel:focus-visible,
.confirm-danger:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.28);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
  }

  .chat-panel {
    height: 100vh;
    height: 100dvh;
  }

  .sidebar-toggle {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
    z-index: 35;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    display: inline-grid;
    place-content: center;
    gap: 4px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transform: translateX(0);
    transition:
      transform 0.22s ease,
      opacity 0.18s ease,
      background 0.18s ease,
      border-color 0.18s ease,
      box-shadow 0.18s ease;
  }

  .sidebar-toggle span {
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transition: transform 0.18s ease, opacity 0.18s ease;
  }

  .sidebar-toggle::before {
    content: "";
    display: none;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 12px solid currentColor;
  }

  .sidebar-closing .sidebar-toggle {
    opacity: 1;
    visibility: visible;
    pointer-events: none;
    width: 44px;
    height: 44px;
    background: var(--sidebar-hover);
    border-color: var(--sidebar-line);
    box-shadow: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar-closing .sidebar-toggle span,
  .sidebar-open .sidebar-toggle span {
    display: none;
  }

  .sidebar-closing .sidebar-toggle::before {
    display: block;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: block;
    border: 0;
    background: rgba(20, 24, 26, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(84vw, 340px);
    max-width: 340px;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    border-right: 1px solid var(--sidebar-line);
    border-bottom: 0;
    min-height: 0;
    box-shadow: 18px 0 40px rgba(0, 0, 0, 0.22);
  }

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

  .sidebar-open .sidebar-toggle {
    transform: translateX(min(calc(84vw - 68px), 272px));
    width: 44px;
    height: 44px;
    color: var(--sidebar-text);
    background: var(--sidebar-hover);
    border-color: var(--sidebar-line);
    box-shadow: none;
    gap: 0;
  }

  .sidebar-open .sidebar-toggle::before {
    display: block;
  }

  .sidebar-open .sidebar-toggle:hover,
  .sidebar-open .sidebar-toggle:focus-visible {
    background: var(--sidebar-hover);
    border-color: var(--sidebar-line);
  }

  .sidebar-refresh-button {
    width: 44px;
    height: 44px;
    border-color: var(--sidebar-line);
    border-radius: 8px;
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
    box-shadow: none;
  }

  .sidebar-refresh-button:hover:not(:disabled),
  .sidebar-refresh-button:focus-visible {
    background: var(--sidebar-hover);
    border-color: var(--sidebar-line);
  }

  .sidebar-refresh-button:active:not(:disabled),
  .sidebar-open .sidebar-toggle:active,
  .sidebar-closing .sidebar-toggle:active {
    background: var(--sidebar-hover);
    border-color: var(--sidebar-line);
    box-shadow: none;
  }

  .brand-row {
    padding: max(12px, env(safe-area-inset-top)) 64px 14px 14px;
  }

  .brand-row h1 {
    font-size: 20px;
  }

  .brand-row p {
    display: none;
  }

  .project-menu,
  .project-new-icon,
  .chat-menu-button {
    opacity: 1;
  }

  .chat-item {
    min-height: 40px;
  }

  .messages {
    padding: 14px 12px;
  }

  .message {
    max-width: 96%;
  }

  .composer {
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .run-options {
    flex: 1 1 auto;
    margin-left: auto;
    min-width: 0;
  }

  .run-option {
    flex: 1 1 0;
    gap: 4px;
    font-size: 11px;
  }

  .custom-select {
    width: 100%;
  }

  .custom-select-button {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: 40px;
    padding: 0 8px;
  }

  .custom-select-menu {
    right: 0;
  }

  .attach-button,
  .voice-button {
    width: 40px;
    height: 40px;
  }

  .send-button {
    width: 42px;
    min-width: 42px;
    height: 42px;
  }

  .modal-backdrop {
    align-items: end;
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .confirm-modal {
    width: 100%;
  }

  .prompt-modal {
    width: 100%;
  }

  .identity-modal {
    width: 100%;
  }

  .identity-editor {
    min-height: 240px;
    max-height: 58vh;
  }

  .image-viewer-backdrop {
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  }

  .image-viewer-modal {
    width: 100%;
    height: 100%;
  }

  .image-viewer-close {
    top: max(8px, env(safe-area-inset-top));
    right: 8px;
  }
}

@media (max-width: 520px) {
  .composer-toolbar {
    flex-wrap: nowrap;
  }

  .run-option > span {
    display: none;
  }

  .run-options {
    gap: 5px;
  }

  .custom-select-button {
    font-size: 11px;
  }

  .sidebar-toggle {
    top: calc(max(10px, env(safe-area-inset-top)) - 2px);
  }

  .chat-header {
    gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px 64px;
  }

  .title-input {
    font-size: 16px;
    padding: 9px 8px;
  }

  .ghost-button {
    padding: 9px 10px;
  }
}
