:root {
  color-scheme: dark;
  --bg: #111313;
  --surface: #171918;
  --surface-2: #202321;
  --surface-3: #282c29;
  --text: #f4f1e8;
  --muted: #aaa69b;
  --line: #353934;
  --accent: #19a987;
  --accent-2: #f08d49;
  --warn: #f0c35b;
  --danger: #ff6b6b;
  --shadow: 0 18px 50px rgba(0, 0, 0, .34);
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, .24);
  --radius: 8px;
  --content: min(1440px, 100vw);
  --toolbar: 64px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
  overflow-x: hidden;
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, rgba(240, 141, 73, .07), transparent 250px),
    linear-gradient(135deg, rgba(25, 169, 135, .05), transparent 42%),
    var(--bg);
  color: var(--text);
  letter-spacing: 0;
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body.fullscreen-is-open {
  overflow: hidden;
}

body.confirm-is-open {
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
select,
input[type="color"] {
  cursor: pointer;
}

button {
  border: 0;
  color: var(--text);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.app-shell {
  width: var(--content);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  overflow-x: clip;
}

.topbar {
  min-height: var(--toolbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
  background: rgba(17, 19, 19, .84);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  position: sticky;
  top: max(10px, env(safe-area-inset-top));
  z-index: 20;
}

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

.brand-button {
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  color: inherit;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: #111313 url("assets/icon.svg") center / cover no-repeat;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
}

.brand-mark span {
  display: none;
}

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

.brand h1 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.1;
  font-weight: 780;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions,
.editor-actions,
.preview-actions,
.danger-zone {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.icon-button,
.primary-button,
.ghost-button,
.run-button,
.delete-button,
.switch-button {
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
  transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.icon-button {
  width: 44px;
  display: grid;
  place-items: center;
  padding: 0;
}

.icon-button.compact {
  width: 44px;
  min-height: 44px;
}

.projects-button,
.library-close {
  display: none;
}

.primary-button,
.ghost-button,
.run-button,
.delete-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  font-weight: 720;
  white-space: nowrap;
  min-width: max-content;
}

.primary-button {
  background: var(--accent);
  color: #081311;
  border-color: transparent;
}

.account-button.is-signed-in {
  border-color: rgba(108, 180, 238, .38);
  background: rgba(108, 180, 238, .14);
  max-width: 180px;
}

.account-button-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.radar-button {
  border-color: rgba(20, 184, 166, .34);
  background: rgba(20, 184, 166, .12);
  color: #cffff8;
}

.run-button {
  background: var(--accent-2);
  color: #160d08;
  border-color: transparent;
}

.delete-button {
  border-color: rgba(255, 107, 107, .32);
  color: #ffd4d4;
}

.icon-button:hover,
.primary-button:hover,
.ghost-button:hover,
.run-button:hover,
.delete-button:hover,
.switch-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, .28);
  box-shadow: var(--shadow-soft);
}

.icon-button:active,
.primary-button:active,
.ghost-button:active,
.run-button:active,
.delete-button:active,
.switch-button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: .58;
  transform: none;
}

.primary-button:hover {
  background: #33bd9a;
}

.run-button:hover {
  background: #ff9c5c;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr);
  gap: 14px;
  padding-top: 14px;
  min-height: calc(100dvh - var(--toolbar) - 42px);
}

.library,
.stage {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
  background: rgba(23, 25, 24, .88);
  box-shadow: var(--shadow);
}

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

.library-search {
  height: 52px;
  display: grid;
  grid-template-columns: 20px 1fr 104px auto;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.library-search svg {
  color: var(--muted);
}

.library-search input,
.library-search select,
.name-input,
.code-input,
.setting-row select,
.setting-block textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: var(--radius);
}

.library-search input {
  height: 38px;
}

.library-search select {
  height: 38px;
  padding-inline: 10px;
}

.library-search input::placeholder,
.code-input::placeholder {
  color: #7e7a72;
}

.library-list {
  min-height: 0;
  overflow: auto;
  padding: 8px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.app-card {
  min-height: 74px;
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .045);
  border-radius: var(--radius);
}

.app-card.is-active {
  border-color: rgba(25, 169, 135, .68);
  background: rgba(25, 169, 135, .12);
}

.app-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #101211;
  font-size: .92rem;
  font-weight: 860;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
}

.app-card strong,
.app-card span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-card strong {
  font-size: .88rem;
}

