/* iPhone layout: home screen and a touch-first editor. Everything respects the safe areas. */

body.mobile { position: fixed; inset: 0; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
body.mobile input, body.mobile textarea { user-select: text; -webkit-user-select: text; }

/* ---------- home ---------- */
.m-home { height: 100%; display: flex; flex-direction: column; padding: var(--safe-top) var(--safe-right) 0 var(--safe-left); }
.m-home-top { display: flex; align-items: center; gap: 10px; padding: 14px 16px 8px; }
.m-home-top .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
.m-home-top h1 { flex: 1; margin: 0; font-size: 24px; letter-spacing: -0.01em; }
.m-home-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px calc(24px + var(--safe-bottom)); }
.m-home-body h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); margin: 26px 0 10px; }
.m-new {
  width: 100%; display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: 20px; border: 0; text-align: left;
  background: linear-gradient(135deg, #ff4f6d, #ffb020); color: #fff; box-shadow: 0 10px 30px rgba(255, 99, 72, 0.25);
}
.m-new:active { transform: scale(0.985); }
.m-new-icon { width: 54px; height: 54px; border-radius: 16px; background: rgba(255, 255, 255, 0.22); display: flex; align-items: center; justify-content: center; }
.m-new b { display: block; font-size: 19px; }
.m-new small { display: block; opacity: 0.9; font-size: 14px; margin-top: 2px; }
.install-hint { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; padding: 12px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); color: var(--dim); }
.install-hint p { flex: 1; margin: 0; }
.install-hint b { color: var(--text); }
.mobile .project-card { padding: 10px; }
.mobile .project-thumb { width: 88px; height: 58px; }
.mobile .project-menu .icon-btn { min-width: 40px; height: 40px; }

/* ---------- editor ---------- */
.m-editor {
  height: 100%; display: grid; grid-template-rows: auto minmax(120px, 1fr) auto auto auto;
  grid-template-columns: minmax(0, 1fr); width: 100%;
  padding: var(--safe-top) var(--safe-right) 0 var(--safe-left); background: var(--bg);
}
.m-top { display: flex; align-items: center; gap: 6px; padding: 6px 10px; min-height: 50px; }
.m-back { display: flex; align-items: center; gap: 2px; border: 0; background: transparent; color: var(--accent); font-weight: 600; padding: 8px 4px; }
.m-name { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 2px; border: 0; background: transparent; font-weight: 700; font-size: 16px; padding: 6px; }
.m-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-name .icon { color: var(--faint); }

.m-preview { position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; background: #000; overflow: hidden; }
.m-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center; color: var(--dim); background: #000; }
.m-empty p { margin: 0; max-width: 18em; }

.m-transport { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 6px 12px; }
.m-time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--dim); white-space: nowrap; }
.m-transport-mid { display: flex; align-items: center; gap: 14px; }
.m-play { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--text); color: #111; display: flex; align-items: center; justify-content: center; }
.m-more { justify-self: end; }

