[hidden] {
  display: none !important;
}

:root {
  --bg: #ffffff;
  --bg-elev: #f4f3ee;
  --bg-input: #fbfbfa;
  --line: #e4e2d8;
  --text: #1b1b16;
  --muted: #6e6d64;
  --copper: #d9923a;
  --copper-deep: #b06e1f;
  --signal: #3cba7a;
  --signal-dim: rgba(60, 186, 122, 0.16);
  --danger: #e25c4a;
  --danger-dim: rgba(226, 92, 74, 0.14);
  --danger-strong: #b3372a;
  --signal-strong: #1d7a4d;
  --warn-strong: #9a6a1a;
  --err-text: #e25c4a;
  --toast-bg: #26261f;
  --toast-text: #f4efe4;
  --hover-bg: #e9e7de;
  --primary-1: #4f93dc;
  --primary-2: #2f6cb0;
  --primary-text: #ffffff;
  --accent: var(--primary-2);
  --mark-1: #4f93dc;
  --mark-2: #2f6cb0;
  --mark-text: #ffffff;
  --tint-1: rgba(79, 147, 220, 0.1);
  --tint-2: rgba(79, 147, 220, 0.06);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --tap: 48px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

html[data-theme="blue"] {
  --primary-1: #4f93dc;
  --primary-2: #2f6cb0;
  --primary-text: #ffffff;
  --mark-1: #4f93dc;
  --mark-2: #2f6cb0;
  --mark-text: #ffffff;
  --tint-1: rgba(79, 147, 220, 0.1);
  --tint-2: rgba(79, 147, 220, 0.06);
}

html[data-theme="red"] {
  --primary-1: #d9634c;
  --primary-2: #b03a26;
  --primary-text: #ffffff;
  --mark-1: #d9634c;
  --mark-2: #b03a26;
  --mark-text: #ffffff;
  --tint-1: rgba(217, 99, 76, 0.1);
  --tint-2: rgba(217, 99, 76, 0.06);
}

html[data-theme="green"] {
  --primary-1: #3fa46a;
  --primary-2: #2a7a4e;
  --primary-text: #ffffff;
  --mark-1: #3fa46a;
  --mark-2: #2a7a4e;
  --mark-text: #ffffff;
  --tint-1: rgba(63, 164, 106, 0.1);
  --tint-2: rgba(63, 164, 106, 0.06);
}

html[data-theme="orange"] {
  --primary-1: #e8933c;
  --primary-2: #c06f1a;
  --primary-text: #ffffff;
  --mark-1: #e8933c;
  --mark-2: #c06f1a;
  --mark-text: #ffffff;
  --tint-1: rgba(232, 147, 60, 0.1);
  --tint-2: rgba(232, 147, 60, 0.06);
}

html[data-theme="gray"] {
  --primary-1: #7a7e7a;
  --primary-2: #5b5f5b;
  --primary-text: #ffffff;
  --mark-1: #7a7e7a;
  --mark-2: #545854;
  --mark-text: #ffffff;
  --tint-1: rgba(122, 126, 122, 0.1);
  --tint-2: rgba(122, 126, 122, 0.06);
}

html[data-theme="dark"] {
  --bg: #10140f;
  --bg-elev: #1a2118;
  --bg-input: #0c100b;
  --line: #2c3828;
  --text: #f4efe4;
  --muted: #9aa892;
  --danger-strong: #ffd2cb;
  --signal-strong: #d9ffe9;
  --warn-strong: #f0c27a;
  --err-text: #ffb4aa;
  --toast-bg: #24301f;
  --toast-text: #f4efe4;
  --hover-bg: #24301f;
  --primary-1: #e3a24a;
  --primary-2: #b06e1f;
  --primary-text: #1a1206;
  --mark-1: #d9923a;
  --mark-2: #b06e1f;
  --mark-text: #1a1206;
  --tint-1: rgba(217, 146, 58, 0.12);
  --tint-2: rgba(60, 186, 122, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, var(--tint-1), transparent 50%),
    radial-gradient(900px 480px at 100% 0%, var(--tint-2), transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body {
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}

button,
input,
textarea {
  font: inherit;
}

.app {
  max-width: 760px;
  margin: 0 auto;
}

.topbar {
  margin-bottom: 10px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-name {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  line-height: 1.3;
}

.topbar-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* Sign-in button sits on the top row, right before the gear */
.auth-inline {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.auth-inline .auth-who {
  margin: 0;
}

.mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--mark-1), var(--mark-2));
  display: grid;
  place-items: center;
  color: var(--mark-text);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0;
  box-shadow: var(--shadow);
}

.icon-btn,
.ghost-btn,
.primary-btn,
.danger-btn {
  min-height: var(--tap);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 14px;
  padding: 0 14px;
  cursor: pointer;
}

.icon-btn {
  width: var(--tap);
  padding: 0;
  font-size: 1.1rem;
}

.primary-btn {
  background: linear-gradient(180deg, var(--primary-1), var(--primary-2));
  border-color: transparent;
  color: var(--primary-text);
  font-weight: 650;
}

.ghost-btn {
  color: var(--text);
}

.ghost-btn.active {
  border-color: #d64545;
  color: #d64545;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.danger-btn {
  background: var(--danger-dim);
  border-color: rgba(226, 92, 74, 0.35);
  color: var(--danger-strong);
}

.stack {
  display: grid;
  gap: 16px;
}

.card {
  background: color-mix(in srgb, var(--bg-elev) 92%, black);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.notes-head {
  margin-bottom: 10px;
}

.notes-title {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.parse-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.parse-hint strong {
  color: var(--text);
  font-weight: 550;
}

.status {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.status.ok {
  color: var(--signal);
}

.status.err {
  color: var(--err-text);
}

.transcript {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  line-height: 1.45;
}

.parse-row {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.parse-btn {
  min-height: var(--tap);
  padding: 0 14px;
  font-size: 0.95rem;
}

.aux-actions,
.row-actions,
.field-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.aux-actions .ghost-btn,
.aux-actions .primary-btn {
  flex: 1 1 6.5rem;
}

.save-actions .primary-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  padding: 0 8px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.save-choices {
  display: grid;
  gap: 8px;
}

.save-choices .ghost-btn,
.save-choices .primary-btn {
  width: 100%;
  min-height: 48px;
}

.places-kicker {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.contact-fields {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.grid-city {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .grid-city {
    grid-template-columns: 1.4fr 0.7fr 0.8fr;
  }
}

@keyframes field-flash {
  0% {
    border-color: rgba(60, 186, 122, 0.85);
    background: color-mix(in srgb, var(--bg-input) 72%, #3cba7a);
    box-shadow: 0 0 0 3px var(--signal-dim);
  }
  100% {
    border-color: var(--line);
    background: var(--bg-input);
    box-shadow: none;
  }
}

@keyframes card-flash {
  0%,
  35% {
    border-color: rgba(60, 186, 122, 0.7);
    box-shadow: 0 0 0 3px var(--signal-dim), var(--shadow);
  }
  100% {
    border-color: var(--line);
    box-shadow: var(--shadow);
  }
}

.field input.flash,
.field textarea.flash {
  animation: field-flash 0.85s ease;
}

.notes-card.parse-flash,
.places-card.parse-flash,
.contact-card.parse-flash {
  animation: card-flash 0.85s ease;
}

.fields {
  display: grid;
  gap: 10px;
}

.field label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}

.field input,
.field textarea {
  width: 100%;
  min-height: var(--tap);
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.grid-2 {
  display: grid;
  gap: 10px;
}

@media (min-width: 560px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.history {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.history-item {
  display: grid;
  gap: 4px;
  text-align: left;
  width: 100%;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
}

.history-item strong {
  font-size: 0.98rem;
}

.history-item span {
  color: var(--muted);
  font-size: 0.82rem;
  font-family: var(--mono);
}

.empty {
  color: var(--muted);
  padding: 18px 8px;
  text-align: center;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 6, 0.72);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}

.overlay.open {
  display: flex;
}

.sheet {
  width: min(560px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.sheet h2 {
  margin: 0 0 8px;
}

.sheet p {
  margin: 0 0 14px;
  color: var(--muted);
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.notes-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 12px 0 10px;
}

.auth-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-top: 10px;
}

.auth-who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.auth-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--line);
}

.auth-pill.approved {
  color: var(--signal-strong);
  border-color: rgba(60, 186, 122, 0.5);
  background: var(--signal-dim);
}

.auth-pill.pending {
  color: var(--warn-strong);
  border-color: rgba(217, 146, 58, 0.45);
}

.auth-pill.revoked {
  color: var(--danger-strong);
  border-color: rgba(226, 92, 74, 0.45);
  background: var(--danger-dim);
}

.fields,
.grid-2,
.field {
  overflow: visible;
}

.suggest-wrap {
  position: relative;
  z-index: 4;
}

.suggest-wrap.is-open {
  z-index: 20;
}

.suggest-list {
  display: none;
  margin-top: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.suggest-list.is-open {
  display: grid;
}

.suggest-item {
  display: grid;
  gap: 2px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 0;
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  cursor: pointer;
}

.suggest-item:first-child {
  border-top: 0;
}

.suggest-item span {
  color: var(--muted);
  font-size: 0.8rem;
}

.suggest-item:hover {
  background: var(--hover-bg);
}

.suggest-item.suggest-msg {
  color: var(--muted);
  cursor: default;
}

.suggest-item.suggest-msg.err {
  color: var(--danger-strong);
}

.admin-card {
  margin-top: 16px;
}

.admin-user {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.admin-user:first-child {
  border-top: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(120%);
  background: var(--toast-bg);
  border: 1px solid var(--line);
  color: var(--toast-text);
  padding: 12px 16px;
  border-radius: 999px;
  z-index: 30;
  transition: transform 0.25s ease;
  max-width: calc(100% - 24px);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.capture-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  flex-direction: column;
  background: #050705;
}

.capture-overlay.open {
  display: flex;
}

.capture-stage {
  position: relative;
  flex: 1;
  min-height: 220px;
  overflow: hidden;
  background: #000;
}

.capture-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.capture-overlay:not(.has-camera) video {
  visibility: hidden;
}

.capture-fallback {
  display: none;
  position: absolute;
  inset: 0;
  place-content: center;
  text-align: center;
  padding: 24px;
  color: var(--muted);
  background: #0b0f0a;
}

.capture-overlay:not(.has-camera) .capture-fallback {
  display: grid;
}

.capture-guide {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.capture-frame {
  position: absolute;
  left: 50%;
  top: 44%;
  width: min(88vw, 540px);
  aspect-ratio: 1.75 / 1;
  transform: translate(-50%, -50%);
  border-radius: 16px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.55);
  outline: 2px solid rgba(240, 194, 122, 0.9);
}

.capture-hint {
  position: absolute;
  left: 16px;
  right: 16px;
  top: calc(44% + min(26vw, 160px));
  margin: 0;
  text-align: center;
  color: #f4efe4;
  font-size: 0.95rem;
  text-shadow: 0 1px 8px #000;
}

.capture-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  background: #10140f;
  border-top: 1px solid var(--line);
}

.capture-bar h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.capture-bar p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.capture-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.capture-shot {
  min-width: 148px;
  min-height: 56px;
}

@media (max-width: 640px) {
  .capture-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .capture-actions {
    justify-content: stretch;
  }

  .capture-actions .primary-btn,
  .capture-actions .ghost-btn {
    flex: 1;
  }
}

/* Settings menu */
.menu-wrap {
  position: relative;
}

/* Plain settings gear: no background box, just the icon */
#configBtn {
  background: none;
  border: none;
  padding: 6px;
  min-height: 0;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--accent);
}

/* Compact custom Google sign-in button: tight spacing around the G and text */
.gsi-compact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.gsi-compact .gsi-g {
  width: 16px;
  height: 16px;
  display: block;
}

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
  min-width: 230px;
  z-index: 50;
}

.menu-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}

.menu-label:not(:first-child) {
  margin-top: 14px;
}

.theme-opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.theme-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.theme-opt .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
}

.theme-opt[data-theme-opt="light"] .dot {
  background: #4f93dc;
}

.theme-opt[data-theme-opt="gray"] .dot {
  background: #7a7e7a;
}

.theme-opt[data-theme-opt="green"] .dot {
  background: #3fa46a;
}

.theme-opt[data-theme-opt="orange"] .dot {
  background: #e8933c;
}

.theme-opt[data-theme-opt="red"] .dot {
  background: #d9634c;
}

.theme-opt[data-theme-opt="dark"] .dot {
  background: #10140f;
  border: 1px solid var(--line);
}

.theme-opt.active {
  border-color: var(--primary-1);
  box-shadow: 0 0 0 1px var(--primary-1);
}

.menu-signout {
  width: 100%;
}