.app-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: .74rem;
}

.empty-state {
  min-height: 120px;
  display: grid;
  place-items: center;
  padding: 14px;
  text-align: center;
  line-height: 1.35;
  color: var(--muted);
  border: 1px dashed rgba(255, 255, 255, .15);
  border-radius: var(--radius);
}

.empty-state.compact {
  min-height: auto;
  padding: 10px;
  font-size: .78rem;
}

.library-more {
  gap: 8px;
}

.library-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: rgba(17, 19, 19, .44);
}

.library-actions button {
  width: 100%;
}

.trash-recovery {
  display: grid;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: rgba(17, 19, 19, .58);
}

.trash-recovery[hidden] {
  display: none;
}

.trash-recovery p {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.35;
}

.trash-recovery strong {
  display: block;
  color: var(--text);
  font-size: .82rem;
}

.trash-recovery-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.trash-recovery-actions.single {
  grid-template-columns: 1fr;
}

.trash-recovery-list {
  display: grid;
  gap: 6px;
}

.trash-recovery-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.trash-recovery-item > span {
  min-width: 0;
  color: var(--muted);
  font-size: .76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  overflow: hidden;
}

.stage-header {
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.field-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 720;
  text-transform: uppercase;
}

.name-input {
  height: 34px;
  padding: 0;
  font-size: 1.24rem;
  font-weight: 780;
}

.view-switch {
  display: flex;
  padding: 4px;
  gap: 4px;
  min-width: 0;
  background: rgba(255, 255, 255, .055);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
}

.switch-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  color: var(--muted);
  font-weight: 720;
  font-size: .82rem;
  background: transparent;
  border-color: transparent;
  white-space: nowrap;
}

.switch-button.is-active {
  color: var(--text);
  background: var(--surface-3);
  border-color: rgba(255, 255, 255, .1);
}

.stage-body {
  min-height: 0;
  position: relative;
}

.empty-workspace {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  align-content: center;
  gap: 22px;
  padding: clamp(22px, 5vw, 54px);
  background:
    linear-gradient(180deg, rgba(25, 169, 135, .08), transparent 42%),
    var(--surface);
}

.empty-workspace[hidden] {
  display: none !important;
}

.empty-workspace-copy {
  max-width: 520px;
}

.empty-workspace-copy p {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.empty-workspace-copy h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.empty-workspace-copy span {
  display: block;
  max-width: 460px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.empty-workspace-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 170px));
  gap: 10px;
  max-width: 720px;
}

.empty-workspace-actions button {
  min-height: 48px;
}

.empty-workspace-actions textarea {
  grid-column: 1 / -1;
  min-height: 104px;
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--text);
  background: rgba(0, 0, 0, .18);
  font: inherit;
  line-height: 1.45;
}

body.has-empty-workspace .view-panel {
  display: none;
}

.view-panel {
  position: absolute;
  inset: 0;
  display: none;
  min-height: 0;
}

.view-panel.is-active {
  display: grid;
}

.view-panel[data-panel="editor"] {
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  overflow: hidden;
}

.view-panel[data-panel="editor"]:has(.editor-status:not([hidden])) {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.editor-toolbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, .12);
}

.runtime-pill {
  min-width: 96px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .045);
  color: var(--muted);
}

.runtime-pill span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.runtime-pill strong {
  color: var(--text);
  font-size: .82rem;
}

.editor-status {
  margin: 0;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(240, 141, 73, .1);
  color: #ffd9bd;
  font-size: .84rem;
  line-height: 1.35;
}

.code-input {
  display: block;
  height: 100%;
  min-height: 0;
  resize: none;
  padding: 16px;
  border-radius: 0;
  border: 0;
  background: #101211;
  color: #f7f3ea;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
  outline-offset: -3px;
  caret-color: var(--accent-2);
  overflow: auto;
  overflow-wrap: normal;
  white-space: pre;
  word-break: normal;
  -webkit-overflow-scrolling: touch;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}

.preview-panel {
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #101211;
}

.preview-chrome {
  min-height: 50px;
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.traffic {
  display: flex;
  gap: 7px;
}

.traffic span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--danger);
}

.traffic span:nth-child(2) {
  background: var(--warn);
}

.traffic span:nth-child(3) {
  background: var(--accent);
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, .62);
}

