:root {
  color-scheme: light;
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-muted: #eef1ef;
  --ink: #171b19;
  --muted: #66706a;
  --subtle: #89918c;
  --line: #dce2de;
  --line-strong: #cbd3ce;
  --accent: #08795b;
  --accent-hover: #06694f;
  --accent-soft: #e3f3ed;
  --danger: #c94c43;
  --shadow: 0 10px 32px rgba(20, 28, 24, 0.1);
  --radius: 6px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: 0;
}

body.modal-open {
  overflow: hidden;
}

body.auth-pending .app-shell {
  visibility: hidden;
}

button,
textarea,
select,
input {
  font: inherit;
  letter-spacing: 0;
}

.text-input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 12px;
  color: var(--ink);
}

.text-input:hover {
  border-color: #abb6af;
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 121, 91, 0.09);
  outline: 0;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  overflow: auto;
  background: var(--bg);
  padding: 28px 16px;
}

.auth-panel {
  width: min(100%, 360px);
}

.auth-panel > .brand {
  margin-bottom: 54px;
}

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

.login-form h1 {
  font-size: 27px;
}

.login-form .generate-button {
  margin-top: 4px;
}

.login-error {
  margin: -8px 0 0;
  color: var(--danger);
  font-size: 12px;
  font-weight: 650;
}

button,
select,
label[for],
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
textarea:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(8, 121, 91, 0.22);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: 208px;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fafbfa;
  padding: 22px 14px 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 19px;
  font-weight: 760;
}

.brand-mark {
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--ink);
  color: white;
}

.brand-mark svg {
  width: 17px;
  height: 17px;
}

.demo-dot {
  width: 7px;
  height: 7px;
  margin-left: -4px;
  border-radius: 50%;
  background: #e66b52;
}

.side-nav {
  display: grid;
  gap: 4px;
  margin-top: 34px;
}

.nav-item,
.mobile-nav-item {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.nav-item {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--muted);
  text-align: left;
  font-weight: 650;
}

.nav-item:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.nav-item.is-active {
  background: var(--ink);
  color: white;
}

.nav-item svg {
  width: 19px;
  height: 19px;
}

.nav-count {
  min-width: 24px;
  border-radius: 12px;
  background: rgba(102, 112, 106, 0.13);
  padding: 2px 7px;
  color: inherit;
  text-align: center;
  font-size: 12px;
}

.nav-item.is-active .nav-count {
  background: rgba(255, 255, 255, 0.17);
}

.account {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 15px;
}

.avatar {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #e9d8c7;
  color: #5f3a27;
  font-size: 13px;
  font-weight: 750;
}

.account-copy {
  display: grid;
  min-width: 0;
}

.account-copy strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy small {
  color: var(--subtle);
  font-size: 11px;
}

.main-content {
  min-height: 100vh;
  min-height: 100dvh;
  margin-left: 208px;
}

.mobile-header,
.mobile-nav {
  display: none;
}

.view {
  min-height: 100vh;
  min-height: 100dvh;
}

.view-header {
  display: flex;
  min-height: 94px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 30px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  text-transform: uppercase;
}

h1,
h2,
p {
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 25px;
  font-weight: 760;
}

h2 {
  font-size: 17px;
  font-weight: 740;
}

.service-status,
.history-total {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.service-status > .status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #e66b52;
  box-shadow: 0 0 0 4px rgba(230, 107, 82, 0.13);
}

.service-status.is-ready > .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(8, 121, 91, 0.13);
}

.service-status.is-error > .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(201, 76, 67, 0.13);
}

.workspace-grid {
  display: grid;
  min-height: calc(100vh - 94px);
  min-height: calc(100dvh - 94px);
  grid-template-columns: minmax(350px, 410px) minmax(0, 1fr);
  border-top: 1px solid var(--line);
}

.controls-pane {
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 28px 30px 32px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
  padding: 3px;
}

.mode-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 690;
}

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

.mode-button.is-active {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(23, 27, 25, 0.1);
  color: var(--ink);
}

.mode-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.field {
  display: grid;
  gap: 8px;
}

.field-label {
  color: #343b37;
  font-size: 12px;
  font-weight: 720;
}

.textarea-wrap {
  position: relative;
}

textarea {
  display: block;
  width: 100%;
  min-height: 132px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fbfcfb;
  padding: 13px 14px 30px;
  color: var(--ink);
  line-height: 1.6;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

textarea::placeholder {
  color: #9aa19d;
}

textarea:hover {
  border-color: #abb6af;
}

textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(8, 121, 91, 0.09);
  outline: 0;
}

