/* communicouple — visual style ported from the divadiscbot 'simple' mode (Phase R).
   Dark glass-morphism over a cosmic background, hot-pink accent, Instrument Serif + Barlow.
   All tokens are CSS custom properties so later phases inherit the look. DOM ids/classes are
   preserved (the e2e + app JS depend on them). */

:root {
  /* palette — comma triples so rgba(var(--x), a) composes */
  --text-main: 255, 255, 255;
  --accent: 255, 0, 127;                 /* hot pink #ff007f */
  --danger: 255, 76, 76;
  /* glass primitive */
  --glass-border: linear-gradient(135deg, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0.32) 50%, rgba(255,255,255,0.22) 100%);
  --glass-shadow: 0 12px 40px rgba(0,0,0,0.5);
  --glass-inner-shadow: inset 0 1px 1px rgba(255,255,255,0.2), inset 0 -1px 1px rgba(0,0,0,0.55);
  --glass-bg: rgba(var(--text-main), 0.09); /* frosted tint over the cosmic bg */
  --blur-val: 16px;                          /* card frost (was 3px — too subtle) */
  --sat-val: 180%;
  --bg-base: #000;
  --bg-filter: contrast(1.15) brightness(0.45) saturate(1.1);
  --bg-tint-alpha: 0.55;
  /* shell */
  --text-scale: 1.0;
  --s-maxw: 820px;
  --s-accent: rgb(255,0,127);
  /* section accent colors (later phases: cursor hues, media tints) */
  --c-gold: 255,220,80; --c-sky: 100,200,255; --c-purple: 160,100,255; --c-mint: 100,255,180; --c-pink: 255,100,200;
  /* compatibility shims for any untouched rule */
  --ink: rgb(var(--text-main));
  --muted: rgba(var(--text-main),0.6);
  --line: rgba(var(--text-main),0.10);
  --radius: 20px;
}
.light-theme {
  --text-main: 15, 23, 42;
  --glass-shadow: 0 12px 40px rgba(31,38,135,0.08);
  --glass-inner-shadow: inset 0 1px 1px rgba(255,255,255,0.5), inset 0 -1px 1px rgba(255,255,255,0.1);
  --blur-val: 18px; --sat-val: 140%;
  --glass-bg: rgba(255, 255, 255, 0.5);
  --bg-base: #f8fafc;
  --bg-filter: grayscale(0) contrast(1) brightness(1.1);
}
body[data-text-size="small"]  { --text-scale: 0.92; }
body[data-text-size="medium"] { --text-scale: 1.0; }
body[data-text-size="large"]  { --text-scale: 1.10; }

* { box-sizing: border-box; }

body {
  margin: 0; min-height: 100dvh;
  font-family: 'Barlow', system-ui, sans-serif; font-weight: 400;
  font-size: calc(15px * var(--text-scale)); line-height: 1.5;
  color: rgb(var(--text-main)); background: var(--bg-base);
  overflow-x: hidden;
  padding: 0 14px env(safe-area-inset-bottom);
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* background layers */
.bg-layer { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.bg-layer img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.05); filter: var(--bg-filter); }
.bg-tint { position: fixed; inset: 0; z-index: 1; pointer-events: none; background: rgba(0,0,0, var(--bg-tint-alpha, 0.55)); }
.light-theme .bg-tint { background: rgba(241,245,249, var(--bg-tint-alpha, 0.5)); }
#login, #hub { position: relative; z-index: 2; }

.hidden { display: none !important; }
.muted { color: rgba(var(--text-main), 0.6); }
.small { font-size: 0.82rem; }
.error { color: #ffb3b3; min-height: 1.2em; }
.ok { color: rgb(var(--c-mint)); min-height: 1.2em; }

/* glass utility (for static + future-phase elements) */
.glass {
  background: transparent; position: relative; border: none;
  backdrop-filter: blur(var(--blur-val)) saturate(var(--sat-val));
  -webkit-backdrop-filter: blur(var(--blur-val)) saturate(var(--sat-val));
  box-shadow: var(--glass-shadow), var(--glass-inner-shadow);
  contain: layout style paint;
}
.glass::before, .glass-edge::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: var(--glass-border);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 6;
}