.confirm-dialog {
  width: min(430px, 100%);
  display: grid;
  gap: 18px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.confirm-kicker {
  margin: 0 0 8px;
  color: var(--danger);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.confirm-dialog h2 {
  margin: 0;
  font-size: 1.2rem;
}

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

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

.preview-chrome p {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 720;
}

.phone-frame {
  min-height: 0;
  margin: 14px auto;
  width: min(100%, 430px);
  height: calc(100% - 28px);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 28px;
  padding: 10px;
  background: #050605;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}

.phone-frame iframe,
.fullscreen iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  background: white;
}

.phone-frame iframe {
  border-radius: 20px;
}

.console-drawer {
  max-height: 180px;
  border-top: 1px solid var(--line);
  background: #0b0d0c;
}

.console-head {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.console-head strong {
  font-size: .8rem;
}

.console-list {
  max-height: 138px;
  overflow: auto;
  padding: 8px 12px 12px;
  display: grid;
  gap: 6px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  color: #ffd4d4;
}

.settings-panel {
  align-content: start;
  padding: 14px;
  gap: 10px;
  overflow: auto;
}

.ask-panel {
  align-content: stretch;
  padding: 14px;
  overflow: auto;
}

.ask-shell {
  display: grid;
  gap: 14px;
  max-width: 780px;
  width: min(100%, 780px);
}

.ask-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0 4px;
}

.ask-header p {
  margin: 0 0 5px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: .76rem;
  letter-spacing: 0;
}

.ask-header h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.1;
  text-wrap: balance;
}

.ai-disclaimer {
  display: block;
  margin-top: 6px;
  max-width: 520px;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.4;
}

.prompt-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(25, 169, 135, .2);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .035)),
    rgba(16, 18, 17, .7);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.prompt-card textarea {
  width: 100%;
  min-height: 170px;
  max-height: min(42dvh, 360px);
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius);
  padding: 14px;
  background: #101211;
  color: var(--text);
  line-height: 1.5;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035);
}

.prompt-card textarea::placeholder {
  color: #918c82;
}

.prompt-card textarea:focus {
  border-color: rgba(240, 141, 73, .62);
  background: #0d100f;
}

.quick-prompts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.quick-prompts button {
  min-height: 44px;
  padding: 7px 10px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .06);
  color: #d8d2c6;
  font-size: .78rem;
  font-weight: 720;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.quick-prompts button:hover {
  border-color: rgba(25, 169, 135, .5);
  background: rgba(25, 169, 135, .12);
  color: var(--text);
}

.ask-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ask-actions .run-button {
  min-width: 156px;
}

.ai-result {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(25, 169, 135, .32);
  background: rgba(25, 169, 135, .1);
  border-radius: var(--radius);
  padding: 12px;
  overflow-wrap: anywhere;
}

.ai-result strong {
  display: block;
  margin-bottom: 4px;
}

.ai-result p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.ai-diff-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-diff-stats span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .08);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 760;
}

.ai-diff-panel {
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, .16);
}

.ai-diff-panel summary {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  cursor: pointer;
  color: var(--text);
  font-size: .84rem;
  font-weight: 780;
}

.ai-diff-panel pre {
  max-height: 260px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border-top: 1px solid rgba(255, 255, 255, .1);
  color: #e7e1d7;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ai-preview-panel {
  display: grid;
  gap: 8px;
}

.ai-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: .8rem;
}

.ai-preview-head strong {
  margin: 0;
  color: var(--text);
}

.ai-preview-panel iframe {
  width: 100%;
  height: 260px;
  display: block;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: var(--radius);
  background: white;
}

.ai-review-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ai-review-actions button {
  width: 100%;
  min-width: 0;
  min-height: 48px;
}

.settings-card {
  display: grid;
  gap: 12px;
}

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

.settings-card-head h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.15;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, .4fr);
  gap: 10px;
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
  font-size: .85rem;
}

.legal-links a {
  color: var(--muted);
}

.setting-row,
.setting-block {
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .045);
  border-radius: var(--radius);
}

.setting-row {
  min-height: 64px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.setting-row span,
.setting-block span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 720;
  text-transform: uppercase;
}

.setting-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(25, 169, 135, .14);
  border: 1px solid rgba(25, 169, 135, .28);
  font-size: .78rem;
  white-space: nowrap;
}

.setting-row select {
  width: auto;
  max-width: 180px;
  min-height: 38px;
  color: var(--text);
  background: var(--surface-2);
  border-color: rgba(255, 255, 255, .1);
  padding: 0 10px;
}