.prompt-field.has-error textarea {
  border-color: var(--danger);
  animation: nudge 200ms ease;
}

.character-count {
  position: absolute;
  right: 10px;
  bottom: 8px;
  color: var(--subtle);
  font-size: 11px;
  pointer-events: none;
}

.option-row {
  display: grid;
  gap: 19px;
}

.select-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.select-wrap > svg:first-child {
  position: absolute;
  left: 12px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

select,
.style-input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 12px 0 38px;
  color: var(--ink);
}

select {
  appearance: none;
  cursor: pointer;
}

.style-input:hover {
  border-color: #abb6af;
}

.style-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 121, 91, 0.09);
  outline: 0;
}

.ratio-field {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.ratio-field legend {
  margin-bottom: 8px;
}

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

.ratio-switch button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 680;
}

.ratio-switch button:hover {
  border-color: #aeb9b2;
  color: var(--ink);
}

.ratio-switch button.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.generate-button {
  display: inline-flex;
  width: 100%;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 2px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 740;
  box-shadow: 0 8px 18px rgba(8, 121, 91, 0.18);
  transition: background 150ms ease, transform 150ms ease;
}

.generate-button:hover {
  background: var(--accent-hover);
}

.generate-button:active {
  transform: translateY(1px);
}

.generate-button:disabled {
  cursor: wait;
  opacity: 0.8;
}

.generate-button svg {
  width: 18px;
  height: 18px;
}

.upload-dropzone {
  display: flex;
  min-height: 96px;
  align-items: center;
  gap: 13px;
  border: 1px dashed #b6c0ba;
  border-radius: var(--radius);
  background: #fafbfa;
  padding: 15px;
  cursor: pointer;
}

.upload-dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-panel input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.upload-icon {
  display: inline-flex;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent);
}

.upload-icon svg {
  width: 20px;
  height: 20px;
}

.upload-copy {
  display: grid;
  gap: 2px;
}

.upload-copy strong {
  font-size: 13px;
}

.upload-copy small {
  color: var(--muted);
  font-size: 11px;
}

.upload-preview {
  position: relative;
  min-height: 96px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--ink);
}

.upload-preview img {
  display: block;
  width: 100%;
  height: 126px;
  object-fit: cover;
  opacity: 0.72;
}

.upload-preview > span {
  position: absolute;
  right: 154px;
  bottom: 10px;
  left: 12px;
  overflow: hidden;
  color: white;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mask-edit-button {
  position: absolute;
  right: 10px;
  bottom: 9px;
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 4px;
  background: rgba(17, 21, 19, 0.76);
  padding: 0 10px;
  color: white;
  cursor: pointer;
  font-size: 11px;
  font-weight: 680;
  backdrop-filter: blur(7px);
}

.mask-edit-button.is-ready {
  border-color: rgba(120, 223, 187, 0.45);
  background: rgba(8, 121, 91, 0.88);
}

.mask-edit-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.mask-edit-button svg {
  width: 15px;
  height: 15px;
}

.icon-button {
  display: inline-flex;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  border-color: #aeb7b1;
  color: var(--ink);
}

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

.icon-button.on-media {
  position: absolute;
  top: 9px;
  right: 9px;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(18, 22, 20, 0.7);
  color: white;
  backdrop-filter: blur(7px);
}

.result-pane {
  display: grid;
  min-width: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--surface-muted);
  padding: 24px 30px;
}

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
}

.result-actions {
  display: flex;
  gap: 7px;
}

.result-stage {
  display: flex;
  min-height: 0;
  align-items: center;
  justify-content: center;
}

.result-frame {
  position: relative;
  width: min(100%, 620px);
  max-height: calc(100vh - 245px);
  max-height: calc(100dvh - 245px);
  overflow: hidden;
  margin: 0;
  border-radius: var(--radius);
  background: #dfe4e1;
  box-shadow: var(--shadow);
}

.result-frame.ratio-1-1 {
  aspect-ratio: 1 / 1;
}

.result-frame.ratio-3-4 {
  aspect-ratio: 3 / 4;
}

.result-frame.ratio-4-3 {
  aspect-ratio: 4 / 3;
}

.result-frame.ratio-16-9 {
  aspect-ratio: 16 / 9;
}

.result-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.generation-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(21, 26, 23, 0.76);
  color: white;
  backdrop-filter: blur(8px);
}

.generation-overlay strong {
  margin-top: 14px;
  font-size: 15px;
}

