/* ==========================================================================
   My Places v5 — Location Notebook theme
   Keep × Maps × Notes — calm, high-contrast, all ages
   ========================================================================== */

body {
  background: var(--surface-0, #f6f5f2);
  color: var(--text-primary, #1c1b19);
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 0 calc(72px + env(safe-area-inset-bottom));
}

/* -- Header -------------------------------------------------------------- */
.app-header.mp-header {
  padding: 16px 16px 8px;
  margin-bottom: 0;
  background: var(--surface-0);
  border-bottom: none;
  box-shadow: none;
}

.mp-header__eyebrow,
.app-header .eyebrow {
  margin: 0 0 2px;
  font-size: var(--font-size-caption, 12px);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted, #8a8983);
}

.mp-header__title,
.app-header h1 {
  margin: 0;
  font-size: var(--font-size-title, 22px);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.mp-header__subtitle,
.app-header .sub {
  margin: 4px 0 0;
  font-size: var(--font-size-footnote, 13px);
  color: var(--text-secondary, #5f5e5a);
  max-width: none;
}

.header-actions.mp-toolbar {
  padding: 0 16px 12px;
  display: flex;
  gap: 8px;
}

.header-actions .btn-tab {
  flex: 1;
  min-height: var(--tap-target-min, 44px);
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--border);
  background: var(--surface-2, #fff);
  color: var(--text-primary);
  font-weight: 600;
  font-size: var(--font-size-footnote, 13px);
}

.header-actions .btn-tab.is-active {
  background: var(--brand-500, #6d4de0);
  border-color: var(--brand-500);
  color: #fff;
}

.header-actions .btn-primary#btnNew {
  flex: 0 0 auto;
  min-width: 72px;
  background: var(--brand-tint-bg, #eee9fb);
  border: 1px solid var(--brand-500);
  color: var(--brand-tint-text, #4a2fae);
  font-weight: 700;
}

/* -- Panels -------------------------------------------------------------- */
.panel {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.panel-list {
  max-height: none;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.quick-access-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 6px;
  padding: 8px 10px;
  margin: 0 0 8px;
  background: #ede9fe;
  border: none;
  border-radius: 10px;
  flex: 0 0 auto;
}
.quick-access-bar.hidden { display: none !important; }

.quick-access-chip {
  border: 1.5px solid #8b5cf6;
  background: #fff;
  color: #5b21b6;
  border-radius: 999px;
  padding: 2px 10px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
  white-space: nowrap;
}
.quick-access-chip-active {
  background: #2563eb;
  border-color: #1d4ed8;
  color: #fff;
}

.list-detail-host {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
}

.list-detail-empty {
  margin: 8px 2px 0;
  padding: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: left;
}

.list-month-divider {
  margin: 0 0 8px;
  padding: 0;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.list-detail-host > .list-month-divider:first-child {
  margin-top: 0;
}

.list-place-detail {
  margin: 0;
  padding: 10px 2px 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  cursor: pointer;
}
.list-place-detail:last-child {
  border-bottom: none;
}
.list-place-detail--active {
  background: #eef2ff;
  border-radius: 8px;
  border-bottom-color: transparent;
}
.list-place-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.list-place-detail-head strong {
  font-size: 1rem;
  color: var(--text-primary);
}
.list-place-detail-addr {
  margin: 6px 0 0;
  font-size: 0.84rem;
  color: var(--text-secondary);
}
.list-place-detail-meta,
.list-place-detail-notes,
.list-place-detail-attach {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.list-place-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.list-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  flex: 0 0 auto;
}

.list-toolbar .mp-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  min-height: var(--control-height);
  box-sizing: border-box;
}

.list-toolbar .mp-search input,
.list-toolbar .mp-search #siteSearch {
  border: none !important;
  outline: none;
  box-shadow: none !important;
  background: transparent !important;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 0 !important;
  margin: 0;
  font: inherit;
  font-size: var(--font-size-footnote);
  line-height: 1.3;
}

.list-toolbar .mp-search .mp-icon-slot {
  color: var(--text-muted);
  flex-shrink: 0;
}


.list-cat-filter {
  flex: 0 0 auto;
  min-height: var(--control-height, 40px);
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font: inherit;
  font-size: var(--font-size-footnote);
  color: var(--text-primary);
  max-width: 110px;
}

.site-list {
  padding: 0 8px 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.panel-head.panel-head-row { display: none; }

.layout {
  grid-template-columns: 1fr;
  gap: 0;
}

.panel-main,
.panel-note {
  padding: 0 16px 24px;
}

/* -- List cards extras --------------------------------------------------- */
.mp-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}

.mp-card__distance {
  font-size: var(--font-size-caption);
  color: var(--text-muted);
}

.mp-card__attach {
  display: inline-flex;
  gap: 8px;
  font-size: var(--font-size-caption);
  color: var(--text-secondary);
  align-items: center;
}

.mp-attach-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.mp-attach-badge .icon {
  color: var(--text-muted);
}

.mp-icon-slot {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  flex-shrink: 0;
}

.note-section-title .mp-icon-slot {
  margin-right: 6px;
}

.note-pin .mp-icon-slot {
  margin-right: 4px;
}

.btn-media .mp-icon-slot {
  margin-bottom: 2px;
}

.note-action-card .mp-icon-slot {
  margin-bottom: 4px;
}

.note-attach-fallback,
.place-media-thumb-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.note-attach-fallback .icon,
.place-media-thumb-fallback .icon {
  width: 32px !important;
  height: 32px !important;
}

/* -- Note detail --------------------------------------------------------- */
.note-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.note-header-main { flex: 1; min-width: 0; }

.note-pin {
  margin: 0 0 6px;
  font-size: var(--font-size-heading, 18px);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  word-break: break-word;
}

.note-pin-icon { margin-right: 4px; }

.note-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.note-address-preview {
  margin: 0;
  font-size: var(--font-size-footnote);
  color: var(--text-secondary);
}

.note-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.note-section:last-child { border-bottom: none; }

.note-section-title {
  margin: 0 0 12px;
  font-size: var(--font-size-body, 15px);
  font-weight: 600;
  color: var(--text-primary);
}

.note-section-count {
  font-weight: 400;
  color: var(--text-muted);
}

.note-fields-compact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.note-fields-compact .field-wide { grid-column: 1 / -1; }

.note-fields-advanced {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.note-fields-advanced .field span {
  font-size: var(--font-size-caption);
}

.note-fields-advanced input {
  font-size: var(--font-size-caption);
  padding: 8px;
}

.field textarea#fieldNotes {
  width: 100%;
  min-height: 88px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: var(--font-size-body);
  resize: vertical;
  background: var(--surface-2);
}

.map.map-note {
  height: 200px !important;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-top: 8px;
}

.note-media-toolbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.note-media-toolbar .btn-media {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 64px;
  padding: 8px 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--font-size-caption);
  font-weight: 600;
  color: var(--text-primary);
}

.note-media-toolbar .btn-media:disabled {
  opacity: 0.45;
}

.note-media-toolbar .btn-media-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.note-attachments-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.note-attach-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.note-attach-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.note-attach-delete .icon {
  color: #fff;
}

.note-attach-thumb {
  aspect-ratio: 4 / 3;
  background: var(--surface-1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.note-attach-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.note-attach-fallback {
  font-size: 2rem;
  opacity: 0.5;
}

.note-attach-label {
  margin: 0;
  padding: 8px 10px 2px;
  font-size: var(--font-size-footnote);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-attach-time {
  display: block;
  padding: 0 10px 8px;
  font-size: var(--font-size-caption);
  color: var(--text-muted);
}

.note-attach-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: var(--font-size-footnote);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

/* Travel templates — icon grid */
.travel-templates-label {
  display: block;
  font-size: var(--font-size-footnote);
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.travel-templates-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.btn-template {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 56px;
  padding: 10px 12px;
  text-align: left;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-primary);
  font-weight: 600;
  font-size: var(--font-size-footnote);
}

.btn-template small {
  font-weight: 400;
  color: var(--text-muted);
  font-size: var(--font-size-caption);
}

/* Actions */
.note-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.note-action-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 72px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.note-action-card strong {
  font-size: var(--font-size-body);
}

.note-action-card span {
  font-size: var(--font-size-caption);
  color: var(--text-muted);
}

.note-action-card--primary {
  background: var(--brand-tint-bg);
  border-color: var(--brand-500);
}

.note-action-card--danger {
  border-color: var(--danger-solid, #e24b4a);
  color: var(--danger-text, #791f1f);
}

.note-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.note-actions-row .btn {
  flex: 1;
  min-width: 120px;
  min-height: var(--tap-target-min);
}

.form-actions.note-form-actions {
  display: contents;
}

.form-status {
  margin-top: 8px;
}

.btn-back-note {
  flex-shrink: 0;
  min-width: var(--tap-target-min);
  min-height: var(--tap-target-min);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 1.1rem;
  cursor: pointer;
}

html:not(.native-app) .btn-back-note { display: none; }

/* Bottom nav (phone) */
.app-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
  max-width: 520px;
  margin: 0 auto;
}

html.native-app .app-bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 8px;
}

.app-bottom-nav .btn-bottom {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 48px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-size-caption);
  font-weight: 600;
  cursor: pointer;
}

.app-bottom-nav .btn-bottom.is-active {
  color: var(--brand-500);
}

.app-bottom-nav .btn-bottom-fab {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--brand-500);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 300;
  border: none;
  margin-top: -18px;
  box-shadow: var(--shadow-md);
}

/* Native layout */
html.native-app .app-header .header-actions { display: none; }
html.native-app .panel-main,
html.native-app .panel-list,
html.native-app .view-panel#viewOverview {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

/* Credit footer: fixed above bottom nav on phone APK */
html.native-app .app-credit {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(58px + env(safe-area-inset-bottom));
  z-index: 39;
  max-width: 520px;
  margin: 0 auto;
  padding: 6px 12px;
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

html.native-app .app {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

html.native-app.native-combined-layout .map.map-note {
  height: 292px !important;
  min-height: 240px;
  margin-top: 0;
}

/* Overview map */
.view-panel#viewOverview {
  padding: 0 16px;
}

.route-day-bar {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.map-overview {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

/* Legacy purple overrides toned down */
.field input,
.field select,
#siteSearch,
#filterCategory {
  border-color: var(--border);
  background: var(--surface-2);
}

.field input:focus,
.field select:focus,
#siteSearch:focus,
#filterCategory:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(109, 77, 224, 0.12);
}

.btn-primary[type="submit"],
button.btn-primary#btnNew {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: #fff;
}

.place-media-strip { display: none; }

@media (min-width: 901px) {
  .app { max-width: 960px; padding-bottom: 16px; }
  .layout {
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 16px;
    padding: 0 16px;
  }
  .panel-list { padding: 0; }
  .panel-note { padding: 0; }
  html.native-app .app-bottom-nav { display: none; }
  html.native-app .app-header .header-actions { display: flex; }
}
