/* Talking Points — assets/app.css — v1.9.2 */
/* v1.9.2: the blue end-of-talk marker is a bar along the top edge only (was a frame on all four sides). */
/* v1.9.1: thin blue frame in the presenter — pulsing on the second-to-last card, steady on the last (see end of file). */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #16181d;
  --muted: #646b78;
  --border: #dde1e7;
  --primary: #3b6cf6;
  --primary-text: #ffffff;
  --danger: #d23b3b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --p-bg: #111317;
  --p-text: #f3f4f6;
  --p-muted: #9aa1ad;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317;
    --surface: #1a1d23;
    --surface-2: #23272f;
    --text: #eceef2;
    --muted: #9aa1ad;
    --border: #2d323b;
    --primary: #5b86ff;
    --danger: #ff6b6b;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
svg { width: 1.15em; height: 1.15em; flex: none; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h2 { font-size: 1.05rem; }
a { color: var(--primary); }
.muted { color: var(--muted); margin: 0 0 1rem; }
.small-text { font-size: .85rem; }
.empty { color: var(--muted); padding: 1rem 0; list-style: none; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 42px; padding: 0 1rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--primary); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 36px; padding: 0 .7rem; font-size: .9rem; }
.btn.icon { padding: 0; width: 36px; }
.btn.block { width: 100%; }

input, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: .65rem .8rem;
}
input:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
textarea { resize: vertical; min-height: 72px; line-height: 1.45; }
label { display: block; font-weight: 550; font-size: .9rem; margin-bottom: .8rem; }
label input { margin-top: .3rem; font-weight: 400; }
.btn input[type=file] { display: none; }
label.btn { margin: 0; font-size: .9rem; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .5rem 16px; padding-top: max(.5rem, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.brand { font-weight: 700; font-size: 1.05rem; }
.device-badge {
  display: inline-flex; align-items: center; gap: .3em;
  font-size: .8rem; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: .15rem .6rem;
}

/* ---------- Pages ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 1.2rem 16px 4rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.6rem; box-shadow: var(--shadow); }
.inline-form { display: flex; gap: .5rem; }
.inline-form input { flex: 1; min-width: 0; }
.section-title { display: flex; align-items: center; gap: .5rem; }
.count { font-size: .8rem; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: .05rem .55rem; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.6rem; box-shadow: var(--shadow); }
.auth-title { font-size: 1.6rem; margin-bottom: .2rem; }
.hint { font-size: .82rem; color: var(--muted); margin: -.4rem 0 .8rem; }
.form-error { color: var(--danger); min-height: 1.2em; margin: 0 0 .6rem; font-size: .9rem; }
.auth-switch { text-align: center; margin: 1rem 0 0; font-size: .92rem; }
.auth-device { text-align: center; margin: 1rem 0 0; }
.version { color: var(--muted); font-size: .75rem; margin-top: 1rem; }

/* ---------- Talk list ---------- */
.talk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.talk-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.talk-item.open { border-color: var(--primary); }
.talk-select {
  display: flex; flex-direction: column; align-items: flex-start; gap: .1rem;
  width: 100%; padding: .9rem 1rem; text-align: left;
  background: none; border: 0; color: inherit; font: inherit; cursor: pointer;
}
.talk-title { font-weight: 650; font-size: 1.05rem; overflow-wrap: anywhere; }
.talk-meta { color: var(--muted); font-size: .85rem; }
.talk-actions { display: none; gap: .5rem; padding: 0 1rem 1rem; flex-wrap: wrap; }
.talk-item.open .talk-actions { display: flex; }
.talk-actions .btn { flex: 1 1 0; min-width: 90px; }

/* ---------- Editor ---------- */
.editor-head { display: flex; gap: .6rem; align-items: center; margin-bottom: .3rem; }
.title-input { font-size: 1.3rem; font-weight: 700; flex: 1; min-width: 0; border-color: transparent; background: transparent; padding-left: .4rem; }
.title-input:hover { border-color: var(--border); }
.card-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .8rem; }
.card-edit { display: flex; gap: .7rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; box-shadow: var(--shadow); }
.card-num { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.card-body { flex: 1; min-width: 0; position: relative; }
.card-heading { font-weight: 700; margin-bottom: .5rem; padding-right: 4.5rem; }
.card-img { margin-top: .6rem; }
.card-img img { display: block; max-width: 100%; max-height: 220px; border-radius: 8px; border: 1px solid var(--border); }
.card-tools { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; align-items: center; }
.card-tools .spacer { flex: 1; }
.save-state { position: absolute; top: .35rem; right: .6rem; font-size: .75rem; color: var(--muted); pointer-events: none; }
.add-card { width: 100%; border-style: dashed; min-height: 52px; }

/* ---------- Modal & toast ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 400px; background: var(--surface); color: var(--text); border-radius: 16px; padding: 1.3rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.modal p { color: var(--muted); }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; }
#toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 200;
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: #222630; color: #fff; padding: .6rem 1rem; border-radius: 10px; font-size: .92rem;
  max-width: calc(100% - 32px); transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); }

/* ---------- Presenter ---------- */
html.presenting, html.presenting body { overflow: hidden; height: 100%; overscroll-behavior: none; background: var(--p-bg); }
.present {
  position: fixed; inset: 0; background: var(--p-bg); color: var(--p-text);
  touch-action: none; user-select: none; -webkit-user-select: none; outline: none;
  overflow: hidden;
}
.p-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: .6rem;
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
}
.p-title { flex: 1; min-width: 0; color: var(--p-muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-counter { color: var(--p-muted); font-variant-numeric: tabular-nums; font-size: .95rem; }
.p-btn {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .06); color: var(--p-text);
  cursor: pointer; font: inherit;
}
.p-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .14); }
.p-btn:disabled { opacity: .3; cursor: default; }
.p-btn svg { width: 22px; height: 22px; }