.generation-overlay small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
}

.loader {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.result-caption {
  width: min(100%, 620px);
  margin: 18px auto 0;
}

.result-caption p {
  margin: 0 0 4px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 660;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-caption > span {
  color: var(--muted);
  font-size: 11px;
}

.history-view {
  padding-bottom: 40px;
}

.usage-view {
  padding-bottom: 40px;
}

.history-header {
  border-bottom: 1px solid var(--line);
}

.history-total strong {
  color: var(--ink);
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  padding: 28px 30px;
}

.history-item {
  min-width: 0;
}

.history-media {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--radius);
  background: #e2e6e3;
  cursor: pointer;
}

.history-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 220ms ease;
}

.history-media:hover img {
  transform: scale(1.02);
}

.history-media .history-delete {
  position: absolute;
  top: 9px;
  right: 9px;
  border-color: rgba(255, 255, 255, 0.26);
  background: rgba(17, 21, 19, 0.7);
  color: white;
  opacity: 0;
  backdrop-filter: blur(7px);
  transition: opacity 150ms ease;
}

.history-media:hover .history-delete,
.history-delete:focus-visible {
  opacity: 1;
}

.history-copy {
  padding-top: 10px;
}

.history-copy p {
  margin: 0 0 4px;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-copy span {
  color: var(--muted);
  font-size: 11px;
}

.empty-history {
  display: grid;
  min-height: 320px;
  grid-column: 1 / -1;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.empty-history svg {
  width: 32px;
  height: 32px;
  margin-bottom: 8px;
}

.usage-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.usage-metric {
  display: grid;
  min-height: 116px;
  align-content: center;
  gap: 7px;
  border-right: 1px solid var(--line);
  padding: 20px 30px;
}

.usage-metric:last-child {
  border-right: 0;
}

.usage-metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.usage-metric strong {
  font-size: 27px;
  line-height: 1;
}

.usage-metric small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.usage-metric small.is-warning {
  color: #a44732;
  font-weight: 700;
}

.usage-table {
  padding: 26px 30px;
}

.usage-table-head,
.usage-user-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 90px 90px 150px;
  align-items: center;
  gap: 16px;
}

.usage-table-head {
  min-height: 36px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
}

.usage-user-row {
  min-height: 66px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.usage-user {
  display: grid;
  min-width: 0;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.usage-user .avatar {
  background: #dce8e3;
  color: #285245;
}

.usage-user-copy {
  display: grid;
  min-width: 0;
}

.usage-user-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usage-user-copy small,
.usage-last {
  color: var(--muted);
  font-size: 11px;
}

.usage-number {
  font-variant-numeric: tabular-nums;
  font-weight: 680;
}

.usage-loading {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: 22px;
  max-width: min(340px, calc(100vw - 32px));
  transform: translateY(16px);
  border-radius: var(--radius);
  background: var(--ink);
  padding: 11px 14px;
  color: white;
  font-size: 12px;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.mask-dialog {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #161a18;
  color: white;
}

.mask-editor-shell {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-rows: 64px minmax(0, 1fr) auto;
}

.mask-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
  padding: 0 22px;
}

.mask-editor-header .eyebrow {
  color: rgba(255, 255, 255, 0.55);
}

.mask-editor-header h2 {
  color: white;
}

.mask-editor-header .icon-button,
.mask-tools .icon-button {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.7);
}

.mask-editor-header .icon-button:hover,
.mask-tools .icon-button:hover,
.mask-tools .icon-button.is-active {
  border-color: rgba(255, 255, 255, 0.38);
  background: white;
  color: var(--ink);
}

.mask-canvas-stage {
  display: flex;
  min-width: 0;
  min-height: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 18px;
}

#maskCanvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 2px;
  background: #252a27;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.3);
  cursor: crosshair;
  touch-action: none;
}

#maskCanvas.is-eraser {
  cursor: cell;
}

.mask-editor-toolbar {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
  background: #1b201d;
  padding: 11px 22px;
}

.mask-tools {
  display: flex;
  align-items: center;
  gap: 7px;
}

.mask-size {
  display: inline-flex;
  min-width: 126px;
  height: 36px;
  align-items: center;
  gap: 8px;
  margin-left: 5px;
  color: rgba(255, 255, 255, 0.65);
}

.mask-size svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.mask-size input {
  width: 100px;
  accent-color: #71d6b2;
  cursor: pointer;
}

.mask-confirm-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  background: white;
  padding: 0 18px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 740;
}

