/* Cineditor – mobile first. Base rules target phones; wider screens are handled at the bottom. */

.cine-app {
  --cine-accent: #f5b942;
  --cine-bg: #0e0f12;
  --cine-surface: #181a1f;
  --cine-surface-2: #23262d;
  --cine-text: #f2f3f5;
  --cine-muted: #9aa0ab;
  --cine-line: rgba(255, 255, 255, .09);
  --cine-radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--cine-text);
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}
.cine-app *, .cine-app *::before, .cine-app *::after { box-sizing: inherit; }
.cine-app [hidden] { display: none !important; }
.cine-app button { font: inherit; color: inherit; cursor: pointer; }

html.cine-lock, html.cine-lock body { overflow: hidden !important; overscroll-behavior: none; }

/* ---------- Start card ---------- */
.cine-start {
  background: radial-gradient(120% 90% at 50% 0%, #2a2d36 0%, var(--cine-bg) 70%);
  border-radius: 20px;
  padding: 32px 20px;
  text-align: center;
  border: 1px solid var(--cine-line);
}
.cine-start h2 { margin: 0 0 6px; font-size: 1.5rem; line-height: 1.2; color: var(--cine-text); }
.cine-start p { margin: 0 auto 22px; max-width: 30ch; color: var(--cine-muted); font-size: .98rem; line-height: 1.45; }
.cine-pick {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; width: 100%; max-width: 320px; padding: 0 24px;
  background: var(--cine-accent); color: #1a1405; font-weight: 700; font-size: 1.05rem;
  border-radius: 999px; cursor: pointer; position: relative; overflow: hidden;
}
.cine-pick:active { transform: scale(.98); }
.cine-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; font-size: 0; }
.cine-error { margin: 14px 0 0; color: #ff8a80; font-size: .92rem; }

/* ---------- Full-screen editor ---------- */
.cineditor {
  position: fixed; inset: 0; z-index: 999999;
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  background: var(--cine-bg);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  outline: none;
}

.cine-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; flex: 0 0 auto;
}
.cine-btn {
  min-width: 44px; min-height: 44px; padding: 0 16px;
  border: 0; border-radius: 999px; background: var(--cine-surface-2);
  font-weight: 600; font-size: .95rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.cine-btn:active { filter: brightness(1.25); }
.cine-btn[disabled] { opacity: .5; pointer-events: none; }
.cine-btn.cine-primary { background: var(--cine-accent); color: #1a1405; }
.cine-btn.cine-ghost { background: transparent; border: 1px solid var(--cine-line); }
.cine-btn.cine-icon { padding: 0; width: 44px; }

.cine-stage {
  flex: 1 1 auto; min-height: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 4px 8px; overflow: hidden;
  background: #000;
  touch-action: none;
}
.cine-canvas { max-width: 100%; max-height: 100%; display: block; border-radius: 4px; box-shadow: 0 6px 30px rgba(0,0,0,.5); }
.cine-stage.cine-cropping .cine-canvas { cursor: grab; outline: 2px solid var(--cine-accent); outline-offset: 2px; }
.cine-hint {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  background: rgba(0,0,0,.65); color: #fff; font-size: .8rem; padding: 6px 12px; border-radius: 999px;
  pointer-events: none; white-space: nowrap;
}
.cine-busy {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px;
  background: rgba(0,0,0,.55); font-weight: 600;
}
.cine-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: var(--cine-accent); animation: cine-spin .8s linear infinite; }
@keyframes cine-spin { to { transform: rotate(360deg); } }

/* ---------- Bottom panel ---------- */
.cine-panel { flex: 0 0 auto; background: var(--cine-surface); border-top: 1px solid var(--cine-line); }
.cine-pane { padding: 10px 0 6px; min-height: 148px; }

.cine-scroller {
  display: flex; gap: 10px; overflow-x: auto; padding: 4px 14px 8px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.cine-scroller::-webkit-scrollbar { display: none; }

.cine-look {
  flex: 0 0 auto; width: 76px; background: none; border: 0; padding: 0; text-align: center; scroll-snap-align: start;
}
.cine-look canvas { display: block; width: 76px; height: 76px; border-radius: 12px; border: 2px solid transparent; background: var(--cine-surface-2); }
.cine-look span { display: block; margin-top: 5px; font-size: .72rem; color: var(--cine-muted); line-height: 1.15; min-height: 2.3em; }
.cine-look.is-active canvas { border-color: var(--cine-accent); }
.cine-look.is-active span { color: var(--cine-text); font-weight: 600; }

.cine-chip {
  flex: 0 0 auto; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--cine-line);
  background: var(--cine-surface-2); font-size: .88rem; white-space: nowrap; scroll-snap-align: start;
}
.cine-chip.is-active { background: var(--cine-text); color: #111; border-color: transparent; font-weight: 600; }
.cine-chip.is-changed::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 7px; border-radius: 50%; background: var(--cine-accent); vertical-align: middle; }

.cine-sliderrow { display: flex; align-items: center; gap: 12px; padding: 8px 18px 4px; }
.cine-sliderrow label { flex: 0 0 auto; min-width: 84px; font-size: .88rem; color: var(--cine-muted); }
.cine-sliderrow output { flex: 0 0 auto; min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.cine-sliderrow input[type=range] { flex: 1 1 auto; min-width: 0; }

.cine-app input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 44px; background: transparent; margin: 0; touch-action: pan-y;
}
.cine-app input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: rgba(255,255,255,.2); }
.cine-app input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255,255,255,.2); }
.cine-app input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -12px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.cine-app input[type=range]::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.cine-app input[type=range]:focus-visible { outline: 2px solid var(--cine-accent); outline-offset: 2px; border-radius: 8px; }

