:root {
  --green: #1b4332; --green-2: #2d6a4f; --green-3: #95d5b2; --saffron: #f4a261; --red: #e63946; --blue: #0077b6;
  --bg: #f3f5f2; --card: #ffffff; --text: #1d2a22; --muted: #6b7a71; --line: #e2e8e3; --radius: 14px;
  --font: -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Mangal", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: var(--font); color: var(--text); background: #0f1a14; }
button, input, select, textarea { font: inherit; }
a { color: var(--green-2); }
.hidden { display: none !important; }

/* Phone frame on desktop; full-bleed on narrow screens */
#stage { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(1200px 600px at 50% -10%, #244d3a, #0f1a14); padding: 16px; }
#phone { width: 400px; height: 820px; max-height: calc(100vh - 32px); background: #000; border-radius: 44px; padding: 12px; box-shadow: 0 30px 80px rgba(0,0,0,.6), inset 0 0 0 2px #333; }
#app { width: 100%; height: 100%; background: var(--bg); border-radius: 34px; overflow: hidden; position: relative; display: flex; flex-direction: column; }
@media (max-width: 520px) { #stage { padding: 0; } #phone { width: 100%; height: 100vh; max-height: none; border-radius: 0; padding: 0; box-shadow: none; } #app { border-radius: 0; } }
body.noframe #stage { padding: 0; } body.noframe #phone { width: 100%; height: 100vh; max-height: none; border-radius: 0; padding: 0; } body.noframe #app { border-radius: 0; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.screen.has-nav { bottom: 62px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; background: var(--green); color: #fff; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.pill { font-size: 11px; padding: 4px 8px; border-radius: 999px; background: rgba(255,255,255,.18); color: #fff; white-space: nowrap; }
.pill.dark { background: rgba(0,0,0,.55); }
.pill.good { background: #2d6a4f; } .pill.warn { background: #b5651d; }
.avatar-btn { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); background: var(--saffron); color: #1b1b1b; font-weight: 700; font-size: 12px; cursor: pointer; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px; flex: none; position: relative; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar .dot { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: #9aa; border: 2px solid #fff; }
.avatar .dot.on { background: #2ecc71; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 12px 20px; position: relative; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 4px 8px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 4px; line-height: 1.4; }
.empty { color: var(--muted); font-size: 13px; padding: 14px; text-align: center; }
.loader { text-align: center; color: var(--muted); font-size: 12px; padding: 12px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05); margin-bottom: 10px; }
.row { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.btn { background: var(--green-2); color: #fff; border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 600; cursor: pointer; }
.btn.ghost { background: #e9efe9; color: var(--green); }
.btn.ghost.light { background: rgba(255,255,255,.2); color: #fff; }
.btn.danger { background: var(--red); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; }
.icon-btn { background: transparent; border: 0; font-size: 20px; cursor: pointer; color: inherit; padding: 6px; line-height: 1; }
.icon-btn.light { color: #fff; }
.link { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font-size: 13px; }
.name { font-weight: 600; } .sub { font-size: 12px; color: var(--muted); }
input[type=text], textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; margin-top: 8px; }

/* Login */
.login-hero { background: linear-gradient(160deg, var(--green), var(--green-2)); color: #fff; padding: 46px 20px 26px; text-align: center; }
.login-hero .logo { width: 64px; height: 64px; }
.login-hero h1 { margin: 10px 0 2px; font-size: 24px; } .login-hero p { margin: 0; opacity: .85; font-size: 13px; }
.persona-list { padding: 0 12px; display: grid; gap: 8px; }
.persona { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: var(--radius); padding: 10px 12px; border: 0; text-align: left; cursor: pointer; width: 100%; }
.persona .meta { flex: 1; } .persona .chips { margin-top: 4px; }
#screen-login { overflow-y: auto; }

/* Segmented control */
.segmented { display: flex; background: var(--green); padding: 0 12px 10px; gap: 6px; }
.segmented button { flex: 1; background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 999px; padding: 7px 8px; font-size: 13px; cursor: pointer; }
.segmented button.active { background: #fff; color: var(--green); font-weight: 600; }
.segmented.small { background: transparent; padding: 0; margin-top: 6px; }
.segmented.small button { background: #e9efe9; color: var(--green); } .segmented.small button.active { background: var(--green-2); color: #fff; }

/* Feed */
.post { background: #fff; border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.post.fresh { animation: pop .6s ease; outline: 2px solid var(--green-3); }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.post-head { display: flex; gap: 10px; align-items: center; padding: 12px 12px 6px; }
.post-head .meta { flex: 1; min-width: 0; }
.post-text { padding: 2px 12px 8px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.post-media img, .post-media video { width: 100%; display: block; max-height: 260px; object-fit: cover; background: #000; }
.post-actions { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); }
.post-actions button { background: none; border: 0; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--muted); }
.post-actions button.liked { color: var(--red); font-weight: 600; }
.post-actions .spacer { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 10px; background: #eaf4ee; color: var(--green); padding: 2px 7px; border-radius: 999px; }
.chip.state { background: #fff0e0; color: #9a4b00; }
.chip.story { background: #e8f1ff; color: #0b4f8a; } .chip.scheme { background: #f3e8ff; color: #5b21b6; }
.comments { border-top: 1px solid var(--line); padding: 8px 12px; background: #fafcfa; }
.comment { font-size: 13px; margin: 4px 0; } .comment b { color: var(--green); }
.comment-form { display: flex; gap: 6px; margin-top: 6px; } .comment-form input { margin: 0; padding: 7px 10px; }
.new-posts { position: sticky; top: 4px; z-index: 5; margin: 0 auto 8px; display: block; background: var(--green-2); color: #fff; border: 0; border-radius: 999px; padding: 7px 14px; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,.25); cursor: pointer; }
.fab { position: absolute; right: 16px; bottom: 16px; width: 54px; height: 54px; border-radius: 50%; background: var(--saffron); color: #1b1b1b; font-size: 30px; border: 0; box-shadow: 0 8px 20px rgba(0,0,0,.3); cursor: pointer; }
.ack { font-size: 11px; color: var(--muted); padding: 0 12px 8px; }

/* Lists (chat list, alerts, prefs, live) */
.list { display: grid; gap: 8px; }
.item { display: flex; gap: 12px; align-items: center; background: #fff; border-radius: var(--radius); padding: 10px 12px; cursor: pointer; }
.item .meta { flex: 1; min-width: 0; } .item .meta .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .right { text-align: right; font-size: 11px; color: var(--muted); }
.unread { display: inline-block; min-width: 18px; padding: 1px 6px; border-radius: 999px; background: var(--green-2); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.item.unread-row .name { font-weight: 700; }
.alert { background: #fff; border-radius: var(--radius); padding: 10px 12px; display: flex; gap: 10px; cursor: pointer; }
.alert.unread { background: #eef7f1; }
.alert .ico { font-size: 20px; } .alert .meta { flex: 1; } .alert .time { font-size: 11px; color: var(--muted); }
.pref { background: #fff; border-radius: var(--radius); padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.pref .meta { flex: 1; } .pref input[type=number] { width: 58px; border: 1px solid var(--line); border-radius: 8px; padding: 5px; text-align: center; }
.switch { width: 44px; height: 26px; border-radius: 999px; background: #cfd8d1; position: relative; border: 0; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .15s; }
.switch.on { background: var(--green-2); } .switch.on::after { left: 21px; }
.push-card { display: flex; align-items: center; gap: 10px; } .push-card .name { font-size: 14px; }

/* Chat view */
.chat-head { padding: 10px 12px; gap: 10px; justify-content: flex-start; }
.chat-title { flex: 1; min-width: 0; } .chat-title .sub { color: rgba(255,255,255,.8); }
.messages { background: #e8efe7; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 78%; background: #fff; border-radius: 14px; padding: 8px 10px; font-size: 14px; line-height: 1.4; align-self: flex-start; box-shadow: 0 1px 1px rgba(0,0,0,.06); word-break: break-word; }
.msg.me { align-self: flex-end; background: #d8f3dc; }
.msg .who { font-size: 11px; color: var(--green-2); font-weight: 600; margin-bottom: 2px; }
.msg .time { font-size: 10px; color: var(--muted); text-align: right; margin-top: 3px; }
.msg .ticks { color: #9aa; } .msg .ticks.read { color: #1e90ff; }
.msg img, .msg video { max-width: 100%; border-radius: 10px; display: block; }
.msg audio { width: 220px; max-width: 100%; }
.msg .file { display: flex; gap: 8px; align-items: center; padding: 6px; background: #f1f5f2; border-radius: 8px; color: var(--green); text-decoration: none; }
.msg .lat { font-size: 10px; color: var(--muted); }
.typing { font-size: 12px; color: var(--muted); padding: 2px 16px 4px; background: #e8efe7; }
.composer { display: flex; align-items: center; gap: 4px; padding: 8px 10px; background: #fff; border-top: 1px solid var(--line); }
.composer input[type=text] { flex: 1; margin: 0; border-radius: 999px; }
.send-btn { background: var(--green-2); color: #fff; border: 0; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; }
.composer .icon-btn.rec { color: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.daysep { align-self: center; font-size: 11px; color: var(--muted); background: #fff; padding: 2px 10px; border-radius: 999px; }

/* Live */
.golive h3 { margin: 0 0 4px; } .golive p { margin: 0; font-size: 13px; color: var(--muted); }
.live-item .thumb { width: 54px; height: 54px; border-radius: 12px; background: linear-gradient(135deg, #e63946, #f4a261); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 11px; }
.vod-card { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.vod-thumb { width: 64px; height: 64px; border-radius: 12px; background: linear-gradient(135deg, #1b4332, #52b788); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 24px; flex: none; }
.live-stage { position: absolute; inset: 0; background: #000; display: flex; flex-direction: column; }
.live-stage video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.live-stage.vod { background: #0f1a14; } .live-stage.vod video { height: auto; max-height: 50%; object-fit: contain; }
.vod-info { padding: 14px; color: #fff; } .vod-info .sub { color: #b8c4bc; }
.live-overlay { position: absolute; left: 0; right: 0; display: flex; gap: 8px; align-items: center; padding: 12px; }
.live-overlay.top { top: 0; } .live-overlay.bottom { bottom: 0; background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.live-overlay input { margin: 0; flex: 1; border-radius: 999px; background: rgba(255,255,255,.9); }
.live-badge { background: var(--red); color: #fff; font-weight: 700; font-size: 11px; padding: 4px 8px; border-radius: 6px; letter-spacing: .05em; }
.live-comments { position: absolute; left: 12px; right: 12px; bottom: 70px; display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.live-comments div { background: rgba(0,0,0,.45); color: #fff; font-size: 13px; padding: 5px 10px; border-radius: 10px; align-self: flex-start; max-width: 85%; animation: pop .3s ease; }
.live-comments b { color: var(--green-3); }

/* Bottom nav */
#nav { position: absolute; left: 0; right: 0; bottom: 0; height: 62px; background: #fff; border-top: 1px solid var(--line); display: flex; }
#nav button { flex: 1; background: none; border: 0; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 8px; cursor: pointer; position: relative; }
#nav button .ico { font-size: 20px; } #nav button.active { color: var(--green); font-weight: 600; }
#nav .badge { position: absolute; top: 6px; right: calc(50% - 22px); background: var(--red); color: #fff; font-size: 10px; min-width: 16px; padding: 1px 5px; border-radius: 999px; font-weight: 700; }

/* Composer sheet */
.sheet { position: absolute; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; z-index: 20; }
.sheet-body { background: #fff; width: 100%; border-radius: 22px 22px 0 0; padding: 14px 16px 18px; max-height: 90%; overflow-y: auto; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.media-strip { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.media-strip img, .media-strip video { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }

/* Toasts (in-app notification banners) */
#toasts { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 30; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: #111; color: #fff; border-radius: 14px; padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start; box-shadow: 0 10px 30px rgba(0,0,0,.4); pointer-events: auto; cursor: pointer; animation: pop .25s ease; }
.toast .ico { font-size: 18px; } .toast .t { font-weight: 600; font-size: 13px; } .toast .b { font-size: 12px; opacity: .85; }
.toast .src { font-size: 10px; opacity: .6; margin-top: 2px; }
