/* SOE Studio Mobile — Wow design system (Grok 4.5 era) */
:root, [data-theme="dark"] {
  --orange: #f47216;
  --gold: #EB9C05;
  --navy: #13234a;
  --ui-bg: #070a12;
  --ui-card: rgba(18, 24, 36, 0.94);
  --ui-border: rgba(255, 255, 255, 0.09);
  --ui-text: #eef2f8;
  --ui-muted: #8b98b0;
  --ui-preview: #05080e;
  --ui-nav: rgba(12, 16, 26, 0.94);
  --ui-shadow: rgba(0, 0, 0, 0.45);
  --ui-glow: rgba(244, 114, 22, 0.4);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --nav-h: 62px;
  --top-h: 56px;
  --radius: 16px;
  --ease: cubic-bezier(.2, .7, .3, 1.05);
}
[data-theme="light"] {
  --orange: #e05f05;
  --gold: #c48404;
  --navy: #243e7c;
  --ui-bg: #f3efe6;
  --ui-card: #ffffff;
  --ui-border: #d5cfc2;
  --ui-text: #1c2c52;
  --ui-muted: #5a6a84;
  --ui-preview: #e6e1d6;
  --ui-nav: rgba(255, 255, 255, 0.94);
  --ui-shadow: rgba(28, 44, 82, 0.12);
  --ui-glow: rgba(224, 95, 5, 0.28);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--ui-bg);
  color: var(--ui-text);
  font-family: 'Archivo', system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  transition: background .25s, color .25s;
}
body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: var(--safe-t);
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
  background:
    radial-gradient(900px 420px at 0% -5%, rgba(244, 114, 22, 0.16), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(36, 62, 124, 0.28), transparent 50%),
    radial-gradient(500px 280px at 50% 100%, rgba(235, 156, 5, 0.06), transparent 45%),
    var(--ui-bg);
}
[data-theme="light"] body {
  background:
    radial-gradient(900px 420px at 0% -5%, rgba(244, 114, 22, 0.1), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(36, 62, 124, 0.08), transparent 50%),
    var(--ui-bg);
}

/* Top bar — glass */
.app-top {
  height: var(--top-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: linear-gradient(180deg, rgba(18, 24, 36, 0.96), rgba(12, 16, 26, 0.9));
  border-bottom: 1px solid var(--ui-border);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
}
[data-theme="light"] .app-top {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.9));
  box-shadow: 0 4px 20px var(--ui-shadow);
}
.app-top::after {
  content: '';
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(244, 114, 22, 0.5), rgba(235, 156, 5, 0.35), transparent);
}
.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-brand img {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(244, 114, 22, 0.4), 0 4px 14px rgba(244, 114, 22, 0.25);
}
.app-brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.app-brand-name {
  font-weight: 900;
  font-size: 16px;
  letter-spacing: -.02em;
  background: linear-gradient(135deg, #f47216, #EB9C05);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.app-brand-sub {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ui-muted);
  margin-top: 2px;
}
.app-top-actions { display: flex; gap: 6px; align-items: center; }
.app-icon-btn {
  min-width: 42px;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--ui-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ui-text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s var(--ease), border-color .12s, background .12s;
}
.app-icon-btn:active {
  background: rgba(244, 114, 22, 0.14);
  border-color: rgba(244, 114, 22, 0.4);
  transform: scale(0.96);
}

/* Screens */
.app-screens { flex: 1; overflow: hidden; position: relative; }
.app-screen {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.app-screen.active { display: flex; }
.app-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 28px;
}
.app-scroll::-webkit-scrollbar { width: 0; height: 0; }

/* Bottom nav — floating glass */
.app-nav {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(8px + var(--safe-b));
  height: calc(var(--nav-h) - 4px);
  padding: 0;
  background: var(--ui-nav);
  border: 1px solid var(--ui-border);
  border-radius: 20px;
  display: flex;
  z-index: 50;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}
body { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px); }
.app-nav button {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ui-muted);
  font-family: inherit;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .01em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  padding-top: 4px;
  border-radius: 16px;
  transition: color .15s, background .15s;
  min-width: 0;
}
.app-nav button .ico { font-size: 18px; line-height: 1; }
.app-nav button.active {
  color: var(--orange);
  background: linear-gradient(180deg, rgba(244, 114, 22, 0.14), transparent);
  text-shadow: 0 0 18px rgba(244, 114, 22, 0.35);
}

