/* memoria · theme-agnostic components (tab bar, bubbles, cards, fields, hotspots…) */

/* ---------- bottom tab bar ---------- */
.tabbar {
  display: flex;
  align-items: stretch;
  background: var(--tabbar-bg);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  flex: 0 0 auto;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0 2px;
  color: var(--text-2);
  font-size: 11px;
  border-radius: 10px;
  transition: color 0.15s ease;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--accent-deep); font-weight: 600; }

/* ---------- page header bar ---------- */
.header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
}
.header .title { font-size: 22px; }
.header .spacer { flex: 1; }
.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
}
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow);
}
.btn.ghost {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn.small { padding: 4px 12px; font-size: 12px; }

/* ---------- homepage hotspots ---------- */
.home-scroll { flex: 1; overflow-y: auto; }
.home-scene { position: relative; width: 100%; overflow: hidden; }
.home-img { position: absolute; top: 0; left: 0; width: 100%; height: auto; display: block; }
.hotspot {
  position: absolute;
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
}
.hotspot:active { background: rgba(255, 255, 255, 0.22); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.35); }
.hotspot-label { display: none; }
body.dev .hotspot {
  outline: 1.5px dashed rgba(214, 96, 77, 0.9);
  background: rgba(255, 214, 102, 0.14);
}
body.dev .hotspot-label {
  display: block;
  position: absolute;
  top: 2px; left: 2px;
  background: rgba(40, 32, 24, 0.75);
  color: #fff;
  font-size: 10px;
  line-height: 1.4;
  padding: 1px 5px;
  border-radius: 5px;
  pointer-events: none;
}
.theme-toggle {
  position: absolute;
  top: 52px; right: 14px;
  z-index: 5;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--tabbar-bg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--text-2);
  backdrop-filter: blur(8px);
}
.theme-toggle svg { width: 19px; height: 19px; }

/* ---------- chat ---------- */
.chat-scroll { flex: 1; overflow-y: auto; padding: 8px 16px 16px; }
.msg-row { display: flex; flex-direction: column; margin-bottom: 14px; }
.msg-row.user { align-items: flex-end; }
.msg-row.peer { align-items: flex-start; }
.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: var(--radius-bubble);
  font-size: 14.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  box-shadow: var(--shadow);
}
.msg-row.peer .bubble { background: var(--bubble-peer); border-top-left-radius: 6px; border: 1px solid var(--line); }
.msg-row.user .bubble { background: var(--bubble-user); border-top-right-radius: 6px; }
.msg-meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-caption {
  text-align: center;
  font-size: 12px;
  color: var(--text-2);
  margin: 18px 0 6px;
  display: flex; align-items: center; gap: 12px;
}
.chat-caption::before, .chat-caption::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 17px;
  color: #fff;
  background: linear-gradient(140deg, var(--brown), var(--accent-deep));
  box-shadow: var(--shadow);
}
.chat-inputbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--tabbar-bg);
  border-top: 1px solid var(--line);
}
.chat-inputbar input {
  flex: 1;
  border: none; outline: none;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
}
.chat-inputbar input::placeholder { color: var(--text-2); }
.round-btn {
  width: 38px; height: 38px; flex: 0 0 auto;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent);
  color: #fff;
}
.round-btn.muted { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.round-btn svg { width: 18px; height: 18px; }

/* ---------- memory cards ---------- */
.masonry { columns: 2; column-gap: 14px; padding: 4px 16px 16px; }
.mem-card {
  break-inside: avoid;
  position: relative;
  margin-bottom: 16px;
  padding: 18px 14px 12px;
  border-radius: 6px 14px 14px 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.mem-card.tint-0 { background: var(--surface); }
.mem-card.tint-1 { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.mem-card.tint-2 { background: color-mix(in srgb, var(--brown) 14%, var(--surface)); }
.mem-card.tint-3 { background: var(--surface-2); }
.mem-card .tape {
  position: absolute;
  top: -8px; left: 50%;
  width: 56px; height: 16px;
  transform: translateX(-50%) rotate(-3deg);
  background: color-mix(in srgb, var(--accent) 38%, transparent);
  border-radius: 2px;
  opacity: 0.85;
}
.mem-card:nth-child(even) .tape { transform: translateX(-50%) rotate(4deg); background: color-mix(in srgb, var(--brown) 40%, transparent); }
.mem-text { font-size: 13.5px; line-height: 1.7; }
.mem-date { margin-top: 10px; font-size: 11px; color: var(--text-2); }
.mem-tags { font-size: 11px; color: var(--text-2); opacity: 0.85; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; padding: 10px 16px 4px; overflow-x: auto; flex: 0 0 auto; }
.chip {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- form fields (settings) ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}
.field { padding: 12px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: none; }
.field-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.field-label { font-size: 14px; }
.field-label small { color: var(--text-2); margin-left: 4px; }
.field-val { font-size: 13px; color: var(--accent-deep); font-variant-numeric: tabular-nums; font-weight: 600; }
.text-input, .select-input, .textarea-input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.text-input:focus, .select-input:focus, .textarea-input:focus { border-color: var(--accent); }
.textarea-input { font-family: var(--font-mono); font-size: 12.5px; min-height: 90px; resize: vertical; }

/* range slider */
input[type="range"] {
  width: 100%;
  appearance: none; -webkit-appearance: none;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent-deep);
  border: 2.5px solid var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent-deep); border: 2.5px solid var(--surface);
}

/* segmented control */
.segmented {
  display: flex;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
}
.seg {
  flex: 1;
  padding: 8px 0 6px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--text-2);
  text-align: center;
  line-height: 1.3;
}
.seg small { display: block; font-size: 10px; opacity: 0.8; }
.seg.active { background: var(--surface); color: var(--accent-deep); font-weight: 600; box-shadow: var(--shadow); }

/* list rows (settings groups) */
.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  background: none;
}
.row:last-child { border-bottom: none; }
.row .row-icon { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--accent-deep); flex: 0 0 auto; }
.row .row-icon svg { width: 16px; height: 16px; }
.row .row-main { flex: 1; }
.row .row-title { font-size: 14.5px; }
.row .row-sub { font-size: 11.5px; color: var(--text-2); }
.row .chev { color: var(--text-2); }
.row .chev svg { width: 16px; height: 16px; }

/* header key-value editor */
.kv-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.kv-row .text-input { font-size: 13px; padding: 8px 10px; }

/* toggle switch */
.switch { position: relative; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; }
.switch .knob {
  position: absolute; inset: 0;
  background: var(--line);
  border-radius: 999px;
  transition: background 0.15s ease;
  pointer-events: none;
}
.switch .knob::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .knob { background: var(--accent); }
.switch input:checked + .knob::after { transform: translateX(18px); }

/* ---------- toast ---------- */
.toast {
  position: absolute;
  left: 50%; bottom: 96px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(60, 52, 44, 0.92);
  color: #fdfbf5;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- terminal ---------- */
.term-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.75;
  color: var(--text);
}
.term-scroll .prompt { color: var(--text-2); }
.term-scroll .cmd { color: var(--text); font-weight: 600; }
.term-scroll .out { white-space: pre-wrap; color: var(--text-2); margin: 4px 0 14px; }
.term-scroll .out.ok { color: var(--accent-deep); }
.term-scroll .cursor { display: inline-block; width: 7px; height: 14px; background: var(--accent-deep); vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
