/* Plaazaa screensaver — shell styles (scenes draw on the canvas) */
:root { --navy: #0b1020; --line: rgba(255, 255, 255, .16); --indigo: #4f46e5; --muted: #b7bdd4;
  --fh: Sora, "Noto Sans Thai", system-ui, sans-serif; --fb: "Noto Sans", "Noto Sans Thai", system-ui, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--navy); color: #fff; font-family: var(--fb); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
#sv-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
.sv-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* content card — modes choose where it sits (body[data-card]) */
.sv-card { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(880px, calc(100vw - 48px)); text-align: center; z-index: 2; pointer-events: none;
  opacity: 0; transition: opacity .6s ease, transform .6s ease; text-shadow: 0 2px 18px rgba(0, 0, 0, .55); }
.sv-card.on { opacity: 1; }
body[data-card="low"] .sv-card { top: auto; bottom: 16vh; transform: translate(-50%, 0); }
body[data-card="bottom"] .sv-card { top: auto; bottom: 120px; transform: translate(-50%, 0); }
body[data-card="left"] .sv-card { left: 6vw; top: auto; bottom: 120px; transform: none; text-align: left; width: min(760px, calc(100vw - 12vw)); }
.sv-k { margin: 0 0 10px; font: 600 clamp(12px, 1.3vw, 16px) var(--fh); letter-spacing: .12em; text-transform: uppercase; color: #c7d2fe; }
.sv-big { margin: 0; font: 700 clamp(30px, 5.4vw, 72px)/1.15 var(--fh); letter-spacing: -.5px; }
.sv-tag { font-weight: 600; font-size: clamp(26px, 4.4vw, 58px); }
.sv-t { margin: 14px 0 0; font: 500 clamp(15px, 1.8vw, 24px)/1.5 var(--fh); color: #e0e4f5; }
.sv-post { margin: 0; font: 600 clamp(20px, 3vw, 40px)/1.4 var(--fh); }
.sv-stats { display: flex; justify-content: center; gap: clamp(20px, 5vw, 70px); }
body[data-card="left"] .sv-stats { justify-content: flex-start; }
.sv-stats b { display: block; font: 700 clamp(44px, 8vw, 110px)/1 var(--fh); }
.sv-stats span { font: 500 clamp(14px, 1.6vw, 22px) var(--fh); color: #e0e4f5; }

/* chrome */
.sv-top { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left)); z-index: 5; }
.sv-bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 0 max(18px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); z-index: 5; }
.sv-top, .sv-bar, body.sv-idle #sv-canvas { transition: opacity .5s; }
body.sv-idle .sv-top, body.sv-idle .sv-bar { opacity: 0; pointer-events: none; }
body.sv-idle { cursor: none; }
.sv-brand img { display: block; height: 28px; width: auto; filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .4)); }
.sv-space { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 6px 14px 6px 6px; border-radius: 16px; background: rgba(11, 16, 32, .55); border: 1px solid var(--line); backdrop-filter: blur(10px); }
.sv-space img { width: 40px; height: 40px; border-radius: 11px; object-fit: cover; filter: none; }
.sv-space span { display: flex; flex-direction: column; } .sv-space b { font: 600 15px var(--fh); } .sv-space small { font-size: 12px; color: var(--muted); }
body.sv-tv .sv-space { pointer-events: auto; }
body.sv-tv.sv-idle .sv-top { opacity: 1; } body.sv-tv.sv-idle .sv-modes { opacity: 0; }

.sv-modes, .sv-ctrl, .sv-right { display: flex; gap: 6px; padding: 5px; border-radius: 16px; background: rgba(11, 16, 32, .55); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.sv-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; min-width: 40px; padding: 0 12px; border: 0; border-radius: 11px; background: none; color: #fff;
  font: 600 13px var(--fh); text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background .15s; }