.cine-actions { display: flex; gap: 8px; padding: 4px 14px 6px; }

/* ---------- Tab bar ---------- */
.cine-tabs { display: flex; border-top: 1px solid var(--cine-line); background: var(--cine-surface); }
.cine-tab {
  flex: 1; min-height: 52px; background: none; border: 0; font-size: .82rem; color: var(--cine-muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.cine-tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cine-tab.is-active { color: var(--cine-accent); font-weight: 600; }

/* ---------- Result sheet ---------- */
.cine-sheet {
  position: fixed; inset: 0; z-index: 1000000; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,.6);
}
.cine-sheet-card {
  width: 100%; max-width: 520px; background: var(--cine-surface); border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 92dvh; overflow: auto;
}
.cine-sheet-card img { display: block; width: 100%; max-height: 42dvh; object-fit: contain; border-radius: 12px; background: #000; }
.cine-sheet-card h3 { margin: 14px 0 4px; font-size: 1.15rem; color: var(--cine-text); }
.cine-sheet-card p { margin: 0 0 14px; color: var(--cine-muted); font-size: .92rem; }
.cine-sheet-actions { display: grid; gap: 10px; }
.cine-sheet-actions .cine-btn { min-height: 52px; width: 100%; text-decoration: none; color: inherit; }
.cine-sheet-actions .cine-primary { color: #1a1405; }

/* ---------- Larger screens ---------- */
@media (min-width: 820px) {
  .cine-start { padding: 56px 32px; }
  .cineditor { max-width: 560px; margin: 0 auto; left: 0; right: 0; border-left: 1px solid var(--cine-line); border-right: 1px solid var(--cine-line); }
}
@media (prefers-reduced-motion: reduce) {
  .cine-spinner { animation-duration: 2.4s; }
}

/* ---------- Full-screen app page (served without the theme) ---------- */
html.cine-appdoc, body.cine-appbody { margin: 0; padding: 0; height: 100%; background: #0e0f12; }
body.cine-appbody { overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
.cine-appmode .cine-start {
  min-height: 100vh; min-height: 100dvh; border: 0; border-radius: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(32px + env(safe-area-inset-top)) 24px calc(32px + env(safe-area-inset-bottom));
}
.cine-appmode .cine-logo { width: 88px; height: 88px; margin-bottom: 20px; filter: drop-shadow(0 8px 24px rgba(245, 185, 66, .25)); }
.cine-appmode .cine-start h2 { font-size: 1.75rem; }
.cine-points { list-style: none; margin: 28px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 340px; }
.cine-points li { font-size: .8rem; color: var(--cine-muted); border: 1px solid var(--cine-line); border-radius: 999px; padding: 6px 12px; }
@media (min-width: 820px) {
  .cine-appmode .cine-start { padding: 56px 32px; }
}