.setting-row input[type="checkbox"] {
  width: 46px;
  height: 26px;
  margin: 0;
  appearance: none;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid rgba(255, 255, 255, .14);
  position: relative;
}

.setting-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .15s ease, background .15s ease;
}

.setting-row input[type="checkbox"]:checked {
  background: rgba(25, 169, 135, .28);
  border-color: rgba(25, 169, 135, .64);
}

.setting-row input[type="checkbox"]:checked::after {
  transform: translateX(20px);
  background: var(--accent);
}

.setting-row input[type="color"] {
  width: 48px;
  height: 38px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.setting-block {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.setting-block textarea {
  min-height: 104px;
  resize: vertical;
  padding: 10px;
  border-color: rgba(255, 255, 255, .08);
  background: var(--surface-2);
}

.settings-accordion {
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .035);
}

.settings-accordion summary {
  min-height: 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  cursor: pointer;
  list-style: none;
}

.settings-accordion summary::-webkit-details-marker {
  display: none;
}

.settings-accordion summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .15s ease;
}

.settings-accordion[open] summary::after {
  transform: rotate(225deg);
}

.settings-accordion summary span,
.settings-accordion summary small {
  min-width: 0;
}

.settings-accordion summary span {
  color: var(--text);
  font-size: .9rem;
  font-weight: 760;
}

.settings-accordion summary small {
  justify-self: end;
  color: var(--muted);
  font-size: .76rem;
  white-space: nowrap;
}

.settings-accordion-body {
  display: grid;
  gap: 10px;
  padding: 0 10px 10px;
}

.settings-accordion:not([open]) .settings-accordion-body {
  display: none;
}

.settings-accordion .cloud-panel,
.settings-accordion .usage-panel,
.settings-accordion .moderation-panel {
  margin-top: 0;
}

.auth-panel,
.cloud-panel,
.usage-panel,
.moderation-panel {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid rgba(25, 169, 135, .24);
  border-radius: var(--radius);
  background: rgba(25, 169, 135, .06);
}

.auth-panel {
  display: none;
  border-color: rgba(108, 180, 238, .24);
  background: rgba(108, 180, 238, .07);
}

body.library-account-is-open .auth-panel {
  display: grid;
  align-content: start;
  min-height: 0;
  margin: 8px;
  overflow: auto;
  box-shadow: var(--shadow-soft);
}

.auth-panel.is-signed-in .auth-grid,
.auth-panel.is-signed-in #signUpButton,
.auth-panel.is-signed-in #signInButton,
.auth-panel.is-signed-in #authStatus {
  display: none;
}

.auth-panel.is-signed-out #signOutButton,
.auth-panel.is-signed-out .account-delete-panel,
.auth-panel.is-signed-out #accountDeletionStatus {
  display: none;
}

body.library-account-is-open .library-list {
  display: none;
}

.usage-panel {
  border-color: rgba(240, 195, 91, .24);
  background: rgba(240, 195, 91, .06);
}

.moderation-panel {
  border-color: rgba(255, 107, 107, .26);
  background: rgba(255, 107, 107, .06);
}

.cloud-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.cloud-head p {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: .72rem;
  font-weight: 820;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.cloud-head h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.cloud-head strong {
  max-width: 220px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(0, 0, 0, .18);
  font-size: .72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cloud-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(150px, .55fr);
  gap: 10px;
}

.auth-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(180px, .8fr);
}

.user-button-host:empty {
  display: none;
}

.user-account-summary {
  min-height: 62px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(108, 180, 238, .24);
  border-radius: var(--radius);
  background: rgba(108, 180, 238, .1);
}

.user-account-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #061716;
  background: var(--accent);
  font-weight: 860;
}

.user-account-summary strong,
.user-account-summary small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-account-summary small {
  margin-top: 3px;
  color: var(--muted);
  font-size: .78rem;
}

.cloud-field {
  display: grid;
  gap: 7px;
}

.cloud-field span,
.cloud-import label {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 760;
  text-transform: uppercase;
}

.cloud-field input,
.cloud-field select,
.cloud-field textarea,
.cloud-import input,
.moderation-admin select {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface-2);
  padding: 0 11px;
}

.cloud-field textarea {
  min-height: 88px;
  padding: 10px 11px;
  resize: vertical;
}

.moderation-grid {
  grid-template-columns: minmax(160px, .42fr) minmax(0, 1fr);
}