/* ---------- strip ---------- */
.m-strip { position: relative; min-width: 0; height: 166px; background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.ms-scroll { height: 100%; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; touch-action: pan-x; overscroll-behavior-x: contain; }
.ms-scroll::-webkit-scrollbar { display: none; }
.ms-content { position: relative; height: 100%; }
.ms-ruler { position: relative; height: 20px; }
.ms-tick { position: absolute; top: 3px; font-size: 10px; color: var(--faint); transform: translateX(-50%); font-variant-numeric: tabular-nums; }
.ms-tick::after { content: ""; position: absolute; left: 50%; top: 13px; width: 1px; height: 4px; background: var(--faint); }
.ms-lane { position: relative; }
.ms-lane.titles { height: 30px; }
.ms-lane.video { height: 76px; }
.ms-lane.audio { height: 36px; }
.ms-clip { position: absolute; top: 4px; height: 66px; border-radius: 9px; overflow: hidden; background: var(--clip); border: 1px solid rgba(255, 255, 255, 0.2); touch-action: pan-x; }
.ms-clip.selected { border: 3px solid var(--accent); overflow: visible; z-index: 2; }
.ms-film { position: absolute; inset: 0; display: flex; overflow: hidden; border-radius: 7px; }
.ms-film img { width: 46px; height: 100%; object-fit: cover; flex: none; pointer-events: none; }
.ms-clip-label { position: absolute; left: 4px; bottom: 3px; display: flex; gap: 4px; align-items: center; font-size: 10.5px; font-weight: 700; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8); pointer-events: none; }
.ms-clip-label span:first-child { background: rgba(0, 0, 0, 0.55); padding: 0 4px; border-radius: 4px; }
.ms-handle { display: none; position: absolute; top: -3px; bottom: -3px; width: 22px; background: var(--accent); touch-action: none; align-items: center; justify-content: center; z-index: 3; }
.ms-handle span { width: 3px; height: 22px; border-radius: 2px; background: rgba(0, 0, 0, 0.5); }
.ms-clip.selected .ms-handle { display: flex; }
.ms-handle.left { left: -14px; border-radius: 9px 0 0 9px; }
.ms-handle.right { right: -14px; border-radius: 0 9px 9px 0; }
.ms-tr {
  position: absolute; top: 22px; z-index: 4; width: 32px; height: 32px; margin-left: -16px; padding: 0; border-radius: 9px;
  border: 1px solid var(--line-2); background: #2b2b33; color: var(--text); display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.ms-tr.on { border-color: var(--accent); }
.ms-tr.near-selected { display: none; }
.ms-tr .tr-glyph svg { width: 28px; height: 28px; }
.ms-add { position: absolute; top: 14px; width: 48px; height: 48px; border-radius: 14px; border: 1px dashed var(--line-2); background: var(--panel-2); color: var(--text); display: flex; align-items: center; justify-content: center; }
.ms-item { position: absolute; top: 3px; bottom: 3px; display: flex; align-items: center; gap: 4px; padding: 0 8px; border-radius: 7px; font-size: 11px; font-weight: 650; white-space: nowrap; overflow: hidden; touch-action: pan-x; }
.ms-item.title { background: var(--title); }
.ms-item.audio { background: var(--audio); }
.ms-item.muted { filter: saturate(0.2) brightness(0.7); }
.ms-item span { position: relative; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
.ms-item .icon { position: relative; }
.ms-item.selected { box-shadow: 0 0 0 2px var(--accent); z-index: 2; }
.ms-item.lifted { opacity: 0.85; box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.ms-wave { position: absolute; inset: 2px 0; display: flex; align-items: center; gap: 1px; padding: 0 2px; opacity: 0.45; }
.ms-wave i { flex: 1; min-width: 1px; background: #fff; border-radius: 1px; }
.ms-playhead { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 6px rgba(0, 0, 0, 0.8); pointer-events: none; z-index: 6; }
.ms-playhead::before { content: ""; position: absolute; top: 0; left: -5px; border: 6px solid transparent; border-top-color: #fff; }
.ms-time { display: none; }
.ms-reorder { position: absolute; inset: 0; z-index: 10; background: var(--panel); display: flex; flex-direction: column; justify-content: center; }
.ms-reorder-hint { text-align: center; color: var(--dim); font-size: 12px; margin-bottom: 8px; }
.ms-reorder-row { position: relative; height: 84px; touch-action: none; }
.ms-reorder-done { position: absolute; right: 12px; top: 8px; display: none; }
.ms-reorder.sticky .ms-reorder-done { display: inline-flex; }
.ms-rtile { touch-action: none; }
.ms-rtile { position: absolute; left: 0; top: 10px; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; background: var(--clip); display: flex; align-items: center; justify-content: center; transition: transform 0.16s ease; border: 2px solid rgba(255, 255, 255, 0.15); }
.ms-rtile img { width: 100%; height: 100%; object-fit: cover; }
.ms-rtile.lifted { transition: none; z-index: 2; border-color: var(--accent); box-shadow: var(--shadow); }

/* ---------- toolbar ---------- */
.m-tools { display: flex; align-items: stretch; gap: 4px; padding: 6px 6px calc(6px + var(--safe-bottom)); background: var(--panel); min-height: 74px; }
.m-tools-row { flex: 1; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.m-tools-row::-webkit-scrollbar { display: none; }
.tool { flex: 1 0 auto; min-width: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px 4px; border: 0; border-radius: 12px; background: transparent; color: var(--text); touch-action: manipulation; }
.tool:active { background: rgba(255, 255, 255, 0.08); }
.tool-label { font-size: 11px; font-weight: 600; color: var(--dim); }
.tool.danger, .tool.danger .tool-label { color: var(--danger); }
.m-tools-done { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 60px; border: 0; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; }

/* ---------- bottom sheets ---------- */
.sheet-backdrop { align-items: flex-end; pointer-events: none; }
.sheet-backdrop.blocking { pointer-events: auto; }
.sheet-backdrop.in { background: transparent; }
.sheet-backdrop.blocking.in { background: rgba(0, 0, 0, 0.5); }
.sheet {
  pointer-events: auto; width: 100%; max-height: min(47dvh, 460px); display: flex; flex-direction: column;
  margin-bottom: var(--kb, 0px); background: var(--panel); border-top: 1px solid var(--line-2); border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5); padding-bottom: var(--safe-bottom);
  transform: translateY(100%); transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.backdrop.in .sheet { transform: none; }
.sheet.small, .sheet.tall { max-height: min(78dvh, 640px); }
.sheet .export-action { bottom: -18px; }
.sheet-head { position: relative; padding: 16px 12px 6px 18px; }
.sheet-grabber { position: absolute; left: 50%; top: 6px; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: var(--panel-3); }
.sheet-head .close { min-width: auto; padding: 0 10px; }
.sheet-head .done { color: var(--accent); font-weight: 700; font-size: 16px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 18px 18px; overscroll-behavior: contain; }
.mobile .sl-range { height: 36px; }
.mobile input[type="range"]::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -12px; }
.mobile .seg-btn { min-height: 38px; }
.mobile .chip { min-height: 36px; padding: 6px 14px; }
.mobile .swatch { width: 34px; height: 34px; }
.mobile .trim-track { height: 72px; }
.mobile .trim-handle { width: 26px; }
.mobile .trim-handle.in { left: -13px; }
.mobile .trim-handle.out { right: -13px; }
.preset-grid.m { grid-template-columns: repeat(3, 1fr); }
.mobile .preset-card { border: 0; background: transparent; padding: 0; text-align: left; color: var(--text); }
.mobile .modal { border-radius: 20px; }
.mobile .busy { bottom: calc(96px + var(--safe-bottom)); }
.mobile .toasts { bottom: calc(96px + var(--safe-bottom)); }
.mobile .update-banner { width: calc(100vw - 24px); }
.mobile .update-banner span { flex: 1; }

@media (orientation: landscape) and (max-height: 500px) {
  .m-editor { grid-template-rows: auto minmax(80px, 1fr) auto auto auto; }
  .m-strip { height: 140px; }
  .ms-lane.titles { height: 24px; }
  .ms-lane.audio { height: 28px; }
  .m-tools { min-height: 60px; }
}
