/* DreamlinkX Tour: the Studio's own dark and emerald, sized for a phone first and an iPad second. */
:root {
  --bg: #0b0e14;
  --card: #11151d;
  --card-2: #161b25;
  --border: #232a37;
  --fg: #e7ecf3;
  --muted: #9aa5b5;
  --primary: #22b07f;
  --primary-ink: #04140d;
  --primary-soft: rgba(34, 176, 127, .14);
  --warn: #e0a233;
  --danger: #e5484d;
  --ok: #22b07f;
  --radius: 14px;
  --gap: 14px;
  --tap: 46px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 var(--sans);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(env(safe-area-inset-bottom) + 24px) env(safe-area-inset-left);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
.app { max-width: 780px; margin: 0 auto; padding: 0 16px; }

/* header */
.top { display: flex; align-items: center; gap: 12px; padding: 14px 0 10px; }
.top img { width: 36px; height: 36px; border-radius: 9px; }
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand strong { font-size: 15px; letter-spacing: .12em; }
.brand span { font: 11px var(--mono); letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.top .spacer { flex: 1; }
.link { background: none; border: 0; color: var(--muted); padding: 10px 4px; min-height: var(--tap); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--fg); }

/* cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0 0 var(--gap); }
.card h2 { margin: 0 0 4px; font-size: 17px; }
.card p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.eyebrow { font: 11px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* status strip */
.status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 10px rgba(34, 176, 127, .55); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--danger); }
.status .msg { flex: 1; min-width: 180px; font-size: 14px; }
.meter { display: flex; align-items: center; gap: 8px; font: 12px var(--mono); color: var(--muted); }
.meter i { display: block; width: 70px; height: 5px; border-radius: 3px; background: var(--card-2); overflow: hidden; }
.meter b { display: block; height: 100%; background: var(--primary); }

/* tool switch */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 5px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 var(--gap); }
.seg button { min-height: var(--tap); border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 600; }
.seg button[aria-selected="true"] { background: var(--primary-soft); color: var(--primary); box-shadow: inset 0 0 0 1px rgba(34, 176, 127, .45); }
.seg.two { grid-template-columns: repeat(2, 1fr); }
.seg button small { display: block; font: 10px var(--mono); letter-spacing: .1em; text-transform: uppercase; opacity: .75; }

