/* ═══════════════════════════════════════════════════════
   WEINROT PWA — Monochrome Hex Theme
   To change the entire color scheme: edit --accent only.
   ═══════════════════════════════════════════════════════ */
:root {
  --accent:   #8b0000;
  --bg:       #060101;
  --surface:  #0e0404;
  --text:     #e0d4d4;
  --text-dim: #6a5050;
  --mono:     'JetBrains Mono','Fira Mono','Consolas',monospace;
  --hx-w:     100px;
  --hx-h:     115.47px;
  --hx-b:     3px;
  --bar-h:    52px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: var(--bg); }

body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%2760%27%20height%3D%2734.641%27%3E%3Cg%20fill%3D%27none%27%20stroke%3D%27%231a0000%27%20stroke-width%3D%270.8%27%3E%3Cpolygon%20points%3D%2750%2C17.32%2040%2C34.64%2020%2C34.64%2010%2C17.32%2020%2C0%2040%2C0%27%2F%3E%3Cpolygon%20points%3D%2720%2C0%2010%2C17.32%20-10%2C17.32%20-20%2C0%20-10%2C-17.32%2010%2C-17.32%27%2F%3E%3Cpolygon%20points%3D%2780%2C0%2070%2C17.32%2050%2C17.32%2040%2C0%2050%2C-17.32%2070%2C-17.32%27%2F%3E%3Cpolygon%20points%3D%2720%2C34.64%2010%2C51.96%20-10%2C51.96%20-20%2C34.64%20-10%2C17.32%2010%2C17.32%27%2F%3E%3Cpolygon%20points%3D%2780%2C34.64%2070%2C51.96%2050%2C51.96%2040%2C34.64%2050%2C17.32%2070%2C17.32%27%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
  background-size: 60px 34.641px;
  opacity: 0.10;
  pointer-events: none;
  z-index: 0;
}

/* ── App shell ── */
#app {
  position: relative; z-index: 1;
  height: 100%; width: 100%;
  display: flex; flex-direction: column;
  font-family: var(--mono);
  color: var(--text);
  max-width: 480px; margin: 0 auto;
  overflow: hidden;
}

/* ── Top bar ── */
#top-bar {
  height: 44px; min-height: 44px; flex-shrink: 0;
  display: flex; align-items: center; padding: 0 16px;
  border-bottom: 1px solid var(--accent);
  background: var(--bg);
}
.brand {
  font-size: 12px; font-weight: 700; letter-spacing: 5px;
  color: var(--accent); text-transform: uppercase;
}
#top-status {
  margin-left: auto; display: flex; align-items: center; gap: 10px;
}
.s-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.3s;
}
.s-dot.on { background: var(--accent); }

/* ── Hive ── */
#hive {
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  align-items: center;
  padding: 14px 0 40px;
}
#hive::-webkit-scrollbar { width: 2px; }
#hive::-webkit-scrollbar-thumb { background: var(--accent); }

/* ── Hex row ── */
.hx-row {
  width: 300px;
  display: flex;
  gap: 0;
  margin-top: -29px;
  flex-shrink: 0;
}
.hx-row:first-child { margin-top: 0; }
.hx-row.off { transform: translateX(50px); }

