@font-face {
  font-family: "Tiempos Text";
  src: url("/tiempos-font-family/TestTiemposText-Regular-BF66457a50cd521.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: "Tiempos Text";
  src: url("/tiempos-font-family/TestTiemposText-Semibold-BF66457a4fed201.otf") format("opentype");
  font-weight: 600;
  font-style: normal;
}

@font-face {
  font-family: "Tiempos Headline";
  src: url("/tiempos-font-family/TestTiemposHeadline-Semibold-BF66457a509040b.otf") format("opentype");
  font-weight: 600;
  font-style: normal;
}

:root {
  color-scheme: light;
  --app-height: 100dvh;
  --bg: #f6f4ef;
  --surface: #fffcf5;
  --sidebar: #ece8df;
  --surface-elevated: #ffffff;
  --border: #d8d2c4;
  --text: #1f1f1a;
  --muted: #67645b;
  --accent: #b65f26;
  --accent-soft: #f2e3d8;
  --user-bubble: #f0e8db;
  --assistant-bubble: #ffffff;
  --shadow: 0 8px 28px rgba(31, 31, 26, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171714;
  --surface: #1f1f1a;
  --sidebar: #20201d;
  --surface-elevated: #262622;
  --border: #34342f;
  --text: #ece8df;
  --muted: #b3ada0;
  --accent: #f3a76b;
  --accent-soft: #3a2a1f;
  --user-bubble: #3a3227;
  --assistant-bubble: #2c2c28;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Tiempos Text", Georgia, serif;
}

button,
textarea {
  font: inherit;
  color: inherit;
}

.material-symbols-rounded {
  font-variation-settings:
    "FILL" 0,
    "wght" 500,
    "GRAD" 0,
    "opsz" 24;
  font-size: 20px;
  line-height: 1;
}

.app-layout {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  height: var(--app-height);
  max-height: var(--app-height);
  background: radial-gradient(circle at top left, rgba(182, 95, 38, 0.08), transparent 44%), var(--bg);
}

.sidebar-overlay {
  display: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
}

.sidebar-header {
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.brand-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  font-family: "Tiempos Headline", "Tiempos Text", Georgia, serif;
}

.conversation-tabs {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.conversation-tab {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  padding: 10px 10px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.conversation-tab-icon {
  font-size: 18px;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.conversation-tab:hover {
  border-color: var(--accent);
}

.conversation-tab.is-active {
  background: var(--surface-elevated);
  border-color: var(--accent);
  color: var(--accent);
}

.new-chat-btn {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-elevated);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.new-chat-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.new-chat-btn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  transform: none;
  border-color: var(--border);
}

.conversation-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.conversation-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.conversation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: stretch;
}

.conversation-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  padding: 10px;
  display: grid;
  gap: 4px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.conversation-item:hover {
  background: rgba(255, 255, 255, 0.45);
  border-color: var(--border);
}

:root[data-theme="dark"] .conversation-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.conversation-item.is-active {
  background: var(--surface-elevated);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.conversation-delete {
  width: 30px;
  min-width: 30px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.conversation-delete:hover {
  background: var(--surface-elevated);
  border-color: var(--border);
  color: var(--accent);
}

.conversation-title {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-preview {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent-soft), rgba(255, 255, 255, 0.3));
}

.user-name {
  margin: 0;
  font-weight: 600;
  font-size: 0.86rem;
}

.user-email {
  margin: 2px 0 0;
  font-size: 0.74rem;
  color: var(--muted);
  word-break: break-all;
}

.sign-out-btn {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}

.sign-out-btn:hover {
  border-color: var(--accent);
}

.chat-main {
  min-width: 0;
  min-height: 0;
  width: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  padding: 18px clamp(12px, 2vw, 26px);
  gap: 12px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.chat-header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chat-title-block {
  min-width: 0;
}

.chat-title-block h1 {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 700;
  font-family: "Tiempos Headline", "Tiempos Text", Georgia, serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-line {
  margin: 3px 0 0;
  min-height: 1.2em;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-selector-container {
  position: relative;
  margin-left: auto;
}

.model-selector-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  width: 200px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-elevated);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.model-selector-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.model-selector-btn span:nth-child(2) {
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  z-index: 1000;
  overflow: hidden;
  padding: 8px;
  animation: slideUpIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

@keyframes slideUpIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.model-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.model-option {
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.model-option:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.model-option.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.model-option-name {
  margin: 0;
  font-weight: 700;
  font-size: 0.94rem;
}

.model-option-desc {
  margin: 2px 0 0;
  font-size: 0.76rem;
  color: var(--muted);
}

.model-option.is-active .model-option-desc {
  color: var(--accent);
  opacity: 0.8;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  width: 44px !important;
  height: 44px !important;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.icon-btn:active {
  background: var(--surface);
}

.code-btn {
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  width: 110px !important;
  height: 44px !important;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.code-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.code-btn:active {
  background: var(--surface);
}

.enabled {
  background-color: var(--accent-soft);
  border: 1px solid var(--accent);
}

.sidebar-toggle {
  display: none;
}

.welcome-panel {
  border: none;
  border-radius: 0;
  padding: 12px 8px;
  background: transparent;
  text-align: center;
  width: min(820px, 100%);
  margin-inline: auto;
  justify-items: center;
  padding-top: 2.4rem;
}

.welcome-panel h2 {
  margin: 0;
  font-size: 2.4rem !important;
  font-family: "Tiempos Headline", "Tiempos Text", Georgia, serif;
}

.welcome-panel p {
  margin: 6px 0 0;
  color: var(--muted);
  text-align: center;
}

.preset-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(760px, 100%);
}

.preset-chip {
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  border-radius: 999px;
  padding: 9px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}

.preset-chip:hover {
  border-color: var(--accent);
}

.chip-icon {
  width: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.messages {
  overflow: auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}

.message {
  display: flex;
  max-width: 100%;
  min-width: 0;
}

.message--user {
  justify-content: flex-end;
}

.message-card {
  width: fit-content;
  max-width: min(760px, 92%);
  min-width: 0;
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 12px 12px 10px;
  background: var(--assistant-bubble);
  box-shadow: var(--shadow);
}

.message--user .message-card {
  background: var(--user-bubble);
}

.message-meta {
  margin: 0 0 8px;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.message-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.5;
  font-size: 0.94rem;
  font-family: "Tiempos Text", Georgia, serif;
}

.markdown-body {
  white-space: normal;
}

.markdown-body p,
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre,
.markdown-body table,
.markdown-body hr {
  margin: 0 0 10px;
}

.markdown-body p:last-child,
.markdown-body h1:last-child,
.markdown-body h2:last-child,
.markdown-body h3:last-child,
.markdown-body h4:last-child,
.markdown-body h5:last-child,
.markdown-body h6:last-child,
.markdown-body ul:last-child,
.markdown-body ol:last-child,
.markdown-body blockquote:last-child,
.markdown-body pre:last-child,
.markdown-body table:last-child,
.markdown-body hr:last-child {
  margin-bottom: 0;
}

.markdown-body h1 {
  font-size: 1.08rem;
}

.markdown-body h2 {
  font-size: 1.02rem;
}

.markdown-body h3 {
  font-size: 0.98rem;
}

.markdown-body h4 {
  font-size: 0.94rem;
}

.markdown-body h5 {
  font-size: 0.9rem;
}

.markdown-body h6 {
  font-size: 0.86rem;
}

.markdown-body ul {
  padding-left: 20px;
}

.markdown-body ol {
  padding-left: 22px;
}

.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: color-mix(in srgb, var(--surface-elevated) 85%, transparent);
  color: color-mix(in srgb, var(--accent) 75%, transparent);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.08em 0.35em;
}

.markdown-body pre {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 44px 16px 16px;
  background: color-mix(in srgb, var(--surface-elevated) 85%, transparent);
  position: relative;
  line-height: 1.5;
  font-size: 0.88rem;
}

.markdown-body pre code {
  display: block;
  white-space: pre;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 0;
  padding: 0;
}

.markdown-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  color: var(--muted);
}

.markdown-body hr {
  border: 0;
  border-top: 1px solid var(--border);
}

.markdown-body a {
  color: var(--accent);
  text-decoration: underline;
}

.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  vertical-align: top;
}

.markdown-body th {
  background: color-mix(in srgb, var(--surface-elevated) 82%, transparent);
  font-weight: 600;
}

.markdown-body .task-list-item {
  list-style: none;
  margin-left: -18px;
}

.markdown-body .task-list-item input[type="checkbox"] {
  margin-right: 8px;
  vertical-align: middle;
}

.code-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 38px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 50%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 5;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.code-lang-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: auto;
}

.code-copy-btn,
.code-preview-btn {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-elevated);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  margin-right: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.code-copy-btn:hover,
.code-preview-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface);
}

/* Highlight.js Overrides */
.hljs {
  background: transparent !important;
  padding: 0 !important;
}

.html-preview-frame {
  width: 100%;
  min-height: 480px;
  background-color: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 14px;
}

.message--system {
  justify-content: center;
}

.message--system .message-card {
  max-width: min(620px, 100%);
  border-style: dashed;
  background: color-mix(in srgb, var(--surface-elevated) 82%, transparent);
  box-shadow: none;
  padding: 9px 12px;
}

.message--system .message-meta {
  text-align: center;
  margin-bottom: 6px;
}

.message--system .message-body {
  font-size: 0.82rem;
  color: var(--muted);
}

.assistant-header {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.assistant-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.assistant-meta {
  margin: 0;
}

.message-images {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;
  gap: 8px;
}

.message-images img {
  width: 100%;
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.message-tool-messages {
  margin-top: 10px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}

.tool-message-row {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.tool-message-row+.tool-message-row {
  margin-top: 4px;
}

.tool-status {
  min-height: 0;
  max-height: 21px;
  overflow: auto;
  color: var(--muted);
  font-size: 0.76rem;
  padding-right: 4px;
}

.tool-status p {
  margin: 0 0 4px;
}

.composer {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  padding: 10px;
  min-width: 0;
}

.pending-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.pending-chip {
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  border-radius: 10px;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.pending-chip img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.pending-label {
  max-width: 220px;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.pending-remove {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 8px;
  width: 24px;
  height: 24px;
  cursor: pointer;
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
}

#prompt-input {
  flex: 1;
  min-width: 0;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-elevated);
  min-height: 44px;
  max-height: 180px;
  padding: 10px 12px;
  line-height: 1.45;
  overflow-y: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

#prompt-input::-webkit-scrollbar {
  display: none;
}

#prompt-input:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 1px;
}

.send-btn {
  background: var(--accent);
  color: #fff;
  border: solid 1px #0000;
  transition: background 0.15s ease;
}

.send-btn:hover {
  border: solid 1px var(--text);
  background: #a05420;
}

.send-btn:active {
  background: var(--accent-soft);
}

.composer-hint {
  margin: 8px 2px 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(23, 23, 20, 0.52);
  display: grid;
  place-items: center;
  padding: 20px;
}

.dialog-overlay[hidden] {
  display: none !important;
}

.dialog-card {
  width: min(460px, 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow);
  padding: 18px;
}

.dialog-card h2 {
  margin: 0;
  font-size: 1.14rem;
  font-family: "Tiempos Headline", "Tiempos Text", Georgia, serif;
}

.dialog-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.dialog-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.dialog-btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dialog-btn:hover {
  border-color: var(--accent);
}

.dialog-btn-secondary {
  background: color-mix(in srgb, var(--accent-soft) 68%, transparent);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.dialog-btn-danger {
  color: #fff;
  background: #b04431;
  border-color: #b04431;
}

.dialog-btn-danger:hover {
  border-color: #8f3122;
  background: #8f3122;
}

@keyframes thinking-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }
}

.thinking-text {
  animation: thinking-pulse 1.6s ease-in-out infinite;
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 960px) {
  .app-layout {
    grid-template-columns: 1fr;
    height: var(--app-height);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(84vw, 320px);
    z-index: 30;
    border-right: 1px solid var(--border);
    border-bottom: none;
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.24);
    transform: translateX(-104%);
    transition: transform 0.22s ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 20;
    border: none;
    padding: 0;
    margin: 0;
    background: rgba(18, 18, 16, 0.36);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .chat-main {
    padding:
      calc(10px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    gap: 10px;
  }

  .preset-grid {
    grid-template-columns: 1fr;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .chat-title-block h1 {
    font-size: 1.08rem;
  }

  .status-line {
    font-size: 0.78rem;
  }

  .message-card {
    max-width: 100%;
  }

  .message-images img {
    width: min(170px, 42vw);
  }

  .composer {
    padding: 8px;
  }

  #prompt-input {
    font-size: 16px;
  }

  .pending-label {
    max-width: min(140px, 32vw);
  }

  .dialog-card {
    padding: 16px;
  }

  .hide-small {
    display: none;
  }

  .code-btn {
    width: 44px !important;
    height: 44px !important;
  }

  .model-selector-btn {
    width: auto;
    max-width: 160px;
    padding: 0 12px;
  }

  .model-selector-btn span:nth-child(2) {
    max-width: 80px;
  }
}

@media (max-width: 480px) {
  .chat-main {
    padding:
      calc(8px + env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    gap: 8px;
  }

  .chat-header {
    gap: 8px;
  }

  .icon-btn {
    width: 40px !important;
    height: 40px !important;
  }

  .code-btn {
    width: 40px !important;
    height: 40px !important;
  }

  .welcome-panel {
    padding: 14px;
  }

  .messages {
    gap: 10px;
    padding-right: 0;
  }

  .message {
    width: 100%;
  }

  .message-card {
    width: 100%;
    max-width: 100%;
    padding: 10px 10px 9px;
  }

  .message-images img {
    width: 100%;
  }

  .composer {
    padding: 8px;
    border-radius: 14px;
  }

  .composer-row {
    gap: 6px;
  }

  .pending-label {
    max-width: min(132px, 34vw);
  }

  .model-selector-btn {
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    justify-content: center;
  }

  .model-selector-btn span:not(:first-child) {
    display: none !important;
  }
}

@media (max-width: 420px) {
  .chat-title-block h1 {
    font-size: 0.98rem;
  }

  .icon-btn {
    width: 38px !important;
    height: 38px !important;
  }

  .code-btn {
    width: 38px !important;
    height: 38px !important;
  }

  #prompt-input {
    min-height: 40px;
    padding: 9px 10px;
  }

  .composer-hint {
    font-size: 0.7rem;
  }

  .pending-label {
    max-width: min(110px, 30vw);
  }

  .model-selector-btn {
    width: 38px !important;
    height: 38px !important;
  }
}

@media (max-height: 512px) {
  .preset-grid {
    display: none;
  }
}

/* Memory styles */
.sidebar-footer-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.sidebar-footer-actions button {
  width: 100%;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

@media (max-height: 720px) {
  .sidebar-footer-actions {
    grid-template-columns: 1fr 1fr;
  }
}

.memory-btn {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.memory-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.memory-list-container {
  margin-top: 14px;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 4px;
}

.memory-list-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.memory-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-elevated);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.memory-list-item:hover {
  border-color: var(--border);
  background: color-mix(in srgb, var(--bg) 40%, var(--surface-elevated));
}

.memory-item-content {
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text);
  word-break: break-word;
}

.memory-item-delete {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s ease;
}

.memory-item-delete:hover {
  border-color: var(--border);
  background: var(--surface);
  color: var(--accent);
}

.memory-empty-state {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}