.auth-actions,
.cloud-actions,
.cloud-import div,
.cloud-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-actions,
.cloud-actions {
  flex-wrap: wrap;
}

.account-delete-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(255, 107, 107, .24);
  border-radius: calc(var(--radius) - 6px);
  background: rgba(255, 107, 107, .07);
}

.password-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(125, 214, 160, .22);
  border-radius: calc(var(--radius) - 6px);
  background: rgba(125, 214, 160, .06);
}

.password-panel[open] {
  gap: 12px;
}

.password-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.password-panel summary::-webkit-details-marker {
  display: none;
}

.password-panel summary::after {
  content: "+";
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  color: var(--muted);
  font-weight: 800;
}

.password-panel[open] summary::after {
  content: "-";
}

.password-panel strong,
.password-panel p,
.password-panel small {
  margin: 0;
}

.password-panel p,
.password-panel small {
  margin-top: 4px;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.45;
}

.password-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(180px, .8fr);
}

.account-delete-panel strong,
.account-delete-panel p {
  margin: 0;
}

.account-delete-panel p {
  margin-top: 4px;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.45;
}

.user-button-host {
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
}

.cloud-import {
  display: grid;
  gap: 7px;
}

.cloud-import input {
  flex: 1;
  min-width: 0;
}

.cloud-status {
  margin: 0;
  color: var(--muted);
  font-size: .84rem;
}

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

.usage-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.admin-usage-panel,
.cloud-conflict-panel {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, .1);
}

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

.admin-usage-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.admin-usage-lists,
.conflict-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.admin-usage-lists {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.usage-card {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, .14);
}

.usage-card span,
.usage-card small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 760;
  text-transform: uppercase;
}

.usage-card strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 1.05rem;
}

.cloud-list-item {
  justify-content: space-between;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, .13);
}

.cloud-list-item div {
  min-width: 0;
}

.cloud-list-item strong,
.cloud-list-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cloud-list-item span {
  margin-top: 2px;
  color: var(--muted);
  font-size: .78rem;
}

.cloud-history {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, .1);
}

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

.cloud-history-head p {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: .72rem;
  font-weight: 820;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.cloud-history-head h3 {
  margin: 0;
  font-size: .96rem;
  line-height: 1.2;
}

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

.history-title {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 820;
  text-transform: uppercase;
}

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

.history-item,
.moderation-report,
.conflict-column {
  display: grid;
  gap: 8px;
  padding: 10px 11px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, .14);
}

.history-item strong,
.history-item span,
.moderation-report strong,
.moderation-report span,
.conflict-column strong,
.conflict-column span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.history-item span,
.moderation-report span,
.conflict-column span {
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.4;
}

.conflict-column pre {
  max-height: 260px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--text);
  font-family: "JetBrains Mono", "SFMono-Regular", ui-monospace, monospace;
  font-size: .74rem;
  line-height: 1.5;
}

.history-item button,
.moderation-report button {
  width: max-content;
  min-width: 112px;
}

.moderation-admin {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, .1);
}

.moderation-admin-actions,
.moderation-report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.moderation-admin select {
  max-width: 180px;
}

.moderation-queue {
  display: grid;
  gap: 8px;
}

.danger-zone {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: block;
  background: #050605;
  overflow: hidden;
}

.fullscreen[hidden] {
  display: none;
}

