:root {
  --brand: #0084e7;
  --brand-dark: #0067b5;
  --bg: #eceff1;
  --card: #ffffff;
  --text: #212121;
  --muted: #78909c;
  --line: #e0e0e0;
  --fav: #ff9908;
  --hl: #bbdefb;
  --hl-edge: #0d47a1;
  --warn: #d32f2f;
  --tagvar-1: #dd5f5f; --tagvar-2: #ff9908; --tagvar-3: #8abdb0; --tagvar-4: #06a3cb; --tagvar-5: #9ec41c;
}
body.night {
  --bg: #121417;
  --card: #1e2227;
  --text: #e3e6ea;
  --muted: #8a96a3;
  --line: #2c3238;
  --hl: #0d47a1;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.4 Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); background: var(--card); }

#app { display: flex; flex-direction: column; height: 100%; max-width: 720px; margin: 0 auto; background: var(--bg); }

.bar {
  display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 8px;
  background: var(--brand); color: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); position: relative; z-index: 3;
}
.bar h1, .bar .title { font-size: 17px; font-weight: 500; margin: 0; flex: 1; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.icon-btn { width: 40px; height: 40px; font-size: 20px; color: #fff; border-radius: 50%; flex: none; }
.icon-btn:active { background: rgba(255,255,255,.2); }
#title-bar .caret { font-size: 12px; opacity: .8; }
#subscribers { min-width: 40px; text-align: right; font-size: 13px; opacity: .9; }
#subscribers:not(:empty)::before { content: "👁 "; }

.info-bar { padding: 8px 12px; background: #fff8e1; color: #5d4037; font-size: 14px; }
.info-bar.warn { background: #ffebee; color: var(--warn); }

.tabs { display: flex; position: relative; background: var(--brand); box-shadow: 0 2px 4px rgba(0,0,0,.15); z-index: 2; }
.tab { flex: 1; height: 44px; color: rgba(255,255,255,.7); font-size: 20px; }
.tab.active { color: #fff; }
.tab-indicator { position: absolute; bottom: 0; left: 0; width: 33.333%; height: 3px; background: #fff; transition: transform .2s; }

#views { flex: 1; position: relative; overflow: hidden; }
.view { position: absolute; inset: 0; overflow-y: auto; display: none; -webkit-overflow-scrolling: touch; }
.view.active { display: block; }

#feed { list-style: none; margin: 0; padding: 0 0 72px; }
#feed > li {
  position: relative; background: var(--card); margin: 6px 6px 0; border-radius: 3px;
  padding: 10px 64px 8px 12px; min-height: 86px; box-shadow: 0 1px 2px rgba(0,0,0,.12);
  user-select: none; -webkit-user-select: none;
}
#feed > li.own { border-left: 4px solid var(--brand); }
#feed > li.hl { background: var(--hl) !important; border-left: 10px solid var(--hl-edge); }
#feed > li.flash { animation: flash 2.2s ease-out; }
@keyframes flash { 0%, 10% { background: #ff9900; } 100% { background: var(--card); } }
#feed > li.placeholder { height: 86px; opacity: .4; }

.entry { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; margin: 0; font: inherit; }
.mention, .hashtag { color: var(--brand); cursor: pointer; }
body.night .mention, body.night .hashtag { color: #64b5f6; }

li.img { padding-right: 64px; }
.ic { position: relative; cursor: pointer; }
.thumb { display: block; width: 100%; max-height: 420px; object-fit: cover; border-radius: 2px; background: #cfd8dc; min-height: 160px; }
.ic.video::after {
  content: "▶"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 56px; height: 56px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff;
  font-size: 24px; line-height: 56px; text-align: center; padding-left: 4px;
}
.ic .dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 1px 6px; border-radius: 8px; }
.imgtext { display: block; margin-top: 6px; white-space: pre-wrap; }

.favbtn {
  position: absolute; right: 6px; top: 4px; width: 52px; height: 40px; border-radius: 20px;
  color: var(--muted); font-size: 22px;
}
.favbtn::before { content: "♡"; }
.favbtn.faved, .favbtn:disabled.faved { color: var(--fav); }
.favbtn.faved::before { content: "♥"; }
.favbtn:disabled:not(.faved) { opacity: .35; }
.favbtn.err { color: var(--warn); }
.fav { position: absolute; right: 6px; top: 42px; line-height: 18px; width: 52px; text-align: center; font-weight: 600; color: var(--fav); font-size: 14px; }
.no { position: absolute; right: 6px; bottom: 6px; line-height: 18px; width: 52px; text-align: center; color: var(--muted); font-size: 12px; cursor: pointer; }

.tag { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.tag .name { color: var(--brand); font-weight: 600; cursor: pointer; }
body.night .tag .name { color: #64b5f6; }
.tag .loc::before { content: "📍"; }
.tag .det::before { content: "🪪 "; }
.tagvar-1 { color: var(--tagvar-1) !important; } .tagvar-2 { color: var(--tagvar-2) !important; }
.tagvar-3 { color: var(--tagvar-3) !important; } .tagvar-4 { color: var(--tagvar-4) !important; }
.tagvar-5 { color: var(--tagvar-5) !important; }
.name[class*="tagvar-"]::after { content: " ≠"; font-weight: 400; }

li.infotext { padding-right: 12px !important; border-left: 4px solid var(--warn); }
li.infotext h2 { margin: 0 0 8px; font-size: 17px; color: var(--warn); }
li.infotext p { margin: 0 0 8px; font-size: 14px; }

.fab {
  position: absolute; right: 16px; bottom: 16px; width: 48px; height: 48px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 22px; box-shadow: 0 3px 8px rgba(0,0,0,.3);
}

#comment-form { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
#comment { width: 100%; min-height: 140px; resize: vertical; padding: 10px; border: 1px solid var(--line); border-radius: 3px; }
.identity { font-size: 13px; color: var(--muted); min-height: 1em; }
.primary { background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 3px; font-weight: 500; }
.primary:active { background: var(--brand-dark); }
.primary:disabled { opacity: .5; }
.wide { width: 100%; }
.ghost { display: inline-block; padding: 10px 16px; border: 1px solid var(--brand); color: var(--brand); border-radius: 3px; cursor: pointer; text-align: center; }

.capture { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
#cam { width: 100%; max-height: 50vh; background: #000; border-radius: 3px; }
.capture-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
#rec.recording { background: var(--warn); }

.side {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(320px, 85vw); background: var(--card);
  transform: translateX(-100%); transition: transform .2s; z-index: 20; box-shadow: 2px 0 8px rgba(0,0,0,.3);
  display: flex; flex-direction: column;
}
.side.open { transform: none; }
.side .bar h1 { text-align: left; padding-left: 8px; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 15; }
.menu { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.menu li { border-bottom: 1px solid var(--line); }
.row { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 14px 16px; text-align: left; cursor: pointer; }
.sub { display: block; width: calc(100% - 32px); margin: 0 16px 12px; padding: 8px; border: 1px solid var(--line); border-radius: 3px; }
div.sub { display: flex; gap: 8px; border: 0; padding: 0; }
div.sub[hidden], .sub[hidden] { display: none; }
div.sub select { flex: 1; padding: 8px; border: 1px solid var(--line); border-radius: 3px; }
.side-foot { padding: 12px 16px; font-size: 12px; color: var(--muted); margin: 0; }

.switch { appearance: none; -webkit-appearance: none; width: 40px; height: 22px; border-radius: 11px; background: #b0bec5; position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch:checked { background: var(--brand); }
.switch:checked::after { left: 20px; }

.popover {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%); width: min(420px, calc(100vw - 16px));
  max-height: 70vh; overflow-y: auto; background: var(--card); border-radius: 3px; z-index: 25;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
.popover ul { list-style: none; margin: 0; padding: 0; }
.popover li a { display: flex; gap: 8px; padding: 12px 16px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line); }
.popover li.current a { font-weight: 600; background: rgba(0,132,231,.08); }
.popover li.meeting a { color: var(--brand); }
.popover .date { flex: none; min-width: 34px; font-size: 12px; color: var(--muted); }
.popover .date.s, .popover .date.m { color: #2e7d32; }
.popover .count { margin-left: auto; color: var(--muted); font-size: 12px; }

.overlay { position: fixed; inset: 0; background: var(--bg); z-index: 30; display: flex; flex-direction: column; }
.overlay.dark { background: #000; }
.overlay[hidden], .dialog[hidden], .toast[hidden], .popover[hidden], .scrim[hidden] { display: none; }
.preview-body { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 12px; align-items: center; overflow: auto; }
.preview-body img, .preview-body video { max-width: 100%; max-height: 70vh; }
#preview-text { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 3px; }
.lb-body { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.lb-body img, .lb-body video { max-width: 100%; max-height: 100%; }
.lb-nav { display: flex; }
.faq-body { flex: 1; overflow-y: auto; padding: 8px 16px 32px; }
.faq-body h3 { color: var(--brand); margin: 20px 0 6px; }

.dialog { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog-box { background: var(--card); border-radius: 3px; padding: 18px; width: min(380px, 100%); }
.dialog-box h3 { margin: 0 0 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #323232; color: #fff; padding: 10px 16px; border-radius: 3px; z-index: 50; max-width: calc(100vw - 32px); }