/* forms */
label.field { display: block; margin: 0 0 14px; }
label.field > span, .field-title { display: block; margin: 0 0 6px; font-size: 13px; color: var(--muted); }
textarea, select, input[type=password], input[type=text] {
  width: 100%; min-height: var(--tap); padding: 11px 12px; border-radius: 11px; background: var(--card-2); border: 1px solid var(--border); color: var(--fg);
}
textarea { min-height: 112px; resize: vertical; line-height: 1.4; }
textarea:focus, select:focus, input:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row { grid-template-columns: 1fr; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.chip { min-height: 40px; padding: 8px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--card-2); color: var(--fg); cursor: pointer; font-size: 14px; }
.chip[aria-pressed="true"] { border-color: rgba(34, 176, 127, .6); background: var(--primary-soft); color: var(--primary); }
.pick { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; }
.pick .thumb { width: 84px; height: 84px; border-radius: 11px; border: 1px dashed var(--border); background: var(--card-2) center / cover no-repeat; flex: none; display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; }
.pick .col { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; min-width: 0; }
.pick .name { font: 12px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* buttons */
.btn { min-height: var(--tap); padding: 10px 18px; border-radius: 12px; border: 1px solid var(--border); background: var(--card-2); color: var(--fg); cursor: pointer; font-weight: 600; }
.btn:hover:not(:disabled) { border-color: #33405a; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.danger { color: #ff8a8e; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.wide { width: 100%; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 140px; }

/* running */
.run { border-color: rgba(34, 176, 127, .5); background: linear-gradient(180deg, rgba(34, 176, 127, .08), transparent), var(--card); }
.run .line { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.run .word { font: 13px var(--mono); color: var(--primary); }
.bar { height: 6px; border-radius: 3px; background: var(--card-2); overflow: hidden; margin: 12px 0; }
.bar b { display: block; height: 100%; width: 30%; background: var(--primary); border-radius: 3px; animation: slide 1.4s ease-in-out infinite; }
.bar.done b { animation: none; width: 100%; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
@media (prefers-reduced-motion: reduce) { .bar b { animation: none; width: 60%; } }

/* results */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--card-2); aspect-ratio: 1 / 1; padding: 0; cursor: pointer; display: block; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .badge { position: absolute; top: 7px; right: 7px; min-width: 24px; height: 24px; border-radius: 12px; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: rgba(11, 14, 20, .82); }
.tile .badge.approved { color: var(--ok); }
.tile .badge.rejected { color: var(--danger); }
.tile .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 7px; font-size: 12px; text-align: left; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .78)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 26px 8px; }
.more { margin-top: 12px; }

/* sheets and viewer */
.scrim { position: fixed; inset: 0; background: rgba(4, 6, 10, .78); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 620px; max-height: 88vh; overflow: auto; background: var(--card); border: 1px solid var(--border); border-radius: 20px 20px 0 0; padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px); }
@media (min-width: 700px) { .scrim { align-items: center; } .sheet { border-radius: 20px; } }
.sheet h2 { margin: 0 0 4px; font-size: 19px; }
.sheet ul { margin: 6px 0 12px; padding-left: 20px; }
.sheet li { margin: 3px 0; overflow-wrap: anywhere; }
.leaves { background: var(--card-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.leaves .eyebrow { margin-bottom: 6px; }
.imgrow { display: flex; align-items: center; gap: 10px; }
.imgrow img { width: 54px; height: 54px; border-radius: 8px; object-fit: cover; }
.viewer { position: fixed; inset: 0; z-index: 30; background: #05070b; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.viewer .bar-top { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.viewer .stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 8px; }
.viewer .stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.viewer .meta { padding: 10px 16px 4px; font-size: 13px; color: var(--muted); max-height: 18vh; overflow: auto; overflow-wrap: anywhere; }
.viewer .tools { display: flex; gap: 8px; padding: 8px 12px 12px; flex-wrap: wrap; }
.viewer .tools .btn { flex: 1 1 96px; padding: 10px 8px; }
.x { width: var(--tap); height: var(--tap); border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--fg); font-size: 20px; cursor: pointer; }

/* sign-in */
.login { max-width: 420px; margin: 9vh auto 0; text-align: center; }
.login img { width: 84px; height: 84px; border-radius: 20px; margin: 0 auto 14px; display: block; }
.login h1 { margin: 0 0 4px; font-size: 20px; letter-spacing: .1em; }
.login form { text-align: left; margin-top: 18px; }
.err { color: #ff8a8e; font-size: 14px; margin: 8px 0 0; min-height: 20px; }
.note { color: var(--muted); font-size: 13px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 18px); z-index: 40; max-width: min(92vw, 520px); background: #1c2230; border: 1px solid #33405a; padding: 12px 16px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); font-size: 14px; }
.toast.bad { border-color: rgba(229, 72, 77, .6); }
.noscript { padding: 20px; }

/* clips (Muapi) */
.warnbox { border-color: rgba(224, 162, 51, .45); background: linear-gradient(180deg, rgba(224, 162, 51, .07), transparent), var(--card); }
.warnbox p { margin: 4px 0 0; }
.pics { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; margin: 0 0 14px; }
.pic { position: relative; aspect-ratio: 1 / 1; padding: 0; border-radius: 10px; border: 1px solid var(--border); background: var(--card-2) center / cover no-repeat; cursor: pointer; }
.pic[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.pic .n { position: absolute; top: 4px; left: 4px; min-width: 22px; height: 22px; border-radius: 11px; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--primary); color: var(--primary-ink); }
.addpic { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.chosen { margin: 0 0 14px; display: flex; flex-direction: column; gap: 8px; }
.chosen .imgrow .name { flex: 1; min-width: 0; font: 12px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chosen .link { padding: 4px; font-size: 13px; }
.clip video { width: 100%; border-radius: 12px; background: #000; display: block; }
.cliptext { margin: 10px 0 6px; color: var(--fg); font-size: 14px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.sheet .cliptext { -webkit-line-clamp: unset; margin: 2px 0 6px; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