.p-track { position: absolute; inset: 0; }
.p-card {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem;
  padding: 76px 24px 64px; padding-top: calc(76px + env(safe-area-inset-top)); padding-bottom: calc(64px + env(safe-area-inset-bottom));
  transition: transform .42s cubic-bezier(.2, .8, .2, 1), opacity .42s;
  will-change: transform;
}
.p-card.above { transform: translateY(-100%); opacity: 0; }
.p-card.below { transform: translateY(100%); opacity: 0; }
.p-card.current { transform: translateY(0); opacity: 1; }
.p-text {
  max-width: 1100px; width: 100%; text-align: center; font-weight: 400; line-height: 1.25;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.fs-xl .p-text { font-size: clamp(2.2rem, 8vw, 5.5rem); }
.fs-lg .p-text { font-size: clamp(1.7rem, 5.5vw, 3.8rem); }
.fs-md .p-text { font-size: clamp(1.35rem, 3.8vw, 2.6rem); line-height: 1.32; }
.fs-sm .p-text { font-size: clamp(1.1rem, 2.6vw, 1.8rem); line-height: 1.4; text-align: left; }
.has-img .p-text { font-size: clamp(1.2rem, 3.6vw, 2.4rem); }
.p-heading { display: block; font-weight: 800; color: #ffffff; margin-bottom: .2em; }   /* v1.1.1/v1.1.2 */
.p-heading + .p-body { color: #b4bac5; }   /* v1.1.2: dimmed only when a heading is present */
.p-img { flex: 1 1 auto; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.p-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px; pointer-events: none; }
.p-card:not(.has-img) .p-img { display: none; }

.p-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .08); z-index: 5; }
.p-bar { height: 100%; width: 0; background: var(--primary); transition: width .3s; }
.p-nav { position: absolute; right: 16px; bottom: 24px; z-index: 5; display: flex; flex-direction: column; gap: .5rem; }
.p-hint {
  position: absolute; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 4;
  text-align: center; color: var(--p-muted); font-size: .85rem; transition: opacity .4s; pointer-events: none;
}
.p-hint.gone { opacity: 0; }
.p-end {
  position: absolute; left: 50%; bottom: 40%; transform: translateX(-50%); z-index: 6;
  background: rgba(255, 255, 255, .12); padding: .5rem 1rem; border-radius: 999px; font-size: .9rem;
  opacity: 0; transition: opacity .25s; pointer-events: none;
}
.p-end.show { opacity: 1; }

/* Phone: bigger touch targets, no PC nav */
html.device-phone .p-nav { display: none; }
html.device-pc .p-card { padding-left: 80px; padding-right: 80px; }

@media (max-width: 480px) {
  .talk-actions .btn { min-width: 0; }
  .editor-head .btn { padding: 0 .8rem; }
}

@media (prefers-reduced-motion: reduce) {
  .p-card { transition: opacity .2s; }
  .p-card.above, .p-card.below { transform: none; }
}

/* v1.2.0: sharing */
.share-link { font-size: .9rem; margin: .2rem 0 1rem; }
.modal-actions.wrap { flex-wrap: wrap; }
.modal-actions .spacer { flex: 1; }
.shared-badge {
  display: inline-block; vertical-align: middle; margin-left: .4rem;
  font-size: .7rem; font-weight: 600; color: var(--primary);
  border: 1px solid var(--primary); border-radius: 999px; padding: 0 .45rem;
}
.shared-card .auth-title { overflow-wrap: anywhere; }
@media (max-width: 480px) { .editor-head { flex-wrap: wrap; } .title-input { flex-basis: 100%; } }

/* v1.3.0: slide field in editor */
.card-row { display: flex; gap: .5rem; align-items: flex-start; }
.card-row .card-heading { flex: 1; min-width: 0; }
.card-slide { display: flex; align-items: center; gap: .3rem; margin: 0; font-size: .8rem; color: var(--muted); font-weight: 600; }
.card-slide input { width: 4.2rem; margin: 0; padding: .55rem .4rem; text-align: center; font-weight: 600; }
.section-title .spacer { flex: 1; }
.section-title .btn { font-size: .85rem; }

/* v1.3.0 / v1.4.1: PowerPoint remote in presenter — one slim line */
.p-remote-hint { color: var(--p-muted); font-size: .75rem; white-space: nowrap; flex: none; }
.p-remote-hint[hidden] { display: none; }
.p-slideflash {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 8;
  background: rgba(59, 108, 246, .9); color: #fff; padding: .5rem 1rem; border-radius: 999px;
  font-weight: 700; opacity: 0; transition: opacity .15s; pointer-events: none;
}
.p-slideflash.show { opacity: 1; }
.p-btn.active { background: var(--primary); border-color: var(--primary); }
.p-remote {
  position: absolute; left: 0; right: 0; bottom: 4px; z-index: 7;
  display: flex; align-items: center; gap: .5rem;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  background: rgba(17, 19, 23, .92); border-top: 1px solid rgba(255, 255, 255, .1);
  touch-action: manipulation;
}
.p-remote[hidden] { display: none; }
.seg { display: inline-flex; border: 1px solid rgba(255, 255, 255, .2); border-radius: 10px; overflow: hidden; flex: none; }
.seg button { background: transparent; color: var(--p-text); border: 0; padding: .45rem .8rem; font: inherit; font-size: .9rem; cursor: pointer; }
.seg.small button { padding: .3rem .55rem; font-size: .8rem; }
.seg button + button { border-left: 1px solid rgba(255, 255, 255, .2); }
.seg button.on { background: var(--primary); color: #fff; font-weight: 600; }
.p-remote-status { display: inline-flex; align-items: center; gap: .35rem; color: var(--p-muted); font-size: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; flex: 1; min-width: 0; overflow: hidden; }
.p-remote-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7280; flex: none; }
.p-remote-status.mid .dot { background: #e0a526; }
.p-remote-status.ok { color: #7ee2a8; }
.p-remote-status.ok .dot { background: #34c77b; }
.p-remote-manual { display: inline-flex; gap: .35rem; flex: none; }
.p-remote-manual[hidden] { display: none; }
.p-slide-btn {
  width: 44px; height: 34px; border-radius: 8px; font: inherit; font-size: .95rem; line-height: 1;
  background: rgba(255, 255, 255, .1); color: var(--p-text); border: 1px solid rgba(255, 255, 255, .2); cursor: pointer;
}
.p-slide-btn:active { background: var(--primary); }
.present.remote-on .p-hint { display: none; }
.present:has(.p-remote:not([hidden])) .p-card { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.present:has(.p-remote:not([hidden])) .p-nav { bottom: 60px; }
.modal.wide { max-width: 560px; }
.steps { padding-left: 1.2rem; color: var(--muted); }
.steps li { margin-bottom: .5rem; }
.steps code { display: block; margin-top: .3rem; padding: .5rem; background: var(--surface-2); color: var(--text); border-radius: 8px; font-size: .78rem; overflow-wrap: anywhere; user-select: all; }
.seg.light { border-color: var(--border); margin-bottom: .4rem; }
.seg.light button { color: var(--text); }
.seg.light button + button { border-left-color: var(--border); }
.seg.light button.on { color: #fff; }

/* v1.3.0: keep the top bar on one line on narrow phones */
.topbar .btn, .brand { white-space: nowrap; }
@media (max-width: 430px) {
  .topbar { padding-left: 12px; padding-right: 12px; }
  .topbar .db-label { display: none; }
  .device-badge { padding: .25rem .4rem; }
  .brand { font-size: .98rem; }
  .topbar .btn.small { padding: 0 .55rem; }
}

/* v1.4.0: storage */
.storage-banner { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .88rem; padding: .6rem .8rem; border-radius: 10px; margin: 0 0 .8rem; border: 1px solid var(--border); background: var(--surface); }
.storage-banner.ok { border-color: #2f9e62; }
.storage-banner.warn { border-color: #d39b22; }
.busy { font-weight: 600; }
.section-title { flex-wrap: wrap; }

/* v1.4.1: fullscreen = clean view; PowerPoint status as a dot on the PC icon */
.present.is-full .p-remote:not(.force) { display: none; }
.present.is-full .p-card { padding-bottom: calc(64px + env(safe-area-inset-bottom)) !important; }
.present.is-full .p-nav { bottom: 24px !important; }
#pRemote { position: relative; }
#pRemote.st-ok::after, #pRemote.st-mid::after {
  content: ''; position: absolute; right: 4px; top: 4px; width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--p-bg); background: #34c77b;
}
#pRemote.st-mid::after { background: #e0a526; }

/* v1.5.0: Black (blackout) button */
.p-black {
  flex: none; height: 30px; padding: 0 .7rem; border-radius: 8px; font: inherit; font-size: .8rem; font-weight: 700;
  background: #000; color: var(--p-text); border: 1px solid rgba(255, 255, 255, .35); cursor: pointer;
}
.p-black[hidden] { display: none; }
.p-black.on { background: #fff; color: #000; border-color: #fff; }

/* v1.5.2: long press must not open the browser's context menu / callout */
.present { -webkit-touch-callout: none; }

/* v1.5.6: dialogs taller than the screen (e.g. PowerPoint remote on iPhone) scroll instead of hiding the buttons */
.modal { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* v1.7.0: per-card timer */
.card-time { display: flex; align-items: center; gap: .3rem; margin: 0; font-size: .8rem; color: var(--muted); font-weight: 600; }
.card-time input { width: 4.4rem; margin: 0; padding: .55rem .4rem; text-align: center; font-weight: 600; }
.card-time input.invalid { border-color: var(--danger); outline-color: var(--danger); }
@media (max-width: 480px) { .card-row { flex-wrap: wrap; } .card-row .card-heading { flex-basis: 100%; } }
.p-timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; color: var(--p-text);
  padding: .15rem .55rem; border-radius: 8px; background: rgba(255, 255, 255, .08); }
.p-timer[hidden] { display: none; }
.present::after { content: ''; position: absolute; inset: 0; z-index: 9; pointer-events: none;
  border: 0 solid transparent; transition: border-color .3s, border-width .3s; }
.present.t-warn::after { border-width: 4px; border-color: #e0a526; }   /* v1.7.1: was 8px */
.present.t-over::after { border-width: 5px; border-color: #e5383b; }   /* v1.7.1: was 10px */
.present.t-warn .p-timer { background: #e0a526; color: #111; }
.present.t-over .p-timer { background: #e5383b; color: #fff; }

/* v1.7.1: Talks button in the editor head */
.editor-head { flex-wrap: wrap; }
@media (max-width: 480px) { .editor-head .btn { flex: 1 1 auto; } }

/* v1.7.2: red frame blinks 4 times when the time is up, then stays */
@keyframes tpBlink { 0%, 100% { border-color: #e5383b; } 50% { border-color: transparent; } }
.present.t-over.t-blink::after { animation: tpBlink .5s step-end 4; }

/* v1.7.3: account line under the talk list (email · Change password · version) */
.account-line { color: var(--muted); font-size: .8rem; text-align: center; margin: 2rem 0 1rem; }
.account-line a { color: inherit; text-decoration: underline; }
.modal .form-error { color: var(--danger); }   /* v1.7.3: error text in dialogs is red (was grey via .modal p) */

/* v1.9.1: the end of the talk is near — thin blue marker (3 px): pulsing on the second-to-last card, steady on the last.
   v1.9.2: a bar along the top edge only (was a frame on all four sides).
   Drawn with ::before; the timer frame (::after, yellow 4 px / red 5 px) is painted on top of it when both are on. */
.present::before { content: ''; position: absolute; top: env(safe-area-inset-top, 0px); left: 0; right: 0; height: 3px;   /* below the iPhone status bar in the installed app */
  z-index: 9; pointer-events: none;
  background: transparent; }
.present.pos-penult::before, .present.pos-last::before { background: var(--primary); }
@keyframes tpPulse { 0%, 100% { opacity: 1; } 50% { opacity: .15; } }
.present.pos-penult::before { animation: tpPulse 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .present.pos-penult::before { animation: none; opacity: .5; } }
