:root {
  --bg: #0b0b0c; --card: #131314; --card2: #19191b; --field: #0e0e0f; --line: #29261f; --text: #f1ede3; --muted: #99948a;
  --gold: #d8bb74; --gold-line: rgba(216,187,116,.55); --gold-soft: rgba(216,187,116,.12); --on-gold: #1c1508;
  --grad: linear-gradient(135deg, #f2dfa4 0%, #d6b35c 48%, #b68c37 100%); --bad: #e08a7d;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Sukhumvit Set", "Noto Sans Thai", sans-serif;
  background: radial-gradient(90% 340px at 50% -90px, rgba(216,187,116,.13) 0%, transparent 72%), var(--bg);
  color: var(--text); line-height: 1.5; min-height: 100dvh;
  max-width: 620px; margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px calc(170px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--card2); border-radius: 12px; padding: 10px 16px; min-height: 44px; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
input[type=text], input[type=password], input[type=tel], select, textarea {
  width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font-size: 16px; min-width: 0;
}
textarea { resize: vertical; min-height: 84px; }
input[type=range] { width: 100%; accent-color: var(--gold); height: 32px; }

.brand { text-align: center; margin-bottom: 22px; }
.brand img { display: block; width: 144px; height: auto; margin: 0 auto 6px; filter: drop-shadow(0 10px 22px rgba(0,0,0,.55)); }
.brand h1 { font-family: "Optima", "Avenir Next", -apple-system, sans-serif; font-size: 17px; font-weight: 600; letter-spacing: .34em; padding-left: .34em; color: var(--gold); }
.brand p { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.brand::after { content: ""; display: block; width: 120px; height: 1px; margin: 14px auto 0; background: linear-gradient(90deg, transparent, var(--gold-line), transparent); }

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.card h2 .ico { color: var(--gold); margin-right: 9px; }
.card h3 { font-size: 14px; color: var(--muted); font-weight: 600; margin: 14px 0 8px; }
.muted { color: var(--muted); font-size: 13px; }
.warn { border-color: var(--gold-line); background: var(--gold-soft); font-size: 14px; }
.err { color: var(--bad); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 140px; }

.drop-card { border: 1px solid var(--gold-line); border-radius: 18px; margin-bottom: 14px; background: linear-gradient(180deg, var(--gold-soft), transparent 75%), var(--card); }
.drop { display: block; text-align: center; padding: 30px 16px; cursor: pointer; border-radius: 18px; }
.drop b { display: block; font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.drop > .ico { display: block; width: 40px; height: 40px; margin: 0 auto 12px; color: var(--gold); stroke-width: 1.2; }
.drop input, .filebtn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within, .filebtn:focus-within { outline: 2px solid var(--gold); }
.filebtn { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--card2); cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button.on, .choice.on, .fonts button.on { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); font-weight: 600; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice { text-align: left; padding: 12px; height: 100%; display: flex; flex-direction: column; justify-content: flex-start; }
.choice b { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.choice b .ico { color: var(--gold); width: 18px; height: 18px; }
.choice small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; line-height: 1.45; margin-top: 6px; }
.fonts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fonts button { padding: 8px 4px; line-height: 1.4; }
.fonts button b { display: block; font-size: 22px; font-weight: inherit; }
.fonts button small { font-size: 11px; opacity: .75; font-family: -apple-system, sans-serif; display: block; }
.preview { display: block; margin: 0 auto; max-width: 100%; max-height: 340px; border-radius: 14px; }

.switch { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; cursor: pointer; }
.switch input { appearance: none; width: 50px; height: 30px; border-radius: 30px; background: #3a364a; position: relative; flex: none; cursor: pointer; }
.switch input::after { content: ""; position: absolute; width: 24px; height: 24px; top: 3px; left: 3px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--gold); }
.switch input:checked::after { transform: translateX(20px); }

.primary { background: var(--grad); border: 0; color: var(--on-gold); font-weight: 700; }
.big { width: 100%; font-size: 17px; letter-spacing: .02em; padding: 15px; border-radius: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.5); }
.danger { color: var(--bad); }

/* ไล่เงาด้านล่าง ไม่ให้เนื้อหาโผล่ลอดหลังปุ่มและเมนู */
body::after { content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: calc(104px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 38%); pointer-events: none; z-index: 4; }
#cta { position: fixed; left: 50%; transform: translateX(-50%); width: min(100% - 32px, 588px); bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 5; }
#cta .big:disabled { opacity: 1; background: #1d1c1a; border: 1px solid var(--line); color: var(--muted); }
/* แถบอัปโหลด อยู่แทนปุ่มตัดระหว่างส่งไฟล์ */
#upload { position: fixed; left: 50%; transform: translateX(-50%); width: min(100% - 32px, 588px); bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 6; background: #181714; border: 1px solid var(--gold-line); border-radius: 16px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.6); }
#upload .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#upload .head b { font-size: 17px; font-variant-numeric: tabular-nums; }
#upload .head button { min-height: 36px; padding: 5px 14px; font-size: 13px; }
#upload .bar { height: 14px; margin-top: 8px; }
#upload .bar div { transition: width .3s; }
#upload p { margin-top: 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
#upload p.file { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; font-size: 12px; }
#upload p.hint { margin-top: 2px; font-size: 12px; color: var(--gold); }
#upload .row { margin-top: 10px; }
#upload.waiting .bar div { background: repeating-linear-gradient(45deg, #d6b35c 0 12px, #f2dfa4 12px 24px); background-size: 34px 34px; animation: upload-wait .8s linear infinite; }
@keyframes upload-wait { to { background-position: 34px 0; } }
#upload.done { border-color: #3ddc84; }
#upload.done .head b { color: #3ddc84; }
#upload.done .bar div { background: #3ddc84; }
#upload.failed { border-color: var(--bad); }
#upload.failed .head b { color: var(--bad); }
#upload.failed .bar div { background: var(--bad); }
body.is-uploading { padding-bottom: calc(290px + env(safe-area-inset-bottom)); }
body.is-uploading #cta { display: none; }
/* แถบรอคลิปจากเครื่อง ตำแหน่งเดียวกับแถบอัปโหลด */
body.is-picking { padding-bottom: calc(290px + env(safe-area-inset-bottom)); }
body.is-picking #cta { display: none; }
#picking { position: fixed; left: 50%; transform: translateX(-50%); width: min(100% - 32px, 588px); bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 7; background: #181714; border: 1px solid var(--gold-line); border-radius: 16px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.6); }
#picking .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#picking .head b { font-size: 17px; }
#picking .head button { min-height: 36px; padding: 5px 14px; font-size: 13px; }
#picking .bar { height: 14px; margin-top: 8px; }
#picking p { margin-top: 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
/* ไม่รู้เปอร์เซ็นต์ จึงใช้แถบเลื่อนไปมา ให้เห็นว่ายังรออยู่ */
.bar.waiting div { width: 35%; animation: picking-slide 1.1s ease-in-out infinite alternate; }
@keyframes picking-slide { from { transform: translateX(0); } to { transform: translateX(186%); } }
#tabs { position: fixed; left: 50%; transform: translateX(-50%); width: min(100% - 20px, 600px); bottom: calc(10px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; background: #111112; border: 1px solid var(--line); border-radius: 20px; padding: 6px; z-index: 6; }
#tabs button { border: 0; background: none; color: var(--muted); font-size: 12.5px; padding: 8px 7px 6px; border-radius: 15px; }
#tabs button .ico { display: block; width: 22px; height: 22px; margin: 0 auto 3px; }
#tabs button.on { background: var(--gold-soft); color: var(--gold); font-weight: 600; }
#tabs.five { grid-template-columns: repeat(5, 1fr); gap: 3px; }
#tabs.five button { font-size: 11.5px; padding-left: 2px; padding-right: 2px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top)); width: max-content; max-width: calc(100% - 32px);
  background: #1f1d18; border: 1px solid var(--gold-line); border-radius: 14px; padding: 10px 16px; font-size: 14px; z-index: 20; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }

.steps { list-style: none; padding: 0; }
.steps li { display: flex; gap: 10px; padding: 5px 0; }
.steps li > span:first-child { width: 18px; text-align: center; color: var(--gold); flex: none; }
.steps li.error > span:first-child { color: var(--bad); }
.steps li.wait, .steps li.skip { color: var(--muted); }
.steps li small { display: block; color: var(--muted); }
.bar { height: 6px; background: #24221d; border-radius: 10px; overflow: hidden; margin-top: 10px; }
.bar div { height: 100%; background: var(--grad); transition: width .4s; }

video { width: 100%; max-height: 70dvh; background: #000; border-radius: 16px; display: block; }
a.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border-radius: 12px; padding: 10px 16px; text-decoration: none; color: var(--text); }
a.btn.primary { color: var(--on-gold); }
.seg { border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-top: 8px; }
.seg.off { opacity: .5; }
.seg > label { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.seg > label > input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--gold); }
.seg .row { margin-top: 6px; }
.seg select { flex: 1 1 120px; width: auto; }
details summary { cursor: pointer; padding: 10px 0; font-weight: 700; }

.work { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; }
.work img, .work .ph { width: 64px; height: 90px; object-fit: cover; border-radius: 10px; background: #000; flex: none; display: grid; place-items: center; }
.work span { overflow-wrap: anywhere; min-width: 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.card p.row { margin-top: 12px; }
textarea::placeholder { white-space: pre-line; }
.designer { margin-top: 14px; }
.designer-tabs { margin-top: 14px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.designer-tabs button { flex: 1 1 0; margin-bottom: 8px; }
.choice .thumb { width: 26px; height: 40px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); flex: none; }
.choice b span { min-width: 0; overflow-wrap: anywhere; }
.choice.add { border: 1px dashed var(--gold-line); background: transparent; }
.choice.add b { color: var(--gold); }
.choice.add.on { border-color: var(--gold); border-style: solid; background: var(--gold-soft); }
.card p.note { margin-top: 12px; }
.choices.scripts .choice { padding: 10px; min-width: 0; }
.choices.scripts .choice:first-child, .choices.scripts .choice:last-child { grid-column: 1 / -1; }
.choices.scripts b { font-size: 14px; line-height: 1.35; }
.choices.scripts small { margin-top: 4px; }
.choice small.example { display: none; color: var(--gold); margin-top: 8px; }
.choice.on small.example { display: block; }
.choices.scripts .choice { position: relative; }
.choice .tag { position: absolute; top: -7px; right: 8px; padding: 0 7px; border-radius: 99px; font-size: 10px; line-height: 15px; font-weight: 600; color: #fff; pointer-events: none; }
.tofu { --stage: #3560d8; } .mofu { --stage: #35796f; } .bofu { --stage: #9c7128; }
.choice .tag.tofu, .choice .tag.mofu, .choice .tag.bofu { background: var(--stage); }
.funnel { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 10px; }
.funnel button { width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 66px; padding: 10px 4px; border: 0; border-radius: 0; background: var(--stage); color: #fff; line-height: 1.35; text-align: center; clip-path: polygon(0 0, 100% 0, 91% 100%, 9% 100%); transition: opacity .15s; }
.funnel button:nth-child(2) { width: 82%; }
.funnel button:nth-child(3) { width: 64%; clip-path: polygon(0 0, 100% 0, 88% 100%, 12% 100%); }
.funnel button b { font-size: 15px; white-space: nowrap; }
.funnel button span { font-size: 13px; }
.funnel.picked button:not(.on) { opacity: .32; }
.funnel button.on b::before { content: "✓ "; }
.card p.audience { margin-top: 10px; font-size: 14px; line-height: 1.65; }
.card p.kpi-note { margin-top: 8px; }
.flow, .kpis { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.flow li, .kpis li { border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 13px; }
.flow { column-gap: 22px; }
.flow li { position: relative; border-color: var(--gold-line); }
.flow li:not(:last-child)::after { content: "→"; position: absolute; left: calc(100% + 5px); top: 4px; color: var(--gold); }
/* กรอบโฟกัสปกติถูกรูปกรวยตัดหาย จึงใช้ขีดเส้นใต้แทน */
.funnel button:focus-visible b { text-decoration: underline; text-underline-offset: 3px; }
.mystyle, .newstyle { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.mystyle .row { margin-top: 8px; }
.newstyle > p { margin: 10px 0; }
.save-look { border-color: var(--gold-line); color: var(--gold); }
.mystyle > .save-look { width: 100%; }
.mystyle > .save-look + p { margin-top: 8px; }
.seg .tools { margin-top: 8px; }
.seg .tools button { flex: 1 1 auto; padding: 8px 10px; font-size: 13px; }
.add-segment { width: 100%; margin-top: 12px; border-style: dashed; }
.picker { margin-top: 12px; padding: 12px; border: 1px solid var(--gold-line); border-radius: 14px; }
.picker .row { margin-top: 8px; }
.pieces { max-height: 460px; overflow-y: auto; margin-top: 10px; }
.piece { border-top: 1px solid var(--line); padding: 10px 0; font-size: 14px; overflow-wrap: anywhere; }
video.mini { max-height: 300px; margin-top: 10px; }
.times input { width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font-size: 16px; }
.beauty-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.beauty-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px 6px; min-height: 78px; font-size: 12px; line-height: 1.3; }
.beauty-item .ico { width: 24px; height: 24px; color: var(--muted); }
.beauty-item small { font-size: 11px; color: var(--gold); min-height: 14px; }
.beauty-item.active { border-color: var(--gold-line); }
.beauty-item.active .ico { color: var(--gold); }
.beauty-item.on { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); }
.beauty-actions { margin-top: 12px; }
.beauty-default { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.beauty-default:empty { display: none; }
.beauty-default .wide { width: 100%; }
.beauty-default > p { margin: 8px 0; }
.sub-anim { margin-bottom: 8px; }
.anim-demo { display: block; width: 100%; margin-top: 10px; height: 74px; overflow: hidden; background: linear-gradient(#5b5862, #34323a); }
.anim-demo span { display: inline-block; font-size: 24px; font-weight: 700; color: #fff; text-shadow: -2px 0 #111, 2px 0 #111, 0 -2px #111, 0 2px #111, 0 3px 6px rgba(0,0,0,.5); }
.anim-demo span[class^="anim-"] { animation-duration: 2s; animation-iteration-count: infinite; animation-timing-function: linear; animation-fill-mode: both; }
.anim-pop { animation-name: anim-pop; } .anim-bounce { animation-name: anim-bounce; } .anim-fade { animation-name: anim-fade; } .anim-zoom { animation-name: anim-zoom; }
.anim-slideright { animation-name: anim-slideright; } .anim-slideleft { animation-name: anim-slideleft; } .anim-blur { animation-name: anim-blur; }
@keyframes anim-pop { 0% { transform: scale(.82); } 2% { transform: scale(1.07); } 4%, 100% { transform: scale(1); } }
@keyframes anim-bounce { 0% { transform: scale(.3); opacity: .6; } 2% { transform: scale(.64); opacity: 1; } 4% { transform: scale(.96); } 6% { transform: scale(1.14); } 8% { transform: scale(1.1); } 10% { transform: scale(.97); } 12% { transform: scale(.9); } 14% { transform: scale(.95); } 16% { transform: scale(1.05); } 18% { transform: scale(1.02); } 20%, 100% { transform: scale(1); } }
@keyframes anim-fade { 0% { opacity: 0; } 16%, 84% { opacity: 1; } 96%, 100% { opacity: 0; } }
@keyframes anim-zoom { 0% { transform: scale(.4); opacity: .25; } 5% { transform: scale(.8); opacity: .55; } 10% { transform: scale(.95); opacity: .85; } 16%, 100% { transform: scale(1); opacity: 1; } }
@keyframes anim-slideright { 0% { transform: translateX(-90px); opacity: .25; } 5% { transform: translateX(-32px); opacity: .55; } 10% { transform: translateX(-8px); opacity: .85; } 16%, 100% { transform: none; opacity: 1; } }
@keyframes anim-slideleft { 0% { transform: translateX(90px); opacity: .25; } 5% { transform: translateX(32px); opacity: .55; } 10% { transform: translateX(8px); opacity: .85; } 16%, 100% { transform: none; opacity: 1; } }
@keyframes anim-blur { 0% { filter: blur(10px); opacity: .35; } 8% { filter: blur(3px); opacity: .7; } 16%, 100% { filter: blur(0); opacity: 1; } }
.beauty-preview { margin-top: 10px; transition: opacity .15s; }
.beauty-preview.loading { opacity: .5; }
.beauty-preview .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.beauty-preview figure { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }
.beauty-preview img { width: 100%; border-radius: 12px; display: block; margin-bottom: 4px; }
.beauty-preview img { cursor: zoom-in; }
.beauty-preview.zoom .pair { grid-template-columns: 1fr; }
.beauty-preview.zoom img { cursor: zoom-out; }
.cover-block { margin-top: 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.cover-row { display: flex; gap: 12px; align-items: center; }
.cover-row img { width: 96px; border-radius: 10px; border: 1px solid var(--gold-line); }
.cover-row a { flex: 1; }
.cover-preview { max-height: 420px; min-height: 120px; margin-top: 8px; }
a.btn.save-look { border: 1px solid var(--gold-line); color: var(--gold); }
.clip-summary { padding: 0 14px 10px; font-weight: 600; text-align: center; }
.clips { list-style: none; padding: 0 14px 14px; margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-height: 470px; overflow-y: auto; }
.clips:empty { display: none; }
.clip-tile { min-width: 0; }
.clip-media { position: relative; }
.clip-frame { aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; background: var(--field); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; color: var(--muted); }
.clip-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.clip-frame .ico { width: 28px; height: 28px; }
.clip-frame.loading { animation: clip-pulse 1.2s ease-in-out infinite alternate; }
@keyframes clip-pulse { to { background: #201e18; } }
.clip-frame.failed::after { content: "ไม่มีภาพตัวอย่าง"; font-size: 10px; }
.clip-number, .clip-length { position: absolute; background: rgba(0,0,0,.68); border-radius: 7px; font-size: 11px; line-height: 1; padding: 5px 7px; }
.clip-number { top: 6px; left: 6px; color: var(--gold); font-weight: 700; }
.clip-length { right: 6px; bottom: 6px; }
.clip-remove { position: absolute; top: 3px; right: 3px; width: 34px; height: 34px; min-height: 0; padding: 0; border-radius: 50%; background: rgba(0,0,0,.68); border: 1px solid rgba(255,255,255,.25); font-size: 14px; line-height: 1; }
.clip-name, .clip-size { display: block; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.clip-size { color: var(--muted); margin-top: 0; font-size: 11px; }
@media (min-width: 520px) { .clips { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.clip-add { aspect-ratio: 3 / 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 1px dashed var(--gold-line); border-radius: 12px; color: var(--gold); cursor: pointer; font-size: 13px; }
.clip-add b { font-size: 30px; font-weight: 300; line-height: 1; }
.clip-add input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.clip-add:focus-within { outline: 2px solid var(--gold); }
.clip-clear { display: block; margin: 0 auto 14px; font-size: 13px; color: var(--muted); }
.filepick .pick-current, .pick-list button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; }
.filepick .pick-current { background: var(--field); }
.pick-list { margin-top: 6px; max-height: 340px; overflow-y: auto; border: 1px solid var(--gold-line); border-radius: 14px; background: #17171a; padding: 4px; position: relative; overscroll-behavior: contain; }
.pick-list button { background: none; border: 0; border-radius: 10px; }
.pick-list button.on { background: var(--gold-soft); color: var(--gold); }
.pick-thumb { position: relative; width: 46px; height: 62px; flex: none; border-radius: 8px; overflow: hidden; background: #000; display: grid; place-items: center; color: var(--muted); }
.pick-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pick-text { flex: 1; min-width: 0; font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.pick-text small { display: block; color: var(--muted); font-size: 12px; }
.pick-arrow, .pick-check { flex: none; width: 16px; text-align: center; color: var(--gold); }
.track > .grow { min-width: 0; overflow-wrap: anywhere; }
.track .play { min-width: 84px; border-color: var(--gold-line); color: var(--gold); }
.track .play.playing { background: var(--grad); border-color: transparent; color: var(--on-gold); font-weight: 700; }
.row.track { flex-wrap: nowrap; } .row.track > .grow { flex: 1 1 0; } .row.track button { flex: none; }
.sfx-item .switch { padding: 10px 0 4px; font-size: 14px; }
.sfx-item .row.track { margin-top: 0; }
.sfx-item small { font-size: 12px; }
.fold-item { padding: 4px 6px; margin-top: 6px; }
.row.track .fold-head { flex: 1 1 0; min-width: 0; display: grid; grid-template-columns: 18px 1fr; column-gap: 4px; align-items: center; text-align: left; background: none; border: 0; padding: 4px; }
.fold-head::before { content: '▸'; grid-row: 1 / span 2; color: var(--gold); }
.fold-head[aria-expanded="true"]::before { content: '▾'; }
.fold-head > * { grid-column: 2; overflow-wrap: anywhere; line-height: 1.3; }
.fold-item > .row.track > .play { min-width: 72px; padding: 8px 10px; }
.fold-more { padding: 0 4px 4px; }
.sfx-card .filebtn + .grow { min-width: 0; overflow-wrap: anywhere; }
.seg label.switch { color: var(--text); margin-bottom: 0; }
.seg label.switch input { width: 50px; height: 30px; }
.switch input:not(:checked) { background: #3a382f; }
.sfx-card > p:last-child { margin-top: 14px; }
.range-editor { margin-top: 8px; padding: 10px; border: 1px solid var(--gold-line); border-radius: 14px; }
.range-audio { width: 100%; display: block; }
.range-editor .row { margin-top: 8px; }
.range-editor > p { margin: 8px 0 0; }
.range-editor .times label { flex: 1 1 0; min-width: 0; }
.range-editor .listen-range { width: 100%; margin-top: 10px; }
.sfx-item > .row > .muted.grow { min-width: 0; }
.range-toggle { flex: none; font-size: 13px; }
.sfx-item .primary.big { margin-top: 10px; }
.visually-hidden, input.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; padding: 0; border: 0; }
.security-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.security-card form > p, .security-card form h3 { margin: 4px 0 0; }
.security-card .big { margin-top: 2px; }
.security-card .lock-actions { margin-top: 14px; }
.security-card .warn-text { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-top: 8px; }
.security-card .track small { display: block; font-size: 12px; overflow-wrap: anywhere; }
.login input:not(.visually-hidden) { margin-top: 6px; }
.login .biometric { display: flex; align-items: center; justify-content: center; gap: 10px; }
.login .biometric .ico { width: 26px; height: 26px; }
.login .or { text-align: center; margin: 14px 0 6px; }
.login.setup input[aria-label="รหัสตั้งค่า"] { text-align: center; text-transform: uppercase; font-size: 16px; letter-spacing: .5px; }
.login > p { margin-top: 12px; }
.secret { position: relative; }
.secret input[type] { padding-right: 52px; }
.secret .eye { position: absolute; top: 50%; right: 2px; transform: translateY(-50%); width: 44px; height: 44px; min-height: 0; padding: 0; display: flex; align-items: center; justify-content: center; background: transparent; border: 0; color: var(--muted); }
.secret .eye .ico { width: 22px; height: 22px; }
.secret .eye[aria-label="ซ่อนรหัสผ่าน"] { color: var(--gold); }
.login .secret { margin-top: 6px; }
.login .secret input[type] { margin-top: 0; }
.device { display: flex; align-items: center; gap: 12px; background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-top: 10px; }
.device .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.device small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.device button { flex: none; }
.add-device { margin-top: 12px; }
.add-device:disabled { background: var(--card2); border: 1px solid var(--line); color: var(--muted); opacity: 1; }
.scan-reason { margin-top: 8px; }
.scan-confirm { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.scan-confirm h3 { margin: 4px 0 0; }
.lyric-box { margin-top: 10px; border: 1px solid var(--gold-line); border-radius: 14px; padding: 6px 12px 12px; }
.lyric-box > p { margin-top: 8px; }
.lyric-editor textarea.lrc { margin-top: 8px; min-height: 200px; font-size: 16px; line-height: 1.7; }
.lyric-editor textarea[readonly] { opacity: .75; }
.lyric-now { min-height: 1.6em; text-align: center; color: var(--gold); font-weight: 600; margin-top: 8px; overflow-wrap: anywhere; }
.lyric-sync { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 4px; }
/* เลือกสีตัวหนังสือ */
.colors { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.colors .auto.on { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); font-weight: 600; }
.colorwell { position: relative; display: flex; width: 132px; height: 44px; border: 1px solid #6b665c; border-radius: 12px; overflow: hidden; cursor: pointer; }
.colorwell.on { outline: 2px solid var(--gold); outline-offset: 2px; }
.colorwell:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }
.colorwell .now { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 13px; background: var(--field); }
.colorwell .wheel { width: 44px; display: flex; align-items: center; justify-content: center; background: #55535a; }
.colorwell .wheel::after { content: ""; width: 28px; height: 28px; border-radius: 50%; background: radial-gradient(circle, #fff 0, rgba(255,255,255,0) 68%), conic-gradient(#ff3b30, #ffd60a, #34c759, #32d7ff, #2f7bff, #c44bff, #ff3b30); }
.colorwell input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
/* ไกด์ไลน์ Safe Zone บนภาพตัวอย่าง */
.stage { position: relative; width: fit-content; max-width: 100%; margin: 0 auto; }
.stage.tall .preview { height: 340px; width: auto; aspect-ratio: 9 / 16; }
.safe-zone { position: absolute; inset: 0; overflow: hidden; border-radius: 14px; pointer-events: none; }
.safe-zone svg { display: block; width: 100%; height: 100%; }
.safe-zone path { stroke: none; fill: none; }
.safe-zone .red { fill: rgba(190, 20, 20, .34); }
.safe-zone .orange { fill: rgba(255, 150, 30, .22); }
.safe-zone .edge { stroke: #3ddc84; stroke-width: 1.5px; }
.safe-zone .mark { stroke: rgba(80, 225, 215, .85); stroke-width: 1px; }
.safe-zone .eye { stroke: rgba(255, 255, 255, .75); stroke-dasharray: 4 3; }
.safe-zone span { position: absolute; font-size: 9px; line-height: 1.3; color: #fff; text-shadow: 0 0 3px #000, 0 0 2px #000; white-space: nowrap; opacity: .85; }
.safe-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
p.safe-legend { font-size: 12px; margin: 6px 0 0; }
.safe-legend i { display: inline-block; width: 11px; height: 11px; margin-right: 5px; border-radius: 3px; vertical-align: -1px; }
.safe-legend i.green { border: 2px solid #3ddc84; }
.safe-legend i.orange { background: rgba(255, 150, 30, .75); }
.safe-legend i.red { background: rgba(190, 20, 20, .9); }
body.no-safezone .safe-zone, body.no-safezone .safe-legend { display: none; }
.cover-editor .stage { margin-top: 8px; }
.stage .cover-preview { margin-top: 0; }
.stage.for-cover .safe-zone .caption { display: none; }
/* บันทึกตำแหน่งและรูปแบบอักษร */
.my-look { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.my-look .save-look { width: 100%; }
.my-look p { margin: 6px 0; }
/* คุยกับ AI เพื่อปรับแก้ */
.chat { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 4px; }
.chat-log { display: flex; flex-direction: column; gap: 10px; max-height: 440px; overflow-y: auto; padding: 4px 0 10px; overscroll-behavior: contain; }
.chat-msg { max-width: 92%; padding: 9px 12px; border-radius: 14px; font-size: 14px; overflow-wrap: anywhere; }
.chat-msg p { white-space: pre-wrap; }
.chat-msg.user { align-self: flex-end; background: var(--gold-soft); border: 1px solid var(--gold-line); border-bottom-right-radius: 4px; }
.chat-msg.assistant { align-self: flex-start; background: var(--card2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-msg.failed p { color: var(--bad); }
.chat-msg.waiting p { color: var(--muted); animation: clip-pulse 1.2s ease-in-out infinite alternate; }
.chat-notes { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--gold); }
.chat-plan { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.chat-plan b { font-size: 13px; }
.chat-plan ul, .chat-plan ol { margin: 4px 0; padding-left: 18px; font-size: 13px; }
.chat-plan li span { color: var(--muted); }
.chat-plan summary { font-size: 13px; cursor: pointer; }
.chat-plan .row { margin-top: 8px; }
.chat-plan .row button { font-size: 13.5px; }
.chat-done { color: #3ddc84; font-size: 13px; margin-top: 6px; }
.chat-colour { display: inline-block; width: 12px; height: 12px; margin-right: 4px; border-radius: 3px; border: 1px solid #6b665c; vertical-align: -1px; }
.chat-ideas { margin-bottom: 8px; }
.chat-ideas button { font-size: 13px; min-height: 36px; padding: 6px 12px; }
.chat textarea { min-height: 64px; }
.chat > .row { align-items: flex-start; margin-top: 6px; }
.chat > .row p { font-size: 12px; }
.chat-send { min-width: 84px; }

/* รูปโปรโมชั่นหลายรูป */
.promos { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin: 0 0 8px; padding: 0; list-style: none; }
.promos li { position: relative; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--card2); }
.promos img { display: block; width: 100%; height: 100%; object-fit: contain; }
.promo-mode { margin-top: 12px; }

/* เวลาโดยประมาณของการปรับผิวบนเว็บ */
.beauty-time { margin: 10px 0; font-size: 13px; line-height: 1.6; color: var(--muted); }
.beauty-time.on { padding: 10px 12px; border: 1px solid var(--gold); border-radius: 12px; color: var(--gold); }

/* เลือกเสียงพากย์ + ฟังตัวอย่าง */
.voice-row { display: flex; gap: 8px; align-items: center; }
.voice-row > select { flex: 1 1 0; min-width: 0; }
.voice-row > .voice-play { flex: none; min-height: 44px; }
.voice-note { margin-top: 6px; font-size: 12.5px; line-height: 1.6; }

/* ส่งไป TikTok และแคปชั่น */
.send-tiktok, .save-video, .save-cover, .caption-box button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.send-tiktok { border-color: var(--gold-line); font-weight: 600; }
.send-tiktok .ico, .caption-box button .ico { color: var(--gold); }
.send-note { margin-top: 8px; }
.caption-box { margin: 12px 0; border-top: 1px solid var(--line); }
.caption-box textarea { min-height: 96px; }
.caption-box .row { margin: 8px 0 6px; }
.caption-box button { font-size: 14px; }

/* โคลนเสียงพากย์ */
.consent-text { margin: 0 0 10px; padding: 12px 14px; border: 1px solid var(--gold-line); border-radius: 12px; background: var(--gold-soft); font-size: 17px; line-height: 1.75; user-select: text; }
.clone-card .filebtn + .grow { min-width: 0; overflow-wrap: anywhere; }
.clone-item .voice-play { flex: none; }
.clone-card input[type=text] { margin-bottom: 4px; }
.clone-card .switch span { font-size: 14px; }
.clone-card .primary.big { margin-top: 0; }
.clone-error:empty { display: none; }
.clone-card > div > p.muted { margin-top: 10px; }


/* บันทึกลงเครื่องผ่านเมนูแชร์ */
.save-fallback { display: inline-block; margin-top: 8px; color: var(--gold); font-size: 13.5px; }
.cover-save { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; flex: 1; }
.cover-save p { margin-top: 6px; }
.cover-save a { flex: none; }
.save-video, .row > .send-tiktok { padding-left: 8px; padding-right: 8px; white-space: nowrap; }
.save-video { gap: 6px; }

/* เมนูสคริปต์ */
.script-views .chips { margin-bottom: 14px; }
.script-views .chips button { flex: 1 1 0; white-space: nowrap; padding-left: 8px; padding-right: 8px; }
.script-editor input[type=text] { margin-bottom: 8px; }
.script-editor textarea.script-text { min-height: 220px; font-size: 16px; line-height: 1.75; }
.script-editor .row { margin-top: 8px; }
.script-editor button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; padding-left: 8px; padding-right: 8px; }
.script-editor button .ico { color: var(--gold); }
.script-editor button.primary .ico { color: inherit; }
.script-length { margin-top: 4px; }
.script-item { display: flex; gap: 8px; align-items: stretch; }
.script-item .script-title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: none; border: 0; padding: 0; }
.script-title b, .script-title span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.script-title span { font-size: 13px; color: var(--muted); }
.script-title small { font-size: 11.5px; color: var(--muted); }
.script-item .script-quick { flex: none; align-self: center; display: inline-flex; align-items: center; justify-content: center; width: 48px; padding: 0; color: var(--gold); }

/* เครื่องบอกบท */
body.is-prompting { overflow: hidden; }
.prompter { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: #000; color: #fff; padding-top: env(safe-area-inset-top); }
.prompter-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0 max(26px, env(safe-area-inset-right)) 0 max(26px, env(safe-area-inset-left)); cursor: pointer; }
/* เว้นบนล่างให้บรรทัดแรกเริ่มที่เส้นอ่าน และบรรทัดสุดท้ายเลื่อนขึ้นมาถึงเส้นได้ */
.prompter-text { max-width: 900px; margin: 0 auto; padding: 24vh 0 60vh; text-align: center; font-weight: 600; line-height: 1.6; }
.prompter-text p { margin: 0 0 .45em; overflow-wrap: anywhere; }
.prompter.mirror .prompter-text { transform: scaleX(-1); }
.prompter-guide { position: absolute; left: 6px; right: 6px; top: calc(env(safe-area-inset-top) + 24vh + 14px); height: 0; pointer-events: none; }
.prompter-guide::before, .prompter-guide::after { content: ""; position: absolute; top: 0; border: 9px solid transparent; }
.prompter-guide::before { left: 0; border-left-color: var(--gold); }
.prompter-guide::after { right: 0; border-right-color: var(--gold); }
.prompter-count { position: absolute; left: 0; right: 0; top: 40%; text-align: center; font-size: 110px; font-weight: 700; color: var(--gold); pointer-events: none; text-shadow: 0 0 24px #000; }
.prompter-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); background: #111112; border-top: 1px solid var(--line); }
.prompter-group { display: flex; align-items: center; gap: 4px; }
.prompter-group button { min-width: 48px; padding: 8px 10px; }
.prompter-value { min-width: 56px; text-align: center; font-size: 13px; color: var(--muted); }
.prompter-main { display: flex; gap: 8px; width: 100%; max-width: 560px; }
.prompter-main button { flex: 1 1 auto; white-space: nowrap; padding: 8px 8px; }
.prompter-main .prompter-play { flex: 1.6 1 auto; }
.prompter-mirror.on { border-color: var(--gold); color: var(--gold); }
.script-go h3:first-child { margin-top: 0; }
.script-result { scroll-margin-top: 12px; }
/* เว้นระยะปุ่มหลักกับตัวเลือกและข้อความรอบๆ ในหน้าสคริปต์ */
.script-views + div .card > p { margin-top: 12px; }

/* เวลาแสดงฮุก */
.hook-time .chips button { min-height: 40px; padding: 8px 12px; font-size: 14px; }
.hook-custom { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; }
.hook-custom input { width: 92px; flex: none; background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; font-size: 16px; text-align: center; }
.hook-time-note { margin: 8px 0 4px; }
.clip-hint { display: block; margin-top: 2px; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.count-note { margin-top: 8px; font-size: 12.5px; }
/* เหตุผลที่ได้คลิปไม่ครบ */
.shortfall { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--gold-line); border-radius: 12px; background: var(--gold-soft); font-size: 13.5px; line-height: 1.65; }

/* โพสต์: คิวโพสต์ TikTok ผ่าน Buffer */
input[type=datetime-local], input[type=time], input[type=number] { width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font-size: 16px; min-width: 0; color-scheme: dark; }
.channel-list { max-height: 240px; overflow-y: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 2px 12px; }
.channel-list .switch { padding: 7px 0; }
.warn-box { border: 1px solid var(--gold-line); background: var(--gold-soft); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; }
.rule-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.rule-fields label { display: block; min-width: 0; }
.rule-fields input { margin-top: 4px; }
.rule-fields .rule-actions { grid-column: 1 / -1; }
.channel-rules { margin-top: 14px; }
.channel-rules summary, .card details > summary { cursor: pointer; padding: 8px 0; }
.post-item video { max-height: 52dvh; margin: 10px 0 6px; }
.check { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin: 8px 0; font-size: 14px; }
.check.pass { border-color: rgba(120,190,130,.6); }
.check.warn { border-color: var(--gold-line); background: var(--gold-soft); }
.check.fail { border-color: var(--bad); }
.check ul { margin: 6px 0 0 18px; }
.check li.fail { color: var(--bad); }
.check li.warn { color: var(--gold); }
.badge { font-size: 12px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.approved, .badge.posting { color: var(--gold); border-color: var(--gold-line); }
.consent a { color: inherit; text-decoration: underline; }
.brand-box { margin: 4px 0 8px 10px; padding-left: 10px; border-left: 2px solid var(--gold-line); }
.post-item select { width: 100%; }
.post-item input[readonly], #view input[readonly] { width: 100%; font-size: 13px; }
.badge.sent { color: #8fd19a; border-color: rgba(120,190,130,.6); }
.badge.error { color: var(--bad); border-color: var(--bad); }
.post-row .row { margin-top: 8px; }
.post-row p { margin-top: 6px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 8px 4px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat small { color: var(--muted); font-size: 11.5px; }
.stat.ok b { color: #8fd19a; }
.stat.bad b { color: var(--bad); }
.report-scroll { overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.report-table th, .report-table td { text-align: left; padding: 6px 5px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.report-table th { color: var(--muted); font-weight: 600; }
