:root {
  --sand: #fff0df;
  --sky: #d8eeff;
  --mint: #dbf7e8;
  --ink: #102334;
  --muted: #5b7085;
  --card: rgba(255, 255, 255, 0.9);
  --stroke: rgba(16, 35, 52, 0.14);
  --primary: #138dff;
  --primary-strong: #0b68bc;
  --accent: #17ad79;
  --danger: #be3c2f;
  --radius: 18px;
  --shadow: 0 16px 34px rgba(16, 35, 52, 0.16);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
}

body {
  background: linear-gradient(140deg, var(--sand), var(--sky));
}

body.modal-open {
  overflow: hidden;
}

body.modal-open #appView[aria-hidden="true"],
body.modal-open #authView[aria-hidden="true"] {
  pointer-events: none;
}

.app-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 133, 64, 0.2), transparent 36%),
    radial-gradient(circle at 88% 12%, rgba(19, 141, 255, 0.25), transparent 38%),
    radial-gradient(circle at 52% 92%, rgba(23, 173, 121, 0.21), transparent 45%);
}

.auth-screen,
.mobile-app {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: env(safe-area-inset-top) 12px calc(12px + env(safe-area-inset-bottom));
  position: relative;
}

.auth-screen {
  min-height: 100dvh;
  display: grid;
  align-content: center;
  gap: 12px;
}

.auth-hero,
.auth-card,
.card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(5px);
}

.auth-hero,
.auth-card,
.card {
  padding: 14px;
}

.auth-hero h1 {
  margin: 4px 0;
  font-size: clamp(2rem, 8vw, 2.9rem);
  letter-spacing: 0.02em;
}

.auth-hero p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-btn {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  padding: 10px;
  font-weight: 700;
}

