/* RY Live Poll — participant page + presenter dashboard */
:root {
	--g-dark: #166D38; --g: #278449; --g-soft: #E6F1EA; --g-mist: #F3F8F4;
	--ink: #1E2A22; --muted: #5B6B60; --line: #CFE3D6; --sun: #F9E267; --clay: #C26E60;
	--font: "Hind Siliguri", "Exo 2", system-ui, -apple-system, "Segoe UI", sans-serif;
	--head: "Exo 2", "Hind Siliguri", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--g-mist); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

/* ============ Participant ============ */
.p-main { max-width: 620px; margin: 0 auto; padding: 18px 16px calc(40px + env(safe-area-inset-bottom)); }
.p-head { text-align: center; padding: 8px 0 18px; }
.p-logo { height: 54px; width: auto; }
.p-head h1 { font-family: var(--head); font-size: 22px; line-height: 1.3; margin: 10px 0 0; color: var(--g-dark); }
.p-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px 18px; margin-bottom: 18px; box-shadow: 0 2px 10px rgba(22, 109, 56, .06); }
.p-seg-title { font-family: var(--head); font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--g); margin: 0 0 14px; }
.p-q + .p-q { margin-top: 26px; padding-top: 22px; border-top: 1px dashed var(--line); }
.p-q-text { display: flex; gap: 10px; font-size: 18px; font-weight: 600; line-height: 1.45; margin-bottom: 12px; white-space: pre-line; }
.p-q-num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--g-soft); color: var(--g-dark); font: 700 13px/26px var(--head); text-align: center; margin-top: 1px; }
.p-hint { font-size: 13px; color: var(--muted); margin: -6px 0 10px 36px; }
.p-options { display: grid; gap: 10px; }
.p-opt { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px 14px; min-height: 52px; font-size: 16px; line-height: 1.35; background: #fff; border: 2px solid var(--line); border-radius: 12px; transition: border-color .15s, background .15s; }
.p-opt:hover { border-color: var(--g); }
.p-opt.on { border-color: var(--g); background: var(--g-soft); font-weight: 600; }
.p-mark { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #9DB8A6; position: relative; background: #fff; }
.p-opt.multi .p-mark { border-radius: 5px; }
.p-opt.on .p-mark { border-color: var(--g); background: var(--g); }
.p-opt.on .p-mark::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.p-scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.p-scale.ten { grid-template-columns: repeat(5, 1fr); }
.p-num { height: 52px; border: 2px solid var(--line); background: #fff; border-radius: 12px; font: 700 18px var(--head); }
.p-num:hover { border-color: var(--g); }
.p-num.on { background: var(--g); border-color: var(--g); color: #fff; }
.p-scale-labels { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.p-scale-labels span:last-child { text-align: right; }
.p-text { width: 100%; font: 16px/1.5 var(--font); padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; resize: vertical; color: var(--ink); }
.p-text:focus { outline: none; border-color: var(--g); }
.p-count { text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; }
.p-submit { display: block; width: 100%; margin-top: 24px; padding: 15px; border: 0; border-radius: 12px; background: var(--g); color: #fff; font: 700 17px var(--head); letter-spacing: .02em; box-shadow: 0 4px 0 var(--g-dark); transition: transform .1s, box-shadow .1s, opacity .15s; }
.p-submit:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--g-dark); }
.p-submit:disabled { opacity: .45; box-shadow: none; }
.p-error { margin-top: 16px; padding: 10px 12px; border-radius: 10px; background: #FBF1EF; color: #9A4A3E; font-size: 14px; }
.p-done { text-align: center; }
.p-tick { width: 56px; height: 56px; margin: 4px auto 10px; border-radius: 50%; background: var(--g); color: #fff; font: 700 28px/56px var(--head); animation: pop .35s ease-out; }
.p-done-text { font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.p-link { background: none; border: 0; color: var(--g-dark); text-decoration: underline; font-size: 14px; padding: 6px; }
.p-foot { text-align: center; color: var(--muted); font-size: 14px; }
.p-wait { text-align: center; padding: 40px 10px; color: var(--muted); }
.p-wait-title { font: 700 20px var(--head); color: var(--g-dark); margin: 18px 0 6px; }
.p-pulse { width: 18px; height: 18px; border-radius: 50%; background: var(--g); margin: 0 auto; animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(39, 132, 73, .5); } 70% { box-shadow: 0 0 0 22px rgba(39, 132, 73, 0); } 100% { box-shadow: 0 0 0 0 rgba(39, 132, 73, 0); } }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 80% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }

/* ============ Dashboard ============ */
body.ry-dashboard { background: #fff; overflow: hidden; }
.d-wrap { display: grid; grid-template-columns: 320px 1fr; height: 100vh; transition: grid-template-columns .25s; }
.d-wrap.no-side { grid-template-columns: 0 1fr; }
.d-side { background: var(--g-mist); border-right: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; min-width: 0; }
.d-wrap.no-side .d-side { border: 0; }
.d-brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.d-brand img { height: 44px; width: auto; }
.d-title { font: 700 16px/1.3 var(--head); color: var(--g-dark); }
.d-seg { padding: 14px 12px 6px; border-bottom: 1px solid var(--line); }
.d-seg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 6px 8px; }
.d-seg-name { font: 700 14px/1.3 var(--head); }
.d-seg-state { font-size: 12px; color: var(--muted); }
.d-seg.is-open .d-seg-state { color: var(--g); font-weight: 600; }
.d-switch { flex: none; width: 46px; height: 26px; border-radius: 13px; border: 0; background: #C4CEC7; position: relative; transition: background .2s; padding: 0; }
.d-switch.on { background: var(--g); }
.d-knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: left .2s; }
.d-switch.on .d-knob { left: 23px; }
.d-qlist { list-style: none; margin: 0; padding: 0; }
.d-qitem { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 8px 8px; font-size: 14px; line-height: 1.35; }
.d-qitem:hover { background: var(--g-soft); }
.d-qitem.on { background: #fff; box-shadow: inset 3px 0 0 var(--g), 0 1px 3px rgba(0, 0, 0, .06); font-weight: 600; }
.d-qitem-text { flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.d-qitem-n { flex: none; min-width: 26px; padding: 1px 7px; border-radius: 10px; background: var(--g-soft); color: var(--g-dark); font: 700 12px/18px var(--head); text-align: center; }
.d-side-foot { margin-top: auto; padding: 16px; display: grid; gap: 8px; }
.d-btn { display: block; text-align: center; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: 14px; text-decoration: none; }
.d-btn:hover { border-color: var(--g); }
.d-btn-danger { color: #9A4A3E; }
.d-btn-danger:hover { border-color: var(--clay); background: #FBF1EF; }
.d-empty { padding: 18px; color: var(--muted); }

.d-main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.d-top { display: flex; align-items: center; gap: 16px; padding: 14px 24px; border-bottom: 1px solid #EEF2EF; }
.d-tool { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 18px; }
.d-tool:hover { border-color: var(--g); }
.d-join { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 4px 14px 4px 4px; border-radius: 12px; }
.d-join:hover { background: var(--g-mist); }
.d-qr-img svg { display: block; width: 100%; height: 100%; }
.d-join-lbl { font-size: 13px; color: var(--muted); }
.d-join-url { font: 700 clamp(16px, 1.6vw, 24px)/1.2 var(--head); color: var(--g-dark); word-break: break-all; }
.d-grow { flex: 1; }
.d-people { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 22px; background: var(--g-soft); font: 700 20px var(--head); color: var(--g-dark); }
.d-people-ico { font-size: 18px; }
.d-notice { margin: 10px 24px 0; padding: 10px 14px; border-radius: 10px; background: #FFFBEA; border: 1px solid #F1E3A1; font-size: 14px; }

.d-stage { flex: 1; display: flex; flex-direction: column; padding: clamp(16px, 3vh, 40px) clamp(24px, 5vw, 80px) 10px; min-height: 0; overflow: auto; }
.d-q-meta { display: flex; justify-content: space-between; gap: 16px; font-size: 15px; color: var(--muted); }
.d-total span { font: 700 18px var(--head); color: var(--ink); }
.d-q { font: 700 clamp(26px, 3.4vw, 52px)/1.2 var(--head); margin: 10px 0 0; white-space: pre-line; }
.d-avg { display: flex; align-items: baseline; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 18px; }
.d-avg b { font: 800 clamp(34px, 4vw, 60px) var(--head); color: var(--g); }
.d-chart { flex: 1; display: flex; align-items: stretch; justify-content: center; gap: clamp(12px, 3vw, 48px); margin-top: clamp(16px, 4vh, 44px); min-height: 220px; }
.d-chart.dense { gap: clamp(8px, 1.4vw, 20px); }
.d-col { flex: 1; max-width: 200px; display: flex; flex-direction: column; min-width: 0; }
.d-val { text-align: center; padding-bottom: 8px; line-height: 1.1; }
.d-val b { display: block; font: 800 clamp(22px, 2.6vw, 40px) var(--head); }
.d-val small { font-size: clamp(13px, 1.1vw, 17px); color: var(--muted); }
.d-track { flex: 1; display: flex; align-items: flex-end; min-height: 60px; }
.d-bar { width: 100%; height: 0; min-height: 4px; border-radius: 8px 8px 0 0; transition: height .7s cubic-bezier(.2, .8, .2, 1); }
.d-label { border-top: 4px solid; padding-top: 10px; text-align: center; font-size: clamp(14px, 1.3vw, 20px); font-weight: 600; line-height: 1.3; min-height: 3.6em; overflow-wrap: anywhere; }
.d-chart.dense .d-label { font-size: clamp(12px, 1vw, 16px); }
.d-scale-ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 15px; margin-top: 4px; }
.d-cards { margin-top: clamp(16px, 3vh, 36px); columns: 3 280px; column-gap: 18px; }
.d-card { break-inside: avoid; margin-bottom: 18px; background: var(--g-mist); border: 1px solid var(--line); border-top: 5px solid; border-radius: 12px; padding: 16px 18px; font-size: clamp(16px, 1.4vw, 22px); line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }
.d-card.new { animation: pop .45s ease-out; }
.d-waiting, .d-empty-stage { color: var(--muted); font-size: 20px; padding: 40px 0; text-align: center; }
.d-bottom { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 10px 0 16px; }
.d-nav { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 26px; line-height: 1; padding-bottom: 4px; }
.d-nav:hover:not(:disabled) { border-color: var(--g); color: var(--g); }
.d-nav:disabled { opacity: .35; }
.d-pos { font: 600 15px var(--head); color: var(--muted); min-width: 60px; text-align: center; }

.d-overlay { position: fixed; inset: 0; background: rgba(22, 50, 32, .7); display: flex; align-items: center; justify-content: center; z-index: 10; cursor: pointer; }
.d-qr-big { background: #fff; border-radius: 24px; padding: 28px 40px; text-align: center; }
.d-qr-big .d-qr-img { margin: 0 auto; }
.d-qr-title { font: 800 34px var(--head); color: var(--g-dark); margin: 0 0 14px; }
.d-qr-url { font: 700 clamp(20px, 2.4vw, 34px) var(--head); margin: 16px 0 4px; word-break: break-all; }
.d-qr-hint { color: var(--muted); margin: 0; font-size: 14px; }

@media (max-width: 800px) {
	.d-wrap { grid-template-columns: 0 1fr; }
	.d-wrap.no-side { grid-template-columns: 260px 1fr; }
	body.ry-dashboard { overflow: auto; }
}
