:root {
  color-scheme: dark;
  font-family: "Noto Sans Thai", Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
  --page: #08090c;
  --surface: #171719;
  --surface-raised: #202023;
  --surface-hover: #2a292e;
  --line: #34343b;
  --text: #f8f7fb;
  --muted: #aaa9b5;
  --purple: #bca5ff;
  --purple-deep: #251958;
  --green: #52da83;
  background: var(--page);
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: #c9b8ff; }
button, input, select, textarea { font: inherit; }
button, .button { cursor: pointer; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; border: 0; border-radius: 9px; padding: 10px 17px; background: #f5f3fa; color: #14121b; font-weight: 750; text-decoration: none; transition: background .16s ease, transform .16s ease; }
button:hover, .button:hover { background: #ded4ff; transform: translateY(-1px); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; }
.secondary { background: #333238; color: var(--text); }
.secondary:hover { background: #45434d; }
.danger { background: #3b252d; color: #ffd7df; }
.danger:hover { background: #653441; }
.app-frame { display: grid; grid-template-columns: 208px minmax(0, 1fr) 272px; gap: 12px; max-width: 1720px; min-height: 100vh; margin: auto; padding: 12px; }
.library-sidebar, .insight-panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.library-sidebar { position: sticky; top: 12px; align-self: start; height: calc(100vh - 24px); overflow: auto; padding: 22px 11px; }
.sidebar-brand { display: block; margin: 2px 10px 30px; color: #fff; font-size: 1rem; font-weight: 900; letter-spacing: -.02em; text-decoration: none; }
.sidebar-brand span { color: var(--purple); }
.sidebar-primary { display: grid; gap: 4px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.sidebar-link { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px; border-radius: 8px; color: #d0ced7; font-size: .9rem; font-weight: 700; text-decoration: none; }
.sidebar-link:hover, .sidebar-link.selected { background: #292730; color: #fff; }
.sidebar-icon { display: grid; place-items: center; width: 23px; font-size: 1.45rem; line-height: 1; }
.sidebar-library { padding-top: 22px; }
.sidebar-heading { display: flex; justify-content: space-between; align-items: center; padding: 0 10px; font-size: .9rem; font-weight: 800; }
.sidebar-heading a { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 7px; background: #eeeef3; color: #15151b; font-size: 1.3rem; text-decoration: none; }
.sidebar-note, .sidebar-empty { margin: 8px 10px 20px; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.library-item { display: flex; align-items: center; gap: 10px; padding: 7px; border-radius: 8px; color: var(--text); text-decoration: none; }
.library-item:hover, .library-item.selected { background: #29282d; }
.library-art { display: grid; flex: 0 0 42px; place-items: center; height: 42px; border-radius: 4px; background: linear-gradient(145deg, #8c5bce, #291d52 65%, #141222); color: white; font-size: .9rem; }
.library-art img { width: 100%; height: 100%; border-radius: 4px; object-fit: cover; }
.library-copy { display: grid; min-width: 0; gap: 2px; }
.library-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; }
.library-copy small { color: var(--muted); font-size: .7rem; }
.shell { min-width: 0; padding: 0 0 70px; }
.hero { padding: 18px 24px 22px; border: 1px solid #685094; border-radius: 12px; background: radial-gradient(circle at 100% -35%, #594187 0, transparent 40%), linear-gradient(135deg, #272044 0%, #191725 90%); }
header { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 42px; }
.brand { display: none; color: #fff; font-size: 1rem; font-weight: 850; text-decoration: none; }
.brand b { color: var(--purple); }
.header-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.header-actions > .button { font-size: .86rem; }
.account-menu { position: relative; }
.account-menu summary { display: grid; place-content: center; gap: 4px; width: 44px; height: 44px; border: 1px solid #ffffff39; border-radius: 9px; background: #ffffff20; cursor: pointer; list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary:hover, .account-menu[open] summary { background: #ffffff3b; }
.account-menu summary .avatar-initial { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #dccbff; color: #271b39; font-size: .88rem; font-weight: 850; }
.account-panel { position: absolute; z-index: 20; top: calc(100% + 10px); right: 0; min-width: 225px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #24232b; box-shadow: 0 16px 36px #0009; }
.account-email { display: block; overflow-wrap: anywhere; padding: 2px 2px 12px; border-bottom: 1px solid var(--line); }
.account-panel form { margin: 12px 0 0; }
.account-panel button { width: 100%; text-align: left; }
.hero-copy { margin-top: 16px; max-width: 780px; }
.hero-kicker, .eyebrow { color: #d0c1ff; font-size: .75rem; font-weight: 800; letter-spacing: .04em; }
h1 { margin: 6px 0 5px; font-size: clamp(1.65rem, 2.5vw, 2.3rem); letter-spacing: -.025em; line-height: 1.3; }
h2 { margin: 0 0 8px; font-size: 1.15rem; letter-spacing: -.015em; }
h3 { font-size: 1rem; }
p { color: #c2bfcb; line-height: 1.6; }
.lead { max-width: 690px; margin: 0; font-size: .95rem; color: #d6cde9; }
.hero-meta { color: #b9b0c8; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin: 24px 18px 14px; }
.section-heading h2 { margin: 4px 0 0; font-size: 1.25rem; }
.muted { color: var(--muted); font-size: .88rem; }
.jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; padding: 0 16px; }
.job-item { display: flex; flex-direction: column; min-width: 0; padding: 12px; border-radius: 10px; background: var(--surface); transition: background .16s ease; }
.job-item:hover { background: var(--surface-hover); }
.job-art { position: relative; display: grid; place-items: center; aspect-ratio: 9 / 10; overflow: hidden; border-radius: 7px; background: linear-gradient(140deg, #9e77c7, #321f60 55%, #130e22); color: white; text-decoration: none; }
.job-art::before { content: ""; position: absolute; width: 72%; aspect-ratio: 1; border: 1px solid #ffffff58; border-radius: 20%; transform: rotate(28deg) translate(28%, 15%); box-shadow: 0 0 0 26px #ffffff0b, 0 0 0 60px #ffffff08; }
.job-art.art-1 { background: linear-gradient(140deg, #a65366, #4f254e 52%, #1e132e); }
.job-art.art-2 { background: linear-gradient(140deg, #5d9fa1, #254f63 52%, #101a31); }
.job-art.art-3 { background: linear-gradient(140deg, #ba824b, #663047 52%, #25172a); }
.job-art.art-4 { background: linear-gradient(140deg, #728eac, #3c4379 52%, #18122e); }
.job-art-back, .job-art-thumb { position: absolute; inset: 0; width: 100%; height: 100%; }
.job-art-back { object-fit: cover; filter: blur(16px) brightness(.52); transform: scale(1.12); }
.job-art-thumb { z-index: 1; object-fit: contain; }
.job-art-mark { z-index: 2; display: grid; place-items: center; width: 52px; height: 52px; padding-left: 3px; border-radius: 50%; background: #ffffffdf; color: #292037; box-shadow: 0 8px 22px #0004; }
.job-art-label { position: absolute; z-index: 2; bottom: 11px; left: 12px; padding: 4px 8px; border-radius: 5px; background: #0a081bdd; font-size: .75rem; font-weight: 750; }
.job-info { padding: 13px 2px 9px; }
.job-info h2 { overflow: hidden; margin-bottom: 2px; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.job-info p { margin: 0 0 9px; color: var(--muted); font-size: .82rem; }
.job-status { display: inline-flex; align-items: center; gap: 6px; color: #c1b8d4; font-size: .82rem; }
.job-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #aa8fed; }
.job-status.ready { color: #93e9aa; }
.job-status.ready::before { background: var(--green); }
.job-created { display: block; margin-top: 7px; color: var(--muted); font-size: .78rem; line-height: 1.4; }
.job-actions { display: flex; gap: 7px; margin-top: auto; padding-top: 8px; }
.job-actions form { margin: 0; }
.job-actions .button, .job-actions button { min-height: 40px; padding: 7px 12px; font-size: .82rem; }
.insight-panel { position: sticky; top: 12px; align-self: start; max-height: calc(100vh - 24px); overflow: auto; padding: 20px 16px; }
.insight-panel h2 { overflow-wrap: anywhere; margin: 8px 0 16px; font-size: 1rem; line-height: 1.5; }
.insight-panel p { font-size: .88rem; }
.canvas-preview { position: relative; width: min(100%, 202px); aspect-ratio: 9 / 16; margin: 0 auto; overflow: hidden; border: 1px solid #5c526b; border-radius: 10px; background: #101014; }
.canvas-preview img, .canvas-preview video { display: block; width: 100%; height: 100%; object-fit: contain; }
.canvas-label { position: absolute; right: 10px; bottom: 10px; left: 10px; padding: 7px 9px; border-radius: 6px; background: #09080ce0; color: white; font-size: .82rem; font-weight: 700; line-height: 1.45; }
.canvas-label small { color: #d6d0df; font-size: .72rem; font-weight: 500; }
.canvas-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: space-between; height: 100%; padding: 28px 10px; background: linear-gradient(170deg, #28213f, #101014 70%); color: #c4bad4; }
.canvas-placeholder > span:first-child { align-self: flex-start; font-size: .8rem; font-weight: 800; }
.canvas-play { display: grid; place-items: center; width: 60px; height: 60px; border: 1px solid #a78de0; border-radius: 50%; color: white; }
.canvas-placeholder small { font-size: .82rem; }
.project-facts { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; color: #cfc7da; font-size: .82rem; }
.readiness-list { display: grid; gap: 11px; padding: 0; margin: 15px 0; list-style: none; }
.readiness-list li { display: flex; align-items: center; gap: 9px; color: #c9c6d0; font-size: .84rem; }
.readiness-list li > span { display: grid; place-items: center; flex: 0 0 25px; height: 25px; border: 1px solid #6c6678; border-radius: 50%; color: #d9d3e1; font-size: .8rem; }
.readiness-list li.ready > span { border-color: #5fb878; background: #1f4730; color: #baf2c8; }
.readiness-list small { color: var(--muted); font-size: .74rem; }
.insight-link { display: flex; justify-content: space-between; min-height: 44px; align-items: center; padding: 9px 0; color: #e0d3ff; font-size: .86rem; font-weight: 750; text-decoration: none; }
.insight-link:hover { color: var(--purple); }
.insight-divider { margin: 18px 0; border-top: 1px solid var(--line); }
.storage-details summary { cursor: pointer; font-size: .86rem; font-weight: 750; }
.storage-details button { width: 100%; font-size: .8rem; }
.tabs { display: flex; gap: 4px; margin: 0; padding: 10px 18px 0; border-bottom: 1px solid var(--line); }
.tab { border: 0; border-radius: 8px 8px 0 0; background: transparent; color: #c1bdcc; font-size: .9rem; }
.tab:hover { background: #29272f; color: white; transform: none; }
.tab[aria-selected="true"] { border-bottom: 3px solid var(--purple); color: white; }
.tab-ready { margin-left: 4px; color: #a5efb6; font-size: .76rem; }
.video-panel[hidden], .workflow-panel[hidden] { display: none; }
.workflow-panel, .video-panel { margin: 18px; }
.new-job-card { max-width: 680px; }
.video-edit-form { max-width: 720px; margin: 28px 0 18px; padding-top: 22px; border-top: 1px solid var(--line); }
.video-edit-form h3 { margin: 0 0 14px; }
.video-edit-form textarea { min-height: 112px; resize: vertical; }
.workflow-heading { display: flex; align-items: center; gap: 18px; margin-bottom: 16px; padding: 0 2px; }
.workflow-heading > div:first-child { display: grid; gap: 3px; white-space: nowrap; }
.workflow-heading strong { font-size: .88rem; }
.progress-track { width: 100%; height: 7px; overflow: hidden; border-radius: 99px; background: #302c38; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: #9d79f4; }
.layout { display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: 16px; align-items: start; }
.step-nav { position: sticky; top: 12px; display: grid; gap: 7px; }
.step-nav a { display: flex; align-items: center; gap: 9px; min-height: 62px; padding: 10px; border: 1px solid transparent; border-radius: 9px; color: #c6c3cd; background: #1e1e22; text-decoration: none; }
.step-nav a:hover, .step-nav a.active { border-color: #69538f; background: #30273f; color: #fff; }
.step-nav .done .step-number { border-color: #5fb878; background: #1f4730; color: #baf2c8; }
.step-nav strong, .step-nav small { display: block; }
.step-nav strong { font-size: .85rem; line-height: 1.35; }
.step-nav small { margin-top: 3px; color: var(--muted); font-size: .73rem; line-height: 1.35; }
.step-number { display: grid; flex: 0 0 27px; place-items: center; width: 27px; height: 27px; border: 1px solid #6b6475; border-radius: 50%; font-size: .82rem; font-weight: 800; }
.steps { display: grid; gap: 14px; min-width: 0; }
.has-job .steps .card { display: none; }
.has-job .steps .card.active { display: block; }
.card { min-width: 0; padding: 24px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.card.highlight { border-color: #8060b6; }
.card .eyebrow { display: block; margin-bottom: 8px; }
label { display: block; margin: 18px 0 7px; font-weight: 650; font-size: .9rem; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid #514e59; border-radius: 7px; background: #101014; color: white; }
input:focus, select:focus, textarea:focus { border-color: var(--purple); }
textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
input[type=file] { padding: 10px; }
input[type=radio], input[type=checkbox] { width: auto; margin-right: 5px; accent-color: var(--purple); }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.notice, .error { padding: 12px 14px; border-radius: 8px; line-height: 1.55; }
.notice { border: 1px solid #4d4570; background: #2b2540; color: #e0d5ff; }
.error { border: 1px solid #8f485f; background: #3a202a; color: #ffd5dc; }
.status { min-height: 24px; margin: 14px 0; }
.status[hidden], .step-feedback[hidden] { display: none; }
.step-feedback { margin: 12px 0 18px; }
.workflow-actionbar { position: sticky; z-index: 5; bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 14px; margin: 16px 0 0 192px; padding: 12px 14px; border: 1px solid #685783; border-radius: 10px; background: #24202eea; box-shadow: 0 12px 32px #0008; backdrop-filter: blur(12px); }
.workflow-actionbar button { flex: 0 0 auto; background: #ddd0ff; }
.action-hint { color: #d4cbdf; font-size: .82rem; line-height: 1.45; }
.asset { display: grid; grid-template-columns: minmax(140px, 1fr) 1.5fr; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.asset small { display: block; color: var(--muted); }
code { color: #d8c1ff; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.result-video { display: block; max-width: 100%; max-height: 70vh; margin: 20px auto; border-radius: 9px; background: #000; }
.media-review { display: block; max-width: 100%; max-height: 300px; margin: 12px 0; border-radius: 9px; background: #000; }
.transcript-choice { display: flex; gap: 12px; flex-wrap: wrap; margin: 18px 0; }
.transcript-choice label { margin: 0; padding: 12px 16px; border: 1px solid #514e59; border-radius: 8px; cursor: pointer; }
.transcript-choice label:has(input:checked) { border-color: var(--purple); background: #332749; }
.transcript-panel[hidden] { display: none; }
.segment-list { display: grid; gap: 14px; margin: 18px 0; }
.segment-card { padding: 17px; border: 1px solid #514e59; border-radius: 9px; background: #1d1c22; }
.segment-card:has(input[type=checkbox]:checked) { border-color: #4d9b68; }
.segment-card h3 { margin: 0 0 8px; }
.segment-card textarea { min-height: 95px; }
.review-check { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; color: #a4e5b6; cursor: pointer; }
.review-check input { width: auto; }
.preview-plan { margin: 16px 0 22px; padding: 18px; border: 1px solid #5e536d; border-radius: 10px; background: var(--surface-raised); }
.preview-header { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.preview-plan h4 { margin: 4px 0 0; font-size: 1.08rem; }
.preview-key { color: var(--muted); font-size: .78rem; text-align: right; }
.storyboard { display: flex; gap: 12px; padding: 2px 2px 10px; overflow-x: auto; scroll-snap-type: x proximity; }
.storyboard-shot { display: grid; flex: 0 0 145px; gap: 6px; scroll-snap-align: start; }
.shot-time, .shot-title { color: #d4cfdb; font-size: .78rem; font-weight: 700; }
.shot-frame { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; aspect-ratio: 9 / 16; padding: 12px; border: 1px solid #766186; border-top: 4px solid var(--shot-accent, #bca5ff); border-radius: 8px; background: linear-gradient(160deg, #30213d, #121015 75%); color: white; text-align: center; overflow-wrap: anywhere; }
.shot-frame strong { font-size: .94rem; line-height: 1.45; }
.shot-frame b { color: #e1d2ff; font-size: 1rem; line-height: 1.4; }
.shot-tag { align-self: flex-start; padding: 3px 6px; border-radius: 4px; background: #ffffff1c; color: #e8dff2; font-size: .7rem; }
.intro-shot .shot-frame { background: linear-gradient(160deg, #49327d, #151222 75%); }
.preview-group { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.preview-group > summary { display: flex; justify-content: space-between; gap: 10px; min-height: 44px; align-items: center; cursor: pointer; }
.preview-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; font-size: .87rem; line-height: 1.55; overflow-wrap: anywhere; }
.preview-line small { color: var(--muted); font-size: .78rem; }
.preview-hidden { opacity: .72; }
.advanced-plan { margin: 18px 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 9px; }
.advanced-plan summary { min-height: 32px; cursor: pointer; font-weight: 700; }
.advanced-plan textarea { min-height: 360px; font-family: ui-monospace, monospace; font-size: .84rem; }
.empty-state { margin: 18px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; margin: 8px auto 18px; border-radius: 16px; background: #302442; color: #e3d6ff; }
.empty-state p { margin-bottom: 20px; }
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: radial-gradient(circle at 50% 0, #30234d, transparent 45%), var(--page); }
.auth-card { width: min(100%, 430px); padding: 32px; border: 1px solid #625477; border-radius: 14px; background: var(--surface); box-shadow: 0 20px 60px #0008; }
.auth-brand { display: inline-block; color: white; font-size: .94rem; font-weight: 900; letter-spacing: -.02em; text-decoration: none; }
.auth-brand span { color: var(--purple); }
.auth-card .eyebrow { display: block; margin-top: 30px; }
.auth-card h1 { margin-top: 6px; }
.auth-card p { color: #cbc6d1; }
.auth-card input { min-height: 46px; }
.auth-card button { width: 100%; margin-top: 26px; }
.result-page { min-height: 100vh; }
.result-shell { max-width: 930px; margin: auto; padding: 26px 20px 70px; }
.result-shell header { flex-wrap: wrap; }
.result-shell h1 { margin-top: 35px; }
.result-card { margin-top: 22px; }
.result-card .result-video { width: auto; max-height: 70vh; margin: 22px auto; }
.result-card .button { margin: 6px 8px 6px 0; }
@media (max-width: 1180px) {
  .app-frame { grid-template-columns: 196px minmax(0, 1fr); }
  .insight-panel { position: static; grid-column: 2; max-height: none; }
  .insight-panel .canvas-preview { max-width: 220px; }
}
@media (max-width: 900px) {
  .app-frame { display: block; padding: 0; }
  .library-sidebar { position: static; height: auto; padding: 8px 14px; border-radius: 0; }
  .sidebar-brand, .sidebar-library { display: none; }
  .sidebar-primary { display: flex; gap: 6px; padding: 0; border: 0; }
  .sidebar-link { min-height: 44px; }
  .shell { padding-bottom: 20px; }
  .hero { border-radius: 0; }
  .brand { display: block; }
  .insight-panel { margin: 12px; }
  .insight-panel .canvas-preview { max-width: 220px; }
}
@media (max-width: 700px) {
  .layout { grid-template-columns: 1fr; }
  .step-nav { position: static; display: flex; overflow-x: auto; padding-bottom: 5px; }
  .step-nav a { flex: 0 0 146px; }
  .step-nav small { display: none; }
  .workflow-actionbar { margin-left: 0; }
  .grid, .asset { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .auth-card { padding: 24px; }
  .hero { padding: 14px 16px 18px; }
  header { gap: 8px; }
  .brand { font-size: .82rem; }
  .header-actions { gap: 7px; }
  .header-actions > .button { padding: 8px 10px; font-size: .78rem; }
  .hero-copy { margin-top: 16px; }
  .hero-meta { display: none; }
  .jobs { grid-template-columns: 1fr; gap: 10px; padding: 0 12px; }
  .job-art { aspect-ratio: 16 / 9; }
  .job-item { padding: 10px; }
  .section-heading { margin-inline: 14px; }
  .workflow-panel, .video-panel { margin: 12px; }
  .card { padding: 18px; }
  .tabs { padding-inline: 12px; }
  .tab { padding: 9px 10px; font-size: .84rem; }
  .workflow-heading { gap: 10px; }
  .workflow-actionbar { bottom: 0; margin: 12px -12px -12px; border-radius: 0; }
  .workflow-actionbar button { max-width: 58%; font-size: .82rem; }
  .action-hint { font-size: .75rem; }
  .preview-header { display: block; }
  .preview-key { display: block; margin-top: 6px; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  button, .button, .job-item { transition: none; }
  button:hover, .button:hover { transform: none; }
}