.fullscreen-bar {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.fullscreen-topbar {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  width: 44px;
  min-height: 44px;
  display: grid;
  grid-template-columns: 44px;
  align-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  pointer-events: auto;
}

.fullscreen-topbar strong {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.fullscreen-topbar .icon-button {
  position: relative;
  width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 0;
  color: rgba(10, 12, 11, .74);
  background: transparent;
  box-shadow: none;
  opacity: 1;
  filter: none;
}

.fullscreen-topbar .icon-button svg {
  opacity: 0;
}

.fullscreen-topbar .icon-button::before {
  content: "×";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(10, 12, 11, .76);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 34px;
  font-weight: 260;
  line-height: 1;
  text-shadow:
    0 0 1px rgba(255, 255, 255, .98),
    0 1px 3px rgba(255, 255, 255, .9),
    0 1px 8px rgba(0, 0, 0, .2);
}

.fullscreen-topbar .icon-button:active {
  background: transparent;
  transform: scale(.94);
}

.fullscreen-dock {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  width: min(432px, calc(100vw - 24px));
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 20px;
  background: rgba(5, 6, 5, .7);
  box-shadow: 0 20px 64px rgba(0, 0, 0, .42);
  backdrop-filter: blur(20px);
  pointer-events: auto;
  transform: translateX(-50%);
}

.fullscreen-tool {
  width: 100%;
  min-width: 0;
  min-height: 54px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  padding: 6px 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .065);
  box-shadow: none;
  font-size: .7rem;
  font-weight: 780;
  line-height: 1;
}

.fullscreen-tool svg {
  width: 18px;
  height: 18px;
}

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

.fullscreen-tool.danger-tool {
  color: #ffd6d6;
}

.fullscreen iframe {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.fullscreen-toggle {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 4;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 999px;
  color: #fff;
  background: rgba(5, 6, 5, .68);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .34);
  backdrop-filter: blur(18px);
  transition: opacity .18s ease, transform .18s ease;
}

.fullscreen-toggle[hidden] {
  display: none;
}

.fullscreen-toggle svg {
  width: 18px;
  height: 18px;
}

.fullscreen.is-chrome-hidden .fullscreen-bar {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
}

.fullscreen.is-chrome-hidden .fullscreen-toggle {
  top: auto;
  bottom: max(16px, env(safe-area-inset-bottom));
  opacity: .78;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(560px, 1fr);
  }

  .library {
    min-height: 164px;
  }

  .library-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 260px);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .stage-header {
    grid-template-columns: 1fr;
  }

  .view-switch {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .view-switch::-webkit-scrollbar {
    display: none;
  }

  .switch-button {
    flex: 1 1 0;
    min-width: max-content;
  }
}