/* ── Hive section divider ── */
.hx-divider {
  width: 300px;
  margin: 8px 0 6px;
  border-top: 1px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.hx-divider span {
  font-size: 7px; letter-spacing: 3px; text-transform: uppercase;
  color: var(--accent); background: var(--bg); padding: 0 8px;
  margin-top: -7px;
}

/* ── Hex outer: accent fill = visible wall ── */
.hx-w {
  width: var(--hx-w);
  height: var(--hx-h);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Gravity assembly animation */
  transition: transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.8s ease;
}
.hx-w:active { filter: brightness(1.5); }
.hx-w.active-cell { filter: brightness(1.8); }

/* ── Hex inner: dark fill — 3px accent ring shows around it ── */
.hx-c {
  width:  calc(var(--hx-w) - var(--hx-b) * 2);
  height: calc(var(--hx-h) - var(--hx-b) * 2);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

/* ── Hex content ── */
.hx-ico {
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.hx-ico svg {
  stroke: currentColor; fill: none;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.hx-lbl {
  font-size: 7px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-dim); pointer-events: none; text-align: center;
}
.hx-val {
  font-size: 12px; font-family: var(--mono);
  color: var(--text); text-align: center; line-height: 1.3;
  pointer-events: none;
}
.hx-val.mono { font-size: 11px; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.hx-val.sm   { font-size: 9px; }

/* Camera hexes */
.hx-c video {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  pointer-events: none;
}
/* Canvas hexes */
.hx-c canvas { display: block; }

/* ── Generic overlay ── */
.ov-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: none; flex-direction: column;
  z-index: 100;
}
.ov-overlay.open { display: flex; }

.ov-header {
  height: 44px; min-height: 44px; flex-shrink: 0;
  display: flex; align-items: center; padding: 0 16px; gap: 8px;
  border-bottom: 1px solid var(--accent);
  background: var(--bg);
}
.ov-close {
  margin-left: auto; background: none; border: none;
  color: var(--text-dim); cursor: pointer; padding: 6px;
  display: flex; align-items: center; justify-content: center;
}
.ov-close svg { stroke: currentColor; fill: none; stroke-width: 2; }
.ov-btn {
  background: none; border: 1px solid var(--accent);
  color: var(--accent); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 5px 10px;
}
.ov-btn svg { stroke: currentColor; fill: none; stroke-width: 2; }

/* ── Notes overlay ── */
#notes-overlay textarea {
  flex: 1; resize: none;
  background: var(--bg); border: none;
  color: var(--text); font-family: var(--mono); font-size: 14px;
  padding: 16px; outline: none; line-height: 1.7;
}
#notes-overlay textarea::placeholder { color: var(--text-dim); }

/* ── Calculator overlay ── */
#calc-display {
  flex-shrink: 0; padding: 16px 20px;
  font-size: 30px; font-family: var(--mono); font-variant-numeric: tabular-nums;
  color: var(--text); text-align: right;
  border-bottom: 1px solid var(--accent);
  min-height: 72px; word-break: break-all; overflow: hidden;
}
#calc-keys {
  flex: 1; display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--accent); padding: 1px;
}
#calc-keys button {
  background: var(--surface); border: none;
  color: var(--text); font-family: var(--mono); font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s;
}
#calc-keys button:active { background: var(--accent); color: var(--bg); }
#calc-keys button.span2 { grid-column: span 2; }
#calc-keys button.eq { background: var(--accent); color: var(--bg); font-size: 22px; }
#calc-keys button.eq:active { filter: brightness(1.3); }
#calc-keys button.op { color: var(--accent); }

/* ── Browser overlay ── */
#browser-overlay { z-index: 101; }
#browser-url {
  flex: 1; background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--text); font-family: var(--mono); font-size: 12px;
  padding: 6px 10px; outline: none;
}
#browser-url::placeholder { color: var(--text-dim); }
#browser-frame { flex: 1; border: none; background: #fff; width: 100%; }

/* ── Camera overlay ── */
#cam-ov-video {
  flex: 1; width: 100%; object-fit: cover;
  background: var(--surface);
}

/* ── Settings overlay ── */
.ov-body {
  flex: 1; overflow-y: auto;
  padding: 28px 20px; display: flex; flex-direction: column; gap: 28px;
}
.ov-setting {
  display: flex; flex-direction: column; gap: 10px;
}
.ov-setting > label {
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-dim);
}
.ov-setting input[type="color"] {
  width: 64px; height: 44px;
  border: 1px solid var(--accent);
  background: none; cursor: pointer; padding: 3px;
}
.ov-setting input[type="range"] {
  width: 100%; accent-color: var(--accent);
  background: transparent;
}

/* ── Stream overlay ── */
#stream-feed {
  flex: 1; overflow-y: auto;
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 2px;
}
#stream-feed::-webkit-scrollbar { width: 2px; }
#stream-feed::-webkit-scrollbar-thumb { background: var(--accent); }
.stream-msg {
  font-size: 11px; font-family: var(--mono);
  color: var(--text); padding: 4px 0;
  border-bottom: 1px solid var(--surface);
  animation: fadeInMsg 0.3s ease;
}
.stream-ts { color: var(--accent); margin-right: 8px; font-size: 10px; }
@keyframes fadeInMsg { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Chat overlay ── */
#chat-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: none; flex-direction: column;
  z-index: 100;
}
#chat-overlay.open { display: flex; }