/* Cards / forms */
.m-card {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--ui-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 10px 28px rgba(0, 0, 0, 0.15);
  animation: mRise .35s var(--ease) both;
}
[data-theme="light"] .m-card {
  background: var(--ui-card);
  box-shadow: 0 8px 24px var(--ui-shadow);
}
@keyframes mRise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.m-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  color: var(--ui-muted);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.m-title { font-size: 17px; font-weight: 900; margin-bottom: 4px; letter-spacing: -.02em; }
.m-sub { font-size: 12px; color: var(--ui-muted); line-height: 1.5; }

.m-input, .m-select, .m-textarea {
  width: 100%;
  padding: 13px 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  color: var(--ui-text);
  font-size: 15px;
  font-family: inherit;
  margin-bottom: 10px;
  transition: border-color .15s, box-shadow .15s;
}
[data-theme="light"] .m-input,
[data-theme="light"] .m-select,
[data-theme="light"] .m-textarea {
  background: #f7f4ed;
}
.m-textarea { min-height: 88px; resize: vertical; line-height: 1.45; font-size: 14px; }
.m-input:focus, .m-select:focus, .m-textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(244, 114, 22, 0.15);
}

.m-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.m-seg button {
  flex: 1 1 calc(33% - 6px);
  min-width: 72px;
  padding: 11px 8px;
  border-radius: 12px;
  border: 1px solid var(--ui-border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--ui-muted);
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all .14s var(--ease);
}
.m-seg.styles button {
  flex: 1 1 calc(25% - 6px);
  min-width: 64px;
  font-size: 11px;
  padding: 10px 6px;
}
.m-seg.compose button {
  flex: 1 1 calc(50% - 6px);
}
.m-seg button.active {
  background: linear-gradient(135deg, #f47216, #e05a08);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 16px var(--ui-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.m-seg button:active:not(.active) {
  transform: scale(0.97);
  border-color: rgba(244, 114, 22, 0.4);
}

.m-btn {
  width: 100%;
  padding: 15px 16px;
  border-radius: 14px;
  border: none;
  font-size: 15px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 8px;
  transition: transform .12s var(--ease), box-shadow .12s, filter .12s;
}
.m-btn:disabled { opacity: .45; cursor: not-allowed; }
.m-btn-primary {
  background: linear-gradient(135deg, #f47216 0%, #e05a08 55%, #c94a00 100%);
  color: #fff;
  box-shadow: 0 6px 22px var(--ui-glow), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.m-btn-primary:active:not(:disabled) {
  filter: brightness(.95);
  transform: translateY(1px);
}
.m-btn-secondary {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
}
.m-btn-secondary:active:not(:disabled) {
  border-color: rgba(244, 114, 22, 0.4);
  background: rgba(244, 114, 22, 0.08);
}
.m-btn-row { display: flex; gap: 8px; }
.m-btn-row .m-btn { flex: 1; }

.m-status {
  font-size: 12px;
  color: var(--ui-muted);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  padding: 11px 13px;
  line-height: 1.45;
  min-height: 40px;
  margin-bottom: 10px;
}
[data-theme="light"] .m-status { background: #f7f4ed; }
.m-status.ok { border-color: #3fb950; color: #3fb950; }
.m-status.err { border-color: #f85149; color: #f85149; }
.m-status.loading { border-color: var(--gold); color: var(--gold); }

/* Principle grid mobile */
.m-pgrid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.m-pgrid button {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid var(--ui-border);
  background: rgba(0, 0, 0, 0.22);
  color: var(--ui-muted);
  font-size: 12px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  position: relative;
  transition: transform .1s, border-color .12s, background .12s;
}
[data-theme="light"] .m-pgrid button { background: #f7f4ed; }
.m-pgrid button.active {
  border-color: var(--orange);
  background: linear-gradient(145deg, rgba(244, 114, 22, 0.22), rgba(244, 114, 22, 0.08));
  color: var(--orange);
  box-shadow: 0 0 16px rgba(244, 114, 22, 0.2);
}
.m-pgrid button:active { transform: scale(0.94); }
.m-pgrid button.done::after {
  content: '✓';
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 9px;
  color: #3fb950;
}

/* Prompt box */
.m-prompt {
  width: 100%;
  min-height: 120px;
  max-height: 220px;
  resize: vertical;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  color: var(--ui-text);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.45;
  margin-bottom: 8px;
}
[data-theme="light"] .m-prompt { background: #f7f4ed; }
.m-prompt:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(244, 114, 22, 0.12);
}
.m-prompt-hint {
  font-size: 10px;
  color: var(--ui-muted);
  line-height: 1.4;
  margin-bottom: 10px;
}

/* Preview — stage */
.m-preview-wrap {
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(244, 114, 22, 0.07), transparent 60%),
    var(--ui-preview);
  border-radius: var(--radius);
  border: 1px solid var(--ui-border);
  overflow: hidden;
  margin-bottom: 12px;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.m-preview-wrap img, .m-preview-wrap canvas {
  max-width: 100%;
  max-height: 52vh;
  display: block;
}
.m-preview-empty {
  text-align: center;
  color: var(--ui-muted);
  padding: 36px 16px;
  font-size: 13px;
}
.m-preview-empty .big {
  font-size: 44px;
  opacity: .3;
  margin-bottom: 10px;
  filter: drop-shadow(0 0 18px rgba(244, 114, 22, 0.25));
}

/* Archive grid */
.m-arch-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.m-arch-card {
  background: var(--ui-card);
  border: 1px solid var(--ui-border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .14s var(--ease), box-shadow .14s;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}
.m-arch-card:active {
  transform: scale(0.97);
}
.m-arch-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #0a0e14;
}
.m-arch-card .info { padding: 9px 11px; }
.m-arch-card .num { font-size: 14px; font-weight: 900; color: var(--orange); }
.m-arch-card .ttl {
  font-size: 11px;
  color: var(--ui-text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-arch-card .meta { font-size: 10px; color: var(--ui-muted); margin-top: 2px; }

/* Install banner */
.install-banner {
  display: none;
  background: linear-gradient(135deg, rgba(244, 114, 22, 0.16), rgba(235, 156, 5, 0.08));
  border: 1px solid rgba(244, 114, 22, 0.4);
  border-radius: 14px;
  padding: 13px;
  margin-bottom: 12px;
  gap: 10px;
  align-items: center;
  box-shadow: 0 8px 24px rgba(244, 114, 22, 0.12);
}
.install-banner.show { display: flex; }
.install-banner .txt { flex: 1; font-size: 12px; line-height: 1.45; }
.install-banner button {
  border: none;
  background: linear-gradient(135deg, #f47216, #e05a08);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--ui-glow);
}

/* Sheet */
.m-sheet-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  z-index: 80;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.m-sheet-bg.open { display: flex; }
.m-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #161d2c, #10161f);
  border-radius: 22px 22px 0 0;
  padding: 16px 16px calc(20px + var(--safe-b));
  border: 1px solid var(--ui-border);
  border-bottom: none;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
}
[data-theme="light"] .m-sheet {
  background: #fff;
}
.holiday-row { display: none; margin-bottom: 10px; }
.holiday-row.show { display: block; }
.m-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--ui-border);
  border-radius: 2px;
  margin: 0 auto 12px;
}

/* Video strip */
.m-vid-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  margin-bottom: 4px;
}
.m-vid-strip::-webkit-scrollbar { height: 0; }
.m-vid-thumb {
  flex: 0 0 72px;
  width: 72px;
  border-radius: 12px;
  border: 2px solid var(--ui-border);
  overflow: hidden;
  background: var(--ui-preview);
  cursor: pointer;
  padding: 0;
}
.m-vid-thumb img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  display: block;
}
.m-vid-thumb.active {
  border-color: var(--orange);
  box-shadow: 0 0 0 2px rgba(244, 114, 22, 0.25);
}
.m-vid-thumb .n {
  font-size: 10px;
  font-weight: 800;
  color: var(--orange);
  text-align: center;
  padding: 2px 0 4px;
  background: var(--ui-card);
}

/* Voice picker (shared with SOE_VOICES inject — mobile boosts) */
.voice-picker { max-height: 200px; }
.voice-row { border-radius: 12px !important; }

/* Desktop redirect note */
.desktop-link {
  display: block;
  text-align: center;
  font-size: 12px;
  color: var(--ui-muted);
  margin-top: 10px;
  text-decoration: none;
  padding: 10px;
  border-radius: 12px;
  border: 1px dashed var(--ui-border);
}
.desktop-link:active {
  color: var(--orange);
  border-color: rgba(244, 114, 22, 0.4);
}

@media (min-width: 900px) {
  body {
    max-width: 440px;
    margin: 0 auto;
    border-left: 1px solid var(--ui-border);
    border-right: 1px solid var(--ui-border);
    box-shadow: 0 0 100px rgba(0, 0, 0, .5);
  }
  .app-nav {
    max-width: 420px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: calc(100% - 20px);
  }
}