/* buttons */
button {
  cursor: pointer; font: inherit; font-weight: 600; font-size: 0.98rem; color: #fff;
  border: none; padding: 12px; border-radius: 14px;
  background: rgba(255,255,255,0.08); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14);
  transition: transform .12s ease, background .14s ease;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: .5; cursor: default; }
button.ghost, .ghost {
  background: transparent; box-shadow: inset 0 0 0 1px rgba(var(--text-main),0.18); color: rgb(var(--text-main));
}
button.ghost:hover { background: rgba(var(--text-main),0.06); }
button.danger, .danger { background: rgba(var(--danger),0.85); box-shadow: none; color: #fff; }
.tp-btn {
  background: var(--s-accent); box-shadow: none; color: #fff;
  border: none; border-radius: 14px; padding: 12px 16px; font-weight: 600; cursor: pointer;
  transition: transform .12s ease, filter .14s ease;
}
.tp-btn:hover { filter: brightness(1.08); }
.tp-btn:active { transform: scale(0.97); }

/* inputs */
input, select, textarea {
  font: inherit; color: rgb(var(--text-main)); border: none; outline: none;
  padding: 12px 14px; border-radius: 14px;
  background: rgba(255,255,255,0.06); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14);
}
input:focus, select:focus, textarea:focus { box-shadow: inset 0 0 0 1.5px rgba(var(--accent),0.7); }
select option, select optgroup { background: #1a1320; color: #fff; }

/* login dialog */
.card {
  width: min(440px, 100%); margin: 12vh auto; position: relative;
  padding: 24px; border-radius: 28px; color: rgb(var(--text-main));
  background: rgba(12,12,20,0.45);
  backdrop-filter: blur(32px) saturate(180%); -webkit-backdrop-filter: blur(32px) saturate(180%);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.13), 0 28px 80px rgba(0,0,0,0.65), inset 0 0 0 1px rgba(255,255,255,0.08);
  animation: fadeUp .5s .05s both;
}
.card h1 { font-family: 'Instrument Serif', serif; font-weight: 400; font-size: 1.8rem; margin: 0 0 .2rem; }
#login-form { display: grid; gap: .8rem; margin-top: 1rem; }
#login-form label { display: grid; gap: .25rem; font-size: 0.82rem; color: rgba(var(--text-main),0.6); }
#login-form button[type=submit] { background: var(--s-accent); box-shadow: none; color: #fff; }

/* topbar — floating sticky glass pill */
.topbar {
  position: sticky; top: 10px; z-index: 40;
  max-width: var(--s-maxw); margin: 14px auto 0; padding: 9px 14px;
  display: flex; align-items: center; gap: 12px; border-radius: 999px; border: none;
  background: transparent;
  backdrop-filter: blur(22px) saturate(180%); -webkit-backdrop-filter: blur(22px) saturate(180%);
  box-shadow: var(--glass-shadow), inset 0 0 0 1px rgba(var(--text-main),0.14);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-family: 'Instrument Serif', serif; font-weight: 400; font-size: 1.18rem; color: rgb(var(--text-main)); }