@media (max-width: 620px) {
  html,
  body {
    background: var(--bg);
    overflow: hidden;
  }

  .app-shell {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 0;
  }

  .topbar {
    min-height: calc(58px + env(safe-area-inset-top));
    top: 0;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    padding: max(8px, env(safe-area-inset-top)) 10px 8px;
    border-top: 0;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    background: #111313;
    backdrop-filter: none;
  }

  .brand {
    flex: 1 1 auto;
    min-height: 44px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand h1 {
    display: block;
    font-size: .96rem;
  }

  .brand-copy p {
    display: block;
    max-width: 58vw;
  }

  .top-actions {
    display: flex;
    min-width: 0;
  }

  .top-actions .icon-button:not(.projects-button):not(.account-button),
  .top-actions .radar-button {
    display: none;
  }

  .top-actions .projects-button,
  .top-actions .account-button {
    display: grid;
  }

  .top-actions .projects-button,
  .top-actions .account-button,
  .top-actions .primary-button {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
  }

  .primary-button,
  .ghost-button,
  .run-button,
  .delete-button {
    padding: 0 10px;
  }

  .radar-button {
    padding-inline: 8px;
  }

  .top-actions .ghost-button svg,
  .top-actions .primary-button svg {
    display: none;
  }

  .workspace {
    min-height: 0;
    height: 100%;
    grid-template-rows: minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
    overflow: hidden;
    background: var(--bg);
  }

  .stage {
    order: 1;
    min-height: min(720px, calc(100dvh - 82px));
    height: calc(100dvh - 82px);
    position: relative;
    z-index: 2;
    background: var(--surface);
    isolation: isolate;
  }

  .library {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    width: min(86vw, 330px);
    height: 100dvh;
    min-height: 0;
    padding-top: env(safe-area-inset-top);
    border-top: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--surface);
    transform: translateX(-105%);
    transition: transform .18s ease;
  }

  body.library-is-open .library {
    transform: translateX(0);
  }

  .library-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 19;
    background: rgba(0, 0, 0, .54);
  }

  body.library-is-open .library-backdrop {
    display: block;
  }

  .library-close {
    display: grid;
  }

  .stage-header,
  .stage-body,
  .view-panel,
  .ask-panel,
  .settings-panel {
    background: var(--surface);
  }

  .view-switch,
  .switch-button {
    background: var(--surface-2);
  }

  .switch-button.is-active {
    background: var(--surface-3);
  }

  .library-search {
    grid-template-columns: 20px minmax(0, 1fr) 88px 44px;
    height: 44px;
  }

  .library-list {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .stage-header,
  .editor-toolbar {
    padding-left: 10px;
    padding-right: 10px;
  }

  .empty-workspace {
    align-content: start;
    overflow: auto;
    padding: 26px 18px;
  }

  .empty-workspace-copy h2 {
    font-size: 1.9rem;
  }

  .empty-workspace-actions {
    grid-template-columns: 1fr;
  }

  .stage-header {
    gap: 10px;
  }

  .view-switch {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: visible;
  }

  .switch-button {
    min-width: 0;
    gap: 5px;
    padding: 0 6px;
    font-size: .76rem;
  }

  .switch-button svg {
    width: 16px;
    height: 16px;
  }

  .editor-toolbar {
    display: grid;
    grid-template-columns: minmax(78px, .42fr) minmax(0, 1fr);
    align-items: center;
    position: relative;
    z-index: 2;
    min-height: auto;
    gap: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
    background: var(--surface);
  }

  .runtime-pill {
    width: auto;
    min-width: 0;
    height: 40px;
    padding: 0 8px;
    gap: 6px;
  }

  .runtime-pill strong {
    font-size: .78rem;
  }

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

  .editor-actions button {
    min-width: 0;
    width: 100%;
    min-height: 40px;
    padding: 0 6px;
    gap: 5px;
    font-size: .8rem;
  }

  .editor-actions button svg {
    width: 16px;
    height: 16px;
  }

  .view-panel[data-panel="editor"] {
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .view-panel[data-panel="editor"]:has(.editor-status:not([hidden])) {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .code-input {
    min-height: 0;
    height: 100%;
    padding: 12px;
    font-size: 12px;
    line-height: 1.45;
    overflow: auto;
  }

  .ai-result {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .ai-review-actions {
    position: sticky;
    bottom: 0;
    z-index: 3;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-top: 10px;
    background: linear-gradient(180deg, rgba(23, 25, 24, 0), rgba(23, 25, 24, .96) 26%);
  }

  .ai-review-actions button {
    min-height: 56px;
    font-size: .94rem;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-accordion summary {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .settings-accordion summary small {
    display: none;
  }

  .auth-actions,
  .cloud-head,
  .cloud-actions,
  .account-delete-panel,
  .password-panel,
  .cloud-import div,
  .cloud-list-item {
    align-items: stretch;
    flex-direction: column;
  }

  .account-delete-panel {
    grid-template-columns: 1fr;
  }

  .cloud-head strong {
    max-width: 100%;
  }

  .cloud-grid,
  .password-grid,
  .moderation-grid,
  .usage-grid,
  .admin-usage-grid,
  .admin-usage-lists,
  .conflict-grid {
    grid-template-columns: 1fr;
  }

  .cloud-history-head,
  .history-grid {
    grid-template-columns: 1fr;
  }

  .cloud-history-head {
    align-items: stretch;
    flex-direction: column;
  }

  .cloud-history-head .ghost-button,
  .history-item button,
  .moderation-admin-actions,
  .moderation-admin select,
  .moderation-report button {
    width: 100%;
  }

  .ask-header {
    align-items: stretch;
    flex-direction: column;
  }

  .ask-header .ghost-button,
  .ask-actions .ghost-button,
  .ask-actions .run-button {
    width: 100%;
  }

  .ask-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ask-panel {
    padding: 12px 10px;
  }

  .prompt-card {
    background: #101211;
  }

  .quick-prompts button,
  .ai-result {
    background: var(--surface-2);
  }

  .prompt-card {
    padding: 12px;
  }

  .prompt-card textarea {
    min-height: 190px;
  }

  .quick-prompts {
    grid-template-columns: 1fr 1fr;
  }

  .setting-row select {
    max-width: 148px;
  }

  .phone-frame {
    width: min(100%, 390px);
    margin: 10px auto;
    height: calc(100% - 20px);
    border-radius: 22px;
    padding: 7px;
  }

  .phone-frame iframe {
    border-radius: 16px;
  }

  .fullscreen-topbar {
    width: 44px;
  }

  .fullscreen-dock {
    width: min(360px, calc(100vw - 20px));
    gap: 5px;
    padding: 5px;
    border-radius: 18px;
  }

  .fullscreen-tool {
    min-height: 52px;
    border-radius: 13px;
    font-size: .66rem;
  }
}

@media (max-width: 390px) {
  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .topbar {
    gap: 8px;
  }

  .top-actions {
    grid-template-columns: 42px minmax(68px, 1fr) minmax(62px, 1fr);
  }

  .switch-button {
    font-size: .7rem;
    padding: 0 4px;
  }

  .quick-prompts {
    grid-template-columns: 1fr;
  }
}