#chat-header {
  height: 44px; min-height: 44px; flex-shrink: 0;
  display: flex; align-items: center; padding: 0 16px;
  border-bottom: 1px solid var(--accent);
  background: var(--bg);
}
#chat-header .brand { font-size: 11px; }
#chat-header button {
  margin-left: auto; background: none; border: none;
  color: var(--text-dim); cursor: pointer; padding: 6px;
  display: flex; align-items: center; justify-content: center;
}
#chat-header button svg { stroke: currentColor; fill: none; stroke-width: 2; }

#chat-area {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 12px 16px; display: flex; flex-direction: column; gap: 6px;
}
#chat-area::-webkit-scrollbar { width: 2px; }
#chat-area::-webkit-scrollbar-thumb { background: var(--accent); }

.msg {
  max-width: 80%; padding: 8px 12px;
  border: 1px solid var(--accent);
  font-size: 13px; line-height: 1.5;
  font-family: var(--mono);
}
.msg.u  { align-self: flex-end; background: var(--surface); }
.msg.w  { align-self: flex-start; background: var(--bg); }
.msg.sys {
  align-self: center; font-size: 10px; letter-spacing: 1px;
  color: var(--text-dim); border: none; opacity: 0.6;
}

/* ── Typing indicator ── */
#typing {
  height: 22px; padding: 0 16px;
  display: flex; align-items: center; gap: 4px;
  visibility: hidden; flex-shrink: 0;
}
#typing.show { visibility: visible; }
#typing span {
  width: 4px; height: 4px;
  background: var(--accent); border-radius: 50%;
  animation: blink 1.2s infinite;
}
#typing span:nth-child(2) { animation-delay: 0.2s; }
#typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,100%{opacity:0.2} 50%{opacity:1} }

/* ── Input bar ── */
#input-bar {
  height: var(--bar-h); min-height: var(--bar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px;
  border-top: 1px solid var(--accent);
  background: var(--bg);
  padding-bottom: max(0px, env(safe-area-inset-bottom));
}
textarea#msg-input {
  flex: 1; resize: none;
  min-height: 34px; max-height: 100px;
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--text); font-family: var(--mono); font-size: 13px;
  padding: 7px 10px; outline: none;
}
textarea#msg-input::placeholder { color: var(--text-dim); }

.btn-icon {
  width: 34px; height: 34px; flex-shrink: 0;
  background: none; border: 1px solid var(--accent);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.btn-icon svg { stroke: currentColor; fill: none; stroke-width: 1.5; }

#btn-send {
  width: 34px; height: 34px; flex-shrink: 0;
  background: var(--accent); border: none; color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
#btn-send svg { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Call overlay ── */
#call-overlay {
  position: fixed; inset: 0;
  background: var(--bg); z-index: 200;
  display: none; flex-direction: column;
}
#call-overlay.active { display: flex; }

#call-status-bar {
  height: 44px; flex-shrink: 0;
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
  border-bottom: 1px solid var(--accent);
}
#call-mode-label { font-size: 10px; letter-spacing: 2px; color: var(--accent); }
#call-timer { font-size: 10px; font-family: var(--mono); color: var(--text-dim); margin-left: auto; }

#video-main {
  flex: 1; min-height: 0; position: relative;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
}
#vid-rear { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
canvas#waveform { position: absolute; bottom: 60px; left: 16px; right: 16px; height: 60px; }
#call-transcript {
  position: absolute; bottom: 70px; left: 16px; right: 16px;
  font-size: 11px; color: var(--text); text-align: center;
}
#video-pip {
  position: absolute; bottom: 16px; right: 16px;
  width: 80px; height: 80px;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  border: 2px solid var(--accent);
  overflow: hidden;
}
#video-pip video { width: 100%; height: 100%; object-fit: cover; }

#call-bar {
  height: 60px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 0 16px; border-top: 1px solid var(--accent);
  padding-bottom: max(0px, env(safe-area-inset-bottom));
}
.btn-icon.danger { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--accent);
  color: var(--text); font-size: 11px; letter-spacing: 1px;
  padding: 6px 16px; opacity: 0;
  transition: opacity 0.3s; z-index: 300;
  pointer-events: none; white-space: nowrap;
}
#toast.show { opacity: 1; }