/* fancy wordmark + chat-bubble-heart logo */
.brand-word { background: linear-gradient(115deg, #ffffff 0%, #ffd3e7 38%, #ff7ab8 75%, #ff3f9a 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; letter-spacing: .2px; }
.brand-icon { flex: 0 0 auto; width: 28px; height: 25px; overflow: visible; filter: drop-shadow(0 2px 7px rgba(255, 0, 127, .45)); }
.brand-icon .heart { transform-box: fill-box; transform-origin: center; animation: heartbeat 2.6s ease-in-out infinite; }
.brand-icon .heart2 { transform-box: fill-box; transform-origin: center; animation: heartbeat 2.6s ease-in-out infinite .4s; opacity: .9; }
@keyframes heartbeat { 0%, 22%, 100% { transform: scale(1); } 8% { transform: scale(1.22); } 15% { transform: scale(.96); } }
.brand-title { display: inline-flex; align-items: center; gap: 11px; }
.brand-title .brand-icon { width: 40px; height: 36px; }
.brand-title .brand-word { font-size: 1.9rem; }
.topbar nav {
  display: flex; align-items: center; gap: 2px; margin-left: auto; padding: 4px; border-radius: 13px;
  background: rgba(var(--text-main),0.04); box-shadow: inset 0 0 0 1px rgba(var(--text-main),0.18);
}
.tab {
  appearance: none; border: none; background: transparent; color: rgba(var(--text-main),0.6);
  font: inherit; font-weight: 500; font-size: 12px; padding: 7px 14px; border-radius: 9px;
  cursor: pointer; transition: background .2s, color .2s, transform .15s; box-shadow: none;
}
.tab:hover { color: rgb(var(--text-main)); background: rgba(var(--text-main),0.06); }
.tab:active { transform: scale(0.96); }
.tab.active {
  background: rgba(var(--text-main),0.16); color: rgb(var(--text-main));
  backdrop-filter: blur(24px) saturate(220%); -webkit-backdrop-filter: blur(24px) saturate(220%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22), inset 0 -1px 0 rgba(0,0,0,0.12), 0 4px 16px rgba(0,0,0,0.18);
}
.who { color: rgba(var(--text-main),0.7); font-size: 0.82rem; margin: 0 .2rem; }
#logout { padding: 8px 12px; font-size: 0.86rem; font-weight: 500; }

/* views */
.view { max-width: var(--s-maxw); margin: 1.5rem auto; padding: 0; }
.view h2 { font-family: 'Instrument Serif', serif; font-weight: 400; font-size: 1.5rem; margin: 1.2rem 0 .6rem; color: rgb(var(--text-main)); }
.view h3 { font-family: 'Instrument Serif', serif; font-weight: 400; font-size: 1.2rem; margin: 1rem 0 .4rem; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* entry cards (glass) */
.entry-feature { margin-bottom: 1.5rem; }
.entry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card-link {
  display: grid; gap: .3rem; text-decoration: none; color: rgb(var(--text-main));
  background: var(--glass-bg); border: none; border-radius: 20px; padding: 20px; position: relative;
  backdrop-filter: blur(var(--blur-val)) saturate(var(--sat-val)); -webkit-backdrop-filter: blur(var(--blur-val)) saturate(var(--sat-val));
  box-shadow: var(--glass-shadow), var(--glass-inner-shadow);
  transition: transform .12s ease; animation: fadeUp .5s both;
}
.card-link::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; background: var(--glass-border);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; z-index: 6;
}
.card-link:hover { transform: translateY(-2px); }
.card-link.big { padding: 28px 24px; border-radius: 28px; }
.card-link strong { font-family: 'Instrument Serif', serif; font-weight: 400; font-size: 1.5rem; }
.kind { font-size: 10px; letter-spacing: .3em; font-weight: 700; text-transform: uppercase; color: rgb(var(--accent)); }
.badge { font-size: .66rem; padding: 2px 8px; border-radius: 999px; background: rgba(var(--text-main),0.08); color: rgba(var(--text-main),0.7); box-shadow: inset 0 0 0 1px rgba(var(--text-main),0.12); }

/* account + my-account panels (glass) */
#view-accounts, #view-account {
  position: relative; padding: 20px; border-radius: 20px;
  background: var(--glass-bg); backdrop-filter: blur(var(--blur-val)) saturate(var(--sat-val)); -webkit-backdrop-filter: blur(var(--blur-val)) saturate(var(--sat-val));
  box-shadow: var(--glass-shadow), var(--glass-inner-shadow); animation: fadeUp .45s both;
}
#view-accounts::before, #view-account::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; background: var(--glass-border);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; z-index: 6;
}
#view-accounts > *, #view-account > * { position: relative; z-index: 7; }
.acct-row { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; padding: 12px 8px; border-bottom: 1px solid rgba(var(--text-main),0.07); }
.acct-row:last-child { border-bottom: none; }
.acct-row .acct-name { min-width: 120px; flex: 0 0 auto; }
.acct-row .acct-pw { flex: 1 1 160px; min-width: 140px; }
.acct-row .muted { min-width: 120px; }
.row-form { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }

