:root {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-light: #ccfbf1;
  --blue: #2563eb;
  --danger: #dc2626;
  --call: #16a34a;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 680px;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  flex-shrink: 0;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
}

.app-subtitle {
  font-size: 13px;
  background: rgba(255, 255, 255, 0.18);
  padding: 2px 10px;
  border-radius: 999px;
}

.app-main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #fff;
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.nav-icon {
  font-size: 18px;
  line-height: 1.1;
}

.nav-item.active {
  color: var(--primary);
}

.page-container {
  padding-bottom: 24px;
}

.sticky-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px;
}

.search-box input {
  width: 100%;
  border: none;
  outline: none;
  padding: 10px 8px;
  font-size: 15px;
  background: transparent;
}

.icon-clear {
  border: none;
  background: #e2e8f0;
  color: var(--text);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 13px;
  cursor: pointer;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.toolbar-buttons {
  display: flex;
  gap: 8px;
}

.count-badge {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--primary-light);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.selection-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.selection-actions {
  display: flex;
  gap: 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-teal {
  background: var(--primary-dark);
  color: #fff;
}

.btn-blue {
  background: var(--blue);
  color: #fff;
}

.btn-call {
  background: var(--call);
  color: #fff;
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-dark {
  background: #1e293b;
  color: #fff;
}

.btn-outline {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.btn-danger-outline {
  background: #fff;
  color: var(--danger);
  border-color: #fecaca;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

.member-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
}

.member-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
}

.member-card.selected {
  border-color: var(--primary);
  background: #f0fdfa;
}

.card-checkbox {
  font-size: 20px;
  padding-top: 4px;
}

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

.member-furigana {
  font-size: 11px;
  color: var(--muted);
}

.member-name {
  font-size: 17px;
  font-weight: 700;
}

.member-address {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.card-phones {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.phone-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: #dcfce7;
  color: #15803d;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.detail-page {
  padding: 12px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-top-actions {
  display: flex;
  gap: 8px;
}

.detail-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.detail-furigana {
  font-size: 12px;
  color: var(--muted);
}

.detail-name {
  margin: 2px 0 12px;
  font-size: 22px;
  font-weight: 800;
}

.detail-phone-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

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

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--primary-dark);
}

.detail-address-text {
  margin: 0 0 10px;
  font-size: 14px;
}

.map-action-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.embed-map-wrap {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  height: 220px;
}

.embed-map-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.info-grid {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px 12px;
  margin: 0;
  font-size: 14px;
}

.info-grid dt {
  color: var(--muted);
  font-weight: 600;
}

.info-grid dd {
  margin: 0;
}

.multiline {
  white-space: pre-wrap;
}

.record-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.record-list.padded {
  padding: 12px 14px;
}

.record-item,
.record-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.record-card {
  background: #fff;
}

.record-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.record-member-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
}

.record-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.record-time {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.record-location {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.record-text {
  margin: 4px 0 0;
  white-space: pre-wrap;
  font-size: 14px;
}

.record-audio {
  margin-top: 8px;
}

.audio-player {
  width: 100%;
  height: 36px;
}

.icon-btn-sm {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
}

/* Map Page */
.map-page {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.map-filter-group,
.map-action-btns {
  display: flex;
  gap: 6px;
  align-items: center;
}

.geo-banner {
  padding: 6px 12px;
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  font-weight: 600;
}

.geo-banner.info {
  background: #eff6ff;
  color: #1e40af;
}

.leaflet-container-box {
  flex: 1;
  min-height: 360px;
  width: 100%;
  z-index: 1;
}

.map-popup {
  min-width: 180px;
}

.map-popup-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 2px;
}

.map-popup-addr {
  font-size: 12px;
  color: #475569;
  margin-bottom: 8px;
}

.map-popup-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.popup-btn {
  display: block;
  text-align: center;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

.popup-call {
  background: #16a34a;
  color: #fff;
}

.popup-gmap {
  background: #2563eb;
  color: #fff;
}

.popup-detail {
  background: #f1f5f9;
  color: #0f172a;
}

/* Settings */
.settings-page {
  padding: 12px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-desc {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.hidden-input {
  display: none;
}

.export-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-banner {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.tips-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 16px;
  }
}

.modal-sheet {
  background: #fff;
  width: 100%;
  max-width: 600px;
  max-height: 92dvh;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 640px) {
  .modal-sheet {
    border-radius: 16px;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
}

.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.field-quick-actions {
  display: flex;
  gap: 10px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
}

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

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.recording-panel {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recording-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.recording-sub {
  font-size: 11px;
  color: var(--muted);
}

.rec-timer {
  color: var(--danger);
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
}

.interim-box {
  background: #fff;
  border: 1px dashed #fca5a5;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--muted);
}

.hint-error {
  font-size: 12px;
  color: var(--danger);
}

.hint-warn {
  font-size: 12px;
  color: #b45309;
}

.modal-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 6px;
  padding-bottom: env(safe-area-inset-bottom);
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty-state h3 {
  margin: 0 0 8px;
  color: var(--text);
}

.empty-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 280px;
  margin: 18px auto 0;
}

.text-muted {
  color: var(--muted);
}