.sv-btn:hover { background: rgba(255, 255, 255, .1); }
.sv-btn:focus-visible, .sv-seg button:focus-visible, .sv-tvact > *:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 1px; }
.sv-mode[aria-pressed="true"] { background: var(--indigo); }
.sv-mode span { display: none; } .sv-mode[aria-pressed="true"] span { display: inline; }
.sv-ghost { background: rgba(11, 16, 32, .55); border: 1px solid var(--line); backdrop-filter: blur(12px); height: 50px; border-radius: 16px; }
.sv-ctrl .sv-btn, .sv-right .sv-btn { padding: 0; }
.sv-every { display: flex; align-items: center; gap: 6px; padding: 0 6px 0 10px; font: 600 12px var(--fh); color: var(--muted); }
.sv-every select { height: 32px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255, 255, 255, .08); color: #fff; font: 600 13px var(--fh); padding: 0 6px; }
.sv-every option { color: #111; }

/* settings panel */
.sv-panel { position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; background: rgba(5, 8, 20, .55); padding: 16px; }
.sv-panel[hidden] { display: none; }
.sv-panel-in { position: relative; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px; border-radius: 22px; background: #121831; border: 1px solid var(--line); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7); }
.sv-panel h3 { margin: 4px 0 10px; font: 700 17px var(--fh); }
.sv-panel h3 + .sv-note { margin-top: -4px; }
.sv-x { position: absolute; right: 12px; top: 12px; width: 36px; height: 36px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer; display: grid; place-items: center; }
.sv-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.sv-seg button { height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); color: #fff; font: 600 13px var(--fh); cursor: pointer; }
.sv-seg button[aria-checked="true"] { background: var(--indigo); border-color: var(--indigo); }
.sv-note { margin: 10px 0 18px; font-size: 13px; line-height: 1.55; color: var(--muted); }
.sv-keys { margin-bottom: 0; border-top: 1px solid var(--line); padding-top: 14px; }
.sv-tvlist { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sv-tvlist li { display: grid; grid-template-columns: 36px 1fr; gap: 4px 10px; align-items: center; padding: 10px; border-radius: 14px; background: rgba(255, 255, 255, .05); }
.sv-tvlist img { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; }
.sv-tvlist b { font: 600 14px var(--fh); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-tvact { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; }
.sv-tvact > * { height: 32px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255, 255, 255, .06); color: #fff; font: 600 12px var(--fh); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.sv-tvact > [data-a="tv_create"], .sv-tvact > [data-a="copy"] { background: var(--indigo); border-color: var(--indigo); }
.sv-tvact > [data-a="tv_off"] { color: #fca5a5; }

/* embed (idle overlay): a quiet hint that fades */
.sv-hint { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); margin: 0; font: 500 13px var(--fh); color: rgba(255, 255, 255, .7); animation: sv-fade 6s forwards; z-index: 5; }
@keyframes sv-fade { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }

@media (max-width: 720px) {
  .sv-mode[aria-pressed="true"] span, .sv-ghost span { display: none; }
  .sv-ghost { width: 50px; padding: 0; }
  .sv-every span { display: none; }
  .sv-top { flex-wrap: wrap; }
  .sv-brand img { height: 24px; }
  body[data-card="bottom"] .sv-card, body[data-card="left"] .sv-card { bottom: 96px; }
  body[data-card="left"] .sv-card { left: 20px; width: calc(100vw - 40px); }
}
@media (max-width: 400px) { .sv-every { display: none; } .sv-modes .sv-btn { min-width: 36px; } }
html.sv-nofs .sv-full { display: none; }   /* iPhone Safari: no page full screen — the page already fills the window */
@media (prefers-reduced-motion: reduce) { .sv-card, .sv-top, .sv-bar { transition: none; } }
body[data-card="sky"] .sv-card { top: 30vh; }
@media (max-width: 720px) { body[data-card="sky"] .sv-card { top: 34vh; } }
/* clock mode in daylight: dark text on a light sky */
body.sv-light .sv-card { color: #0f172a; text-shadow: 0 1px 14px rgba(255, 255, 255, .55); }
body.sv-light .sv-card .sv-k { color: #4338ca; }
body.sv-light .sv-card .sv-t, body.sv-light .sv-card .sv-stats span { color: #1e293b; }
.sv-q { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-left: 6px; border-radius: 50%; border: 1px solid var(--line); color: var(--muted); font: 600 12px var(--fh); text-decoration: none; vertical-align: 2px; }
.sv-q:hover { color: #fff; border-color: #fff; }
/* Space TV cards: overview, event, post with photo + author */
.sv-mini { margin-top: 18px; } .sv-mini b { font-size: clamp(30px, 4.6vw, 60px); }
.sv-ev { margin: 0; font: 700 clamp(26px, 4vw, 54px)/1.2 var(--fh); }
.sv-who { display: inline-flex; align-items: center; gap: 10px; margin: 16px 0 0; font: 500 clamp(14px, 1.4vw, 19px) var(--fh); color: #e0e4f5; }
.sv-who img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px rgba(255,255,255,.6); }
.sv-media { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(18px, 3vw, 40px); align-items: center; text-align: left; }
.sv-media > img { width: 100%; max-height: 46vh; object-fit: cover; border-radius: 22px; box-shadow: 0 24px 60px -18px rgba(0,0,0,.7); }
.sv-post-s { font-size: clamp(17px, 2.1vw, 28px); display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.sv-card:has(.sv-media) { width: min(1180px, calc(100vw - 48px)); }
@media (max-width: 720px) { .sv-media { grid-template-columns: 1fr; gap: 14px; } .sv-media > img { max-height: 30vh; } }
.sv-card { overflow-wrap: anywhere; }