/* entry view */
.entry-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.entry-head .save-state { margin-left: auto; }
.ghost-link { color: rgba(var(--text-main),0.6); text-decoration: none; }
.ghost-link:hover { color: rgb(var(--text-main)); }
.entry-title { font-family: 'Instrument Serif', serif; font-weight: 400; font-size: 2rem; margin: .2rem 0 1rem; }
.entry-title-input { width: 100%; font-family: 'Instrument Serif', serif; font-weight: 400; font-size: 1.8rem; margin-bottom: .8rem; }
.entry-body {
  position: relative; padding: 24px; border-radius: 20px; animation: fadeUp .4s both;
  background: var(--glass-bg); backdrop-filter: blur(var(--blur-val)) saturate(var(--sat-val)); -webkit-backdrop-filter: blur(var(--blur-val)) saturate(var(--sat-val));
  box-shadow: var(--glass-shadow), var(--glass-inner-shadow);
}
.entry-body::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; background: var(--glass-border);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; z-index: 6;
}
.entry-body .blk { position: relative; z-index: 7; margin: 0 0 .6rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.entry-body .blk:last-child { margin-bottom: 0; }
.entry-body code { font-family: ui-monospace, "Cascadia Code", monospace; font-size: .86em; background: rgba(var(--text-main),0.06); padding: .05rem .35rem; border-radius: 6px; }
.entry-textarea { width: 100%; min-height: 50vh; resize: vertical; line-height: 1.6; }

/* collaborative editor (Phase 2) */
.editor-toolbar { display: flex; gap: .4rem; margin-bottom: .6rem; }
button.mini { padding: 5px 12px; font-size: 13px; border-radius: 9px; }
/* id selector — the ported editor-styles.css also targets #rich-editor-wrapper (white bg); match
   its specificity so our glass theme wins. */
#rich-editor-wrapper {
  position: relative; min-height: 50vh; padding: 20px; border-radius: 20px;
  background: var(--glass-bg); backdrop-filter: blur(var(--blur-val)) saturate(var(--sat-val)); -webkit-backdrop-filter: blur(var(--blur-val)) saturate(var(--sat-val));
  box-shadow: var(--glass-shadow), var(--glass-inner-shadow);
}
#rich-editor-wrapper::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; background: var(--glass-border);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; z-index: 6;
}
.scrollnote-rich-editor { position: relative; z-index: 7; min-height: 46vh; }
.dark-theme .scrollnote-rich-editor { background: transparent; padding: 4px 2px; } /* glass wrapper is the surface; editor text = #e0e0e0 */
.scrollnote-rich-editor [data-block-id] { margin: 0 0 .6rem; }
.hue-swatch { display: inline-block; width: 34px; height: 34px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(var(--text-main),0.3); vertical-align: middle; }

/* appearance settings (theme / text size / bg dim) */
.pref-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin: .6rem 0; }
.pref-label { min-width: 150px; color: rgba(var(--text-main), 0.8); }
.seg { display: inline-flex; gap: 2px; padding: 4px; border-radius: 12px; background: rgba(var(--text-main), 0.06); box-shadow: inset 0 0 0 1px rgba(var(--text-main), 0.12); }
.seg button { appearance: none; border: none; background: transparent; color: rgba(var(--text-main), 0.65); box-shadow: none; font: inherit; font-weight: 500; font-size: .9rem; padding: 6px 14px; border-radius: 9px; cursor: pointer; transition: background .15s, color .15s; }
.seg button:hover { color: rgb(var(--text-main)); }
.seg button.active { background: rgba(var(--text-main), 0.16); color: rgb(var(--text-main)); box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 2px 8px rgba(0,0,0,.14); }
.pref-row input[type=range] { flex: 1; min-width: 160px; }