.mask-confirm-button:hover {
  background: #e8ece9;
}

.mask-confirm-button svg {
  width: 17px;
  height: 17px;
}

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

@keyframes nudge {
  50% {
    transform: translateX(3px);
  }
}

@media (max-width: 1060px) {
  .workspace-grid {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .controls-pane,
  .result-pane {
    padding-right: 22px;
    padding-left: 22px;
  }

  .history-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: calc(66px + env(safe-area-inset-bottom));
  }

  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  .mobile-header {
    position: sticky;
    top: 0;
    z-index: 15;
    display: flex;
    height: 58px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background: rgba(250, 251, 250, 0.94);
    padding: 0 16px;
    backdrop-filter: blur(12px);
  }

  .mobile-header .brand {
    font-size: 18px;
  }

  .mobile-header .brand-mark {
    width: 28px;
    height: 28px;
  }

  .demo-badge {
    border: 1px solid #e8c6bb;
    border-radius: 12px;
    background: #fff2ed;
    padding: 3px 8px;
    color: #9b4735;
    font-size: 10px;
    font-weight: 700;
  }

  .view,
  .workspace-grid {
    min-height: auto;
  }

  .view-header {
    min-height: 72px;
    padding: 13px 16px;
  }

  .view-header h1 {
    font-size: 21px;
  }

  .service-status {
    display: none;
  }

  .workspace-grid {
    display: block;
  }

  .controls-pane {
    gap: 18px;
    border-right: 0;
    padding: 18px 16px 20px;
  }

  textarea {
    min-height: 112px;
  }

  .option-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .generate-button {
    margin-top: 2px;
  }

  .result-pane {
    min-height: 520px;
    border-top: 1px solid var(--line);
    padding: 18px 16px 24px;
  }

  .result-frame {
    max-height: none;
  }

  .result-toolbar {
    padding-bottom: 14px;
  }

  .history-view {
    padding-bottom: 10px;
  }

  .usage-view {
    padding-bottom: 10px;
  }

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

  .usage-metric {
    min-height: 94px;
    border-bottom: 1px solid var(--line);
    padding: 16px;
  }

  .usage-metric:nth-child(2) {
    border-right: 0;
  }

  .usage-metric:nth-child(3),
  .usage-metric:nth-child(4) {
    border-bottom: 0;
  }

  .usage-metric strong {
    font-size: 23px;
  }

  .usage-table {
    padding: 18px 16px 24px;
  }

  .usage-table-head,
  .usage-user-row {
    grid-template-columns: minmax(112px, 1fr) 42px 42px 68px;
    gap: 8px;
  }

  .usage-user-row {
    min-height: 62px;
  }

  .usage-user {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 8px;
  }

  .usage-user .avatar {
    width: 30px;
    height: 30px;
  }

  .history-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 10px;
    padding: 18px 16px 24px;
  }

  .history-media .history-delete {
    width: 32px;
    height: 32px;
    opacity: 1;
  }

  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 30;
    display: grid;
    height: calc(62px + env(safe-area-inset-bottom));
    grid-template-columns: repeat(var(--mobile-nav-items, 2), 1fr);
    border-top: 1px solid var(--line);
    background: rgba(250, 251, 250, 0.96);
    padding: 5px 18px env(safe-area-inset-bottom);
    backdrop-filter: blur(14px);
  }

  .mobile-nav.has-admin {
    --mobile-nav-items: 3;
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--subtle);
    font-size: 10px;
    font-weight: 680;
  }

  .mobile-nav-item svg {
    width: 19px;
    height: 19px;
  }

  .mobile-nav-item.is-active {
    color: var(--accent);
  }

  .toast {
    right: 16px;
    bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .mask-editor-shell {
    grid-template-rows: 58px minmax(0, 1fr) auto;
  }

  .mask-editor-header {
    padding: 0 14px;
  }

  .mask-canvas-stage {
    padding: 10px;
  }

  .mask-editor-toolbar {
    display: grid;
    min-height: 118px;
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  }

  .mask-tools {
    justify-content: space-between;
  }

  .mask-tools .icon-button {
    width: 38px;
    height: 38px;
  }

  .mask-size {
    min-width: 90px;
    margin-left: 0;
  }

  .mask-size input {
    width: min(80px, 20vw);
  }

  .mask-confirm-button {
    width: 100%;
  }
}

@media (max-width: 370px) {
  .mode-button {
    gap: 5px;
    font-size: 12px;
  }

  .ratio-switch {
    gap: 4px;
  }

  .ratio-switch button {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