.tab-btn.is-active {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(120deg, var(--primary), #4fc8ff);
}

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

label {
  display: grid;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 700;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(16, 35, 52, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  padding: 10px 12px;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(19, 141, 255, 0.24);
  border-color: transparent;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(120deg, var(--primary), #4fc8ff);
}

.btn-primary:active {
  background: var(--primary-strong);
}

.btn-secondary {
  color: #0b5a8f;
  background: rgba(19, 141, 255, 0.14);
  border: 1px solid rgba(19, 141, 255, 0.24);
}

.btn-ghost {
  color: #0b5a8f;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(16, 35, 52, 0.17);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.auth-link-btn {
  border: none;
  background: transparent;
  color: #0b5a8f;
  text-decoration: underline;
  justify-self: start;
  padding: 0;
  font-weight: 700;
  cursor: pointer;
}

.auth-link-btn:active {
  color: #08456d;
}

.msg {
  min-height: 1.2rem;
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 0.88rem;
}

.mobile-app {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 10px;
}

.group-switch {
  display: grid;
  gap: 6px;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.content {
  padding-bottom: 74px;
}

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

.card h3 {
  margin: 0 0 10px;
}

.groups-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.top-gap-sm {
  margin-top: 8px;
}

.groups-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.group-plus-btn {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(16, 35, 52, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #2c4a63;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.group-plus-btn:active {
  transform: scale(0.97);
}

.group-plus-close {
  font-size: 1.4rem;
}

.group-detail-form {
  margin-bottom: 10px;
}

.group-detail-member-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.group-members-wrap {
  margin-top: 10px;
}

.group-members-wrap h4 {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.group-members-list {
  display: grid;
  gap: 20px;
}

.group-members-list.list {
  gap: 20px;
}

.member-list-item {
  padding: 20px 12px;
  height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.member-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.member-row-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.member-row-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.member-avatar {
  width: 80px;
  height: 80px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(16, 35, 52, 0.2);
  background: #e7edf5;
  flex: 0 0 auto;
}

.member-row-name {
  display: block;
  font-size: 1rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-row-meta {
  margin-top: 4px;
  margin-left: 88px;
  font-size: 0.8rem;
}

.account-avatar-block {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.account-card {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.account-head {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  padding: 12px;
}

.account-head-text h3 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.2;
}

.account-head-text p {
  margin: 3px 0 0;
}

.account-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.account-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(16, 35, 52, 0.16);
  border-radius: 14px;
  background: rgba(241, 248, 255, 0.88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.account-tabs .tab-btn {
  min-height: 42px;
}

.account-tabs .tab-btn:not(.is-active) {
  background: rgba(255, 255, 255, 0.94);
}

.account-tab-panel {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(16, 35, 52, 0.13);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.84);
}

.account-color-card {
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.86);
  display: grid;
  gap: 8px;
}

.account-llm-panel {
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.9);
  display: grid;
  gap: 8px;
}

.account-llm-panel h4 {
  margin: 0;
  font-size: 0.95rem;
}

.account-llm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.account-admin-actions {
  display: grid;
  gap: 8px;
}

.account-admin-actions .btn {
  width: 100%;
}

.account-chat-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.85rem;
  color: #2c445a;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
  padding: 0;
  border: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(16, 35, 52, 0.18);
  transition: background 0.2s ease;
}

.switch-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(16, 35, 52, 0.28);
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-slider {
  background: rgba(23, 173, 121, 0.78);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.account-stats {
  margin: 0;
}

.account-logout-btn {
  justify-self: stretch;
}

.avatar-preview {
  width: 74px;
  height: 74px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(16, 35, 52, 0.2);
  background: #e7edf5;
}

.account-avatar-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
}

#userAvatarInput {
  display: none;
}

.group-detail-toprow {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.group-detail-toprow input[type="color"] {
  width: 40px;
  height: 32px;
  padding: 1px;
  border-radius: 8px;
}

.group-detail-head-card {
  position: static;
  box-shadow: none;
  backdrop-filter: none;
}

#viewGroupDetail {
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: calc(100dvh - 74px - env(safe-area-inset-bottom));
  overflow: hidden;
}

.group-detail-places-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin-bottom: 20px;
}

#groupDetailList {
  flex: 1;
  max-height: none;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.group-detail-search {
  margin-bottom: 8px;
}

.impulse-filter-grid {
  margin-bottom: 10px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.util-grid {
  margin-top: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mode-btn {
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  padding: 8px 0;
  font-weight: 700;
}

.mode-btn.is-active {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(120deg, var(--primary), #4fc8ff);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 700;
}

.check-grid {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.map-bg-config {
  margin-top: 10px;
}

.color-row {
  justify-content: space-between;
}

.check input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.check input[type="color"] {
  width: 42px;
  height: 30px;
  padding: 1px;
  border-radius: 8px;
}

.date-filter {
  margin: 10px 0 0;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 8px;
  display: grid;
  gap: 8px;
}

.date-filter legend {
  padding: 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.visit-scope {
  margin: 0;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 8px;
  display: grid;
  gap: 6px;
}

.visit-scope legend {
  padding: 0 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.map-card {
  position: relative;
  padding-bottom: 10px;
}

#map {
  width: 100%;
  min-height: 44dvh;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  overflow: hidden;
}

#map.map-export-clean .leaflet-control-container,
#map.map-export-clean .leaflet-popup-pane {
  display: none !important;
}

body.map-fullscreen-active {
  overflow: hidden;
}

#mapWrap.is-fullscreen {
  position: fixed;
  z-index: 2200;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100vw, 860px);
  height: 100dvh;
  margin: 0;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  border-radius: 0;
}

#mapWrap.is-fullscreen #map {
  min-height: calc(100dvh - 80px);
  border-radius: 12px;
}

.map-export-tools {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 14px;
  z-index: 2300;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 22px rgba(16, 35, 52, 0.2);
}

.map-export-tools label {
  font-size: 0.74rem;
  gap: 4px;
}

.map-exit-fullscreen {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: 14px;
  z-index: 2300;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(16, 35, 52, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #0d2234;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(16, 35, 52, 0.2);
}

.map-exit-fullscreen:active {
  transform: scale(0.97);
}

#map .leaflet-tile-pane {
  opacity: 1;
  transition: opacity 0.2s ease;
}

#map.map-basemap-hidden .leaflet-tile-pane {
  opacity: 0;
}

.list {
  display: grid;
  gap: 8px;
}

.list-item {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  padding: 10px;
}

.list-item strong {
  display: block;
}

.group-item {
  padding: 12px;
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.group-title {
  font-size: 1rem;
  line-height: 1.2;
}

.group-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.group-color-chip {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(16, 35, 52, 0.28);
  box-shadow: 0 2px 8px rgba(16, 35, 52, 0.16);
}

.group-meta {
  margin-top: 8px;
  font-size: 0.82rem;
  line-height: 1.35;
}

.group-desc {
  margin-top: 8px;
  color: #31495f;
  line-height: 1.3;
  font-size: 0.88rem;
}

.group-icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(16, 35, 52, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #35536e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.group-icon-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.group-icon-btn:active {
  transform: scale(0.97);
}

.group-icon-btn.is-danger {
  color: #a13b31;
  border-color: rgba(161, 59, 49, 0.26);
  background: rgba(190, 60, 47, 0.08);
}

.group-color-row {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.template-images-block {
  margin-top: 10px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.86);
}

.template-status-panel {
  margin-top: 6px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.88);
}

.template-status-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.template-status-toast {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.template-status-toast.is-draft {
  background: rgba(21, 134, 86, 0.16);
  color: #0f7048;
  border-color: rgba(21, 134, 86, 0.28);
}

.template-status-toast.is-validation {
  background: rgba(224, 133, 30, 0.2);
  color: #9b5e10;
  border-color: rgba(224, 133, 30, 0.34);
}

.template-status-toast.is-published {
  background: rgba(186, 52, 52, 0.16);
  color: #9b2424;
  border-color: rgba(186, 52, 52, 0.34);
}

.template-status-toast.is-archived {
  background: rgba(16, 35, 52, 0.12);
  color: #4a647a;
  border-color: rgba(16, 35, 52, 0.2);
}

.template-status-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

#templateImagesInput {
  display: none;
}

.template-image-list {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

.template-image-item {
  border: 1px solid rgba(16, 35, 52, 0.16);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
}

.template-image-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: #e7edf5;
}

.template-image-remove {
  width: 100%;
  border: none;
  border-top: 1px solid rgba(16, 35, 52, 0.1);
  background: rgba(190, 60, 47, 0.08);
  color: #a13b31;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 6px;
  cursor: pointer;
}

.template-image-remove:active {
  background: rgba(190, 60, 47, 0.16);
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}

.copy-groups {
  margin: 0 0 10px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  padding: 8px;
}

.copy-groups-list {
  margin-top: 6px;
  display: grid;
  gap: 6px;
}

.color-value {
  margin-top: -2px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Menlo", "Consolas", monospace;
  font-size: 0.78rem;
}

.color-value::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(16, 35, 52, 0.24);
  background: var(--swatch-color, #14a5ff);
}

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

.actions-capture {
  grid-template-columns: 1fr;
}

.actions-capture .btn {
  width: 100%;
}

.list-item-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.list-item-actions .btn {
  flex: 1;
  min-width: 120px;
}

.group-place-actions {
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
}

.group-place-actions-left,
.group-place-actions-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.group-place-actions-right {
  margin-left: auto;
}

.visit-edit-icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(16, 35, 52, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #35536e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.visit-edit-icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 3200;
  width: min(calc(100vw - 24px), 520px);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(16, 35, 52, 0.2);
  background: rgba(16, 35, 52, 0.92);
  color: #f8fbff;
  box-shadow: 0 14px 28px rgba(16, 35, 52, 0.28);
  font-size: 0.9rem;
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 3300;
  background: rgba(9, 19, 29, 0.42);
  padding: 16px;
  display: grid;
  align-items: center;
}

.modal.modal-passive {
  pointer-events: none;
}

.modal-card {
  width: min(100%, 520px);
  margin: 0 auto;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  padding: 14px;
}

.modal-card h3 {
  margin: 0 0 10px;
}

.members-modal-card {
  width: min(100%, 900px);
  height: min(100dvh - 24px, 860px);
  display: flex;
  flex-direction: column;
}

.admin-users-modal-card {
  width: min(100%, 980px);
  height: min(100dvh - 24px, 900px);
}

.admin-user-create-form {
  margin-bottom: 10px;
}

.impulse-template-modal-card {
  width: min(100%, 980px);
  height: min(100dvh - 24px, 900px);
}

.impulse-template-head {
  margin-bottom: 10px;
  display: grid;
  gap: 6px;
}

.impulse-template-description {
  margin: 0;
  line-height: 1.35;
  color: #29435a;
}

.impulse-carousel {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.impulse-carousel-image-btn {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: rgba(245, 250, 255, 0.88);
  padding: 0;
  width: 100%;
  min-height: 220px;
  max-height: 320px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.impulse-carousel-image-btn:disabled {
  cursor: default;
}

#impulseTemplateImage {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.impulse-image-counter {
  margin-top: 8px;
}

.impulse-template-actions {
  margin-top: 4px;
  margin-bottom: 10px;
}

.impulse-template-actions .btn {
  width: 100%;
}

.impulse-import-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.impulse-import-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.impulse-template-item .btn {
  margin-top: 8px;
}

.impulse-template-item-actions {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.impulse-template-item-actions .btn {
  margin-top: 0;
  flex: 1;
}

.impulse-zoom-modal-card {
  width: min(100%, 920px);
}

.impulse-zoom-stage {
  margin-top: 4px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: rgba(245, 250, 255, 0.9);
  min-height: 48dvh;
  max-height: 66dvh;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

#impulseZoomImage {
  max-width: 100%;
  max-height: 100%;
  transform-origin: center center;
  transition: transform 0.16s ease;
}

.impulse-zoom-controls {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.template-llm-modal-card {
  width: min(100%, 860px);
  height: min(100dvh - 24px, 860px);
  display: flex;
  flex-direction: column;
  position: relative;
}

.template-llm-modal-card .groups-head {
  margin-bottom: 8px;
}

.template-llm-modal-card .form {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.template-llm-modal-card textarea {
  resize: vertical;
}

.template-llm-prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
}

.template-llm-prompt-head span {
  font-size: 0.84rem;
  font-weight: 700;
}

.llm-loading-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.84);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.llm-loading-dialog {
  min-width: 220px;
  max-width: min(100%, 360px);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  padding: 14px;
  display: grid;
  justify-items: center;
  gap: 10px;
  box-shadow: 0 12px 28px rgba(16, 35, 52, 0.18);
}

.llm-loading-dialog p {
  margin: 0;
  font-size: 0.9rem;
  color: #264158;
  text-align: center;
}

.llm-loading-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(19, 141, 255, 0.2);
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: llm-spin 0.9s linear infinite;
}

@keyframes llm-spin {
  to {
    transform: rotate(360deg);
  }
}

.members-modal-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.dialog-card {
  width: min(100%, 460px);
  padding: 16px;
  border-radius: 16px;
}

.dialog-message {
  margin: 4px 0 0;
  color: #2c445a;
  line-height: 1.35;
}

.dialog-actions {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.dialog-actions .btn {
  width: 100%;
}

.memory-link-btn {
  border: none;
  background: transparent;
  color: #0b5a8f;
  font-weight: 700;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
}

.popup-memory-wrap {
  margin-top: 6px;
  border-top: 1px solid rgba(16, 35, 52, 0.12);
  padding-top: 6px;
}

.popup-memory-item {
  margin-bottom: 6px;
}

.popup-memory-meta {
  font-size: 0.72rem;
  color: #4d6479;
}

.popup-memory-text {
  font-size: 0.78rem;
  color: #1f3548;
  line-height: 1.25;
}

.popup-memory-more {
  border: none;
  background: transparent;
  color: #0b5a8f;
  font-weight: 700;
  cursor: pointer;
  padding: 0 0 0 4px;
}

.popup-memory-actions {
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.popup-memory-add-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(19, 141, 255, 0.28);
  background: linear-gradient(135deg, rgba(19, 141, 255, 0.16), rgba(79, 200, 255, 0.3));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  color: #0b5a8f;
  font-size: 1.2rem;
  line-height: 1;
  font-weight: 700;
}

.popup-memory-add-btn:active {
  transform: scale(0.97);
}

.memory-image-picker {
  display: grid;
  gap: 8px;
}

#memoryImageInput {
  display: none;
}

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

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

.memory-entry-actions .btn {
  flex: 1;
  min-width: 140px;
}

.memory-image-preview {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid rgba(16, 35, 52, 0.18);
  background: #e7edf5;
}

.memory-list-item {
  padding: 12px;
}

.memory-item-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
  align-items: stretch;
}

.memory-item-body {
  min-width: 0;
}

.memory-item-head {
  display: block;
}

.memory-item-date {
  margin: 2px 0 0;
}

.memory-item-text {
  margin: 6px 0 0;
  line-height: 1.32;
  word-break: break-word;
}

.memory-item-media {
  width: 92px;
  border: 1px solid rgba(16, 35, 52, 0.18);
  border-radius: 10px;
  background: #e7edf5;
  overflow: hidden;
}

.memory-item-media.is-clickable {
  padding: 0;
  cursor: pointer;
}

.memory-item-thumbnail {
  width: 100%;
  height: 100%;
  min-height: 86px;
  max-height: 120px;
  object-fit: cover;
  display: block;
}

.memory-item-thumbnail.is-fallback {
  object-fit: contain;
  background: #eef4fb;
}

.memory-item-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.memory-image-modal-card {
  width: min(100%, 680px);
}

.chat-modal-card {
  width: min(100%, 920px);
}

.chat-body {
  display: grid;
  gap: 10px;
}

.chat-entry-item {
  padding: 10px;
}

.chat-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-item-head-text {
  min-width: 0;
}

.chat-item-head-text strong {
  font-size: 0.9rem;
}

.chat-item-head-text .muted {
  margin: 0;
  font-size: 0.74rem;
}

.chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(16, 35, 52, 0.2);
  background: #e7edf5;
  flex: 0 0 auto;
}

.chat-avatar.is-comment {
  width: 28px;
  height: 28px;
}

.chat-item-text {
  margin: 8px 0 0;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-item-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-like-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-like-btn {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(16, 35, 52, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #4f6479;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.chat-like-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.chat-like-btn.is-liked {
  color: #0b7fbe;
  border-color: rgba(11, 127, 190, 0.35);
  background: rgba(79, 200, 255, 0.16);
}

.chat-like-btn:active {
  transform: scale(0.97);
}

.chat-like-count {
  min-width: 14px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #4d6479;
}

.chat-reply-form {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.chat-comment-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  margin-left: 26px;
  padding-left: 10px;
  border-left: 2px solid rgba(19, 141, 255, 0.18);
}

.chat-comment-item {
  position: relative;
  border: 1px solid rgba(16, 35, 52, 0.12);
  border-radius: 10px;
  background: rgba(239, 247, 255, 0.82);
  padding: 8px;
}

.chat-comment-item::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 14px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: 2px solid rgba(19, 141, 255, 0.46);
  background: #fff;
}

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

.memory-image-large {
  width: 100%;
  max-height: 72dvh;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid rgba(16, 35, 52, 0.18);
  background: #e7edf5;
}

.import-table-wrap {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.8);
}

.import-table {
  width: 100%;
  border-collapse: collapse;
}

.import-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-size: 0.78rem;
  color: var(--muted);
  background: rgba(245, 250, 255, 0.98);
  border-bottom: 1px solid var(--stroke);
  padding: 8px 10px;
}

.import-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(16, 35, 52, 0.09);
  font-size: 0.84rem;
  vertical-align: middle;
}

.import-table tbody tr:last-child td {
  border-bottom: none;
}

.import-select-col {
  width: 70px;
}

.address-line {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.stats-grid {
  margin: 10px 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-box {
  text-align: center;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.92);
  padding: 10px;
}

.stat-box span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.stat-box strong {
  font-size: 1.3rem;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  background: rgba(255, 255, 255, 0.86);
  border-top: 1px solid var(--stroke);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  backdrop-filter: blur(8px);
  z-index: 1000;
}

.nav-btn {
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  padding: 9px 10px;
  font-weight: 700;
}

.nav-btn.is-active {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(120deg, var(--accent), #33c58f);
}

.nav-btn:disabled,
.nav-btn.is-disabled {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(0.3);
}

.quick-add-nav-btn {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border: none;
  border-radius: 999px;
  background: linear-gradient(130deg, #ff7a1a, #ff5f2f);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 20px rgba(255, 95, 47, 0.36);
  cursor: pointer;
}

.quick-add-nav-btn:active {
  transform: scale(0.96);
}

.app-msg {
  margin: 2px 2px 4px;
  min-height: 1rem;
  font-size: 0.87rem;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

@media (min-width: 920px) {
  .auth-screen,
  .mobile-app {
    padding: 20px;
  }

  .auth-screen {
    grid-template-columns: 1.2fr 1fr;
    align-items: center;
  }

  .bottom-nav {
    position: static;
    padding: 0;
    background: transparent;
    border: none;
    backdrop-filter: none;
  }

  .content {
    padding-bottom: 0;
  }

  #map {
    min-height: 56dvh;
  }

  .actions-capture {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