/* rich elements — beacons (Phase 4) */
.tb-sep { width: 1px; align-self: stretch; background: rgba(var(--text-main), 0.15); margin: 0 4px; }
.blk.beacon { margin: .8rem 0; }
.blk-image { margin: 0; }
.blk-image img, .beacon-image img { max-width: 100%; height: auto; border-radius: 14px; display: block; }
.blk-image figcaption, .beacon-image .caption, .grid-cap { margin: .4rem 0 0; font-size: .85rem; color: rgba(var(--text-main), 0.6); }
.blk-grid { display: grid; grid-template-columns: repeat(var(--cols, auto-fill), minmax(120px, 1fr)); gap: 8px; }
.blk-grid .grid-cell { display: block; border-radius: 12px; overflow: hidden; }
.blk-grid .grid-cell img { width: 100%; height: 130px; object-fit: cover; display: block; background: #000; }
.bubble { max-width: 80%; padding: 10px 14px; border-radius: 16px; margin: .3rem 0; display: inline-flex; flex-direction: column; gap: 2px;
  background: rgba(var(--text-main), 0.08); box-shadow: inset 0 0 0 1px rgba(var(--text-main), 0.12); }
.bubble.right { margin-left: auto; background: rgba(var(--accent), 0.18); box-shadow: inset 0 0 0 1px rgba(var(--accent), 0.3); }
.bubble.left { margin-right: auto; }
.bubble-author { font-size: .72rem; font-weight: 600; color: rgba(var(--text-main), 0.7); }
.bubble-img { max-width: 220px; border-radius: 10px; margin: 2px 0; }
.bubble-ts { font-size: .68rem; color: rgba(var(--text-main), 0.5); align-self: flex-end; }
.editor-beacon { margin: .8rem 0; }

/* annotate mode — custom non-native selector + voice threads (Phase 3) */
.entry-body.annotate {
  user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; cursor: pointer;
}
.entry-body.annotate .w { border-radius: 4px; padding: 0 1px; transition: background .1s; }
.entry-body.annotate .w.sel { background: rgba(var(--accent), 0.55); color: #fff; }
.entry-body.annotate .w.hl-lite { background: rgba(var(--accent), 0.16); box-shadow: inset 0 -2px 0 rgba(var(--accent), 0.5); }
.entry-body.annotate .w.hl { background: rgba(var(--accent), 0.24); box-shadow: inset 0 -2px 0 rgb(var(--accent)); }
.annot-hint { margin: 0 0 .6rem; }

.annot-panel {
  position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(140%);
  width: min(640px, calc(100% - 28px)); z-index: 80; padding: 12px 14px; border-radius: 20px;
  display: flex; flex-direction: column; gap: 10px; opacity: 0; pointer-events: none;
  background: rgba(12,12,20,0.55); backdrop-filter: blur(28px) saturate(180%); -webkit-backdrop-filter: blur(28px) saturate(180%);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.13), 0 20px 60px rgba(0,0,0,0.6);
  transition: transform .22s ease, opacity .22s ease;
}
.annot-panel.open { transform: translateX(-50%) translateY(0); opacity: 1; pointer-events: auto; }
.annot-nav { display: flex; gap: 6px; justify-content: center; }
.annot-nav button { min-width: 48px; font-size: 16px; }
.annot-quote { font-family: 'Instrument Serif', serif; font-size: 1.05rem; opacity: .85; text-align: center; }
.annot-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.annot-actions audio { height: 36px; max-width: 100%; }
.rec-dot { color: rgb(var(--accent)); animation: recpulse 1s infinite; }
@keyframes recpulse { 50% { opacity: .3; } }
.vocal-item { display: flex; align-items: center; gap: 10px; width: 100%; }
.vocal-item audio { flex: 1; }
.thread-foot { display: flex; gap: 8px; width: 100%; justify-content: center; margin-top: 4px; }

/* micro-interactions */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* responsive */
@media (max-width: 560px) {
  .tab { padding: 8px 10px; }
  .card-link.big { padding: 20px; }
}
@media (max-width: 520px) { .who { display: none; } }
@media (max-width: 460px) { .card-link { padding: 16px; } }
