/* 轨迹记录仪 - 新中式 · 精致简约 */

:root {
  --bg: #e8e4db;
  --bg-paper: #efebe2;
  --bg-card: #faf9f6;
  --text: #0d0d0d;
  --text-muted: #4a4540;
  --accent: #5c4508;
  --accent-light: #dfd6c4;
  --danger: #8a2a2a;
  --danger-light: #f0e2e2;
  --success: #3d5a3d;
  --border: #9a8f80;
  --border-light: #b5a99a;
  --radius: 6px;
  --radius-sm: 4px;
  --font-serif: 'Lora', Georgia, serif;
  --font-sans: 'Inter', -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 100% 80% at 50% 0%, rgba(139, 105, 20, 0.04) 0%, transparent 60%);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.5rem 2.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  text-align: left;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.logo {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  color: var(--text);
  margin: 0;
}

.tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
  letter-spacing: 0.2em;
  font-weight: 400;
}

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.control-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.control-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
  padding: 0.25rem 0.6rem;
  background: var(--bg-paper);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  letter-spacing: 0.05em;
}

.btn {
  padding: 0.5rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
  background: var(--bg-card);
  color: var(--text);
}

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

.btn:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-primary {
  background: var(--text);
  color: var(--bg-card);
  border-color: var(--text);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-card);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: var(--bg-card);
  border-color: var(--danger);
  animation: pulse 1.5s infinite;
}

.btn-danger:hover:not(:disabled) {
  opacity: 0.9;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.92; }
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
}

.btn-outline:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-icon {
  font-size: 0.9em;
  opacity: 0.9;
}

.hidden {
  display: none !important;
}

/* Status bar */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.875rem;
  padding: 0.6rem 1rem;
  background: var(--bg-paper);
  border-radius: var(--radius);
  font-size: 0.8rem;
  border: 1px solid var(--border-light);
}

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

.status-text.recording {
  color: var(--success);
  font-weight: 500;
}

.coords {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.2rem 0.5rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
}

/* 定位信号强度 */
.signal-strength {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 1rem;
}

.signal-strength .bar {
  width: 3px;
  min-height: 2px;
  border-radius: 1px;
  background: var(--border);
  transition: background 0.2s;
}

.signal-strength .bar.active {
  background: var(--accent);
}

.signal-strength .bar:nth-child(1) { height: 4px; }
.signal-strength .bar:nth-child(2) { height: 6px; }
.signal-strength .bar:nth-child(3) { height: 8px; }
.signal-strength .bar:nth-child(4) { height: 10px; }
.signal-strength .bar:nth-child(5) { height: 12px; }

.signal-strength.weak .bar.active {
  background: #b8860b;
}

.signal-strength.poor .bar.active {
  background: var(--danger);
}

/* Content grid */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 1rem;
  flex: 1;
  min-height: 320px;
}

@media (max-width: 768px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}

/* Map */
.map-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  isolation: isolate;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 300px;
}

/* Leaflet 图层切换 - 新中式 */
.leaflet-top.leaflet-right {
  z-index: 1001;
}

.leaflet-control-layers {
  background: var(--bg-paper) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  pointer-events: auto !important;
}

.leaflet-control-layers-expanded {
  padding: 0.4rem 0.6rem !important;
  width: auto;
  min-width: 0;
}

.leaflet-control-layers label {
  color: var(--text) !important;
  font-size: 0.75rem !important;
  font-family: var(--font-sans) !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  margin-bottom: 0.15rem !important;
  white-space: nowrap;
}

.leaflet-control-layers label:last-child {
  margin-bottom: 0 !important;
}

.leaflet-control-layers-selector {
  margin-right: 0.35rem !important;
  flex-shrink: 0;
}

/* 北向指示 */
.north-arrow {
  background: var(--bg-paper) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  font-family: var(--font-serif) !important;
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--accent);
  padding: 0.25rem 0.45rem !important;
  line-height: 1.2;
}

/* Sidebar */
.sidebar {
  background: var(--bg-paper);
  border-radius: var(--radius);
  padding: 1rem;
  border: 1px solid var(--border-light);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.sidebar-title {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-weight: 500;
  margin: 0;
  color: var(--text);
  letter-spacing: 0.1em;
}

.btn-icon-small {
  padding: 0.2rem 0.4rem;
  font-size: 0.85rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
}

.btn-icon-small:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.stats-panel {
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stats-panel .stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.stats-panel .stat-row:last-child {
  margin-bottom: 0;
}

.stats-panel .stat-value {
  color: var(--text);
  font-weight: 500;
}

.record-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.record-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.45rem 0.55rem;
  margin-bottom: 0.3rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  border: 1px solid var(--border-light);
  transition: all 0.15s ease;
  cursor: pointer;
}

.record-item:hover {
  border-color: var(--border);
}

.record-item.highlighted {
  border-color: var(--accent);
  background: var(--accent-light);
}

.record-item .record-actions {
  display: flex;
  gap: 0.2rem;
  align-items: center;
}

.record-item .record-action-btn {
  padding: 0.15rem 0.3rem;
  font-size: 0.65rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  color: var(--text-muted);
}

.record-item .record-action-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.record-item .record-delete {
  padding: 0.15rem 0.3rem;
  font-size: 0.65rem;
}

.record-item .record-action-btn.export-btn:hover {
  color: var(--success);
  border-color: var(--success);
}

/* 底部容器：功能特点 + 使用说明 */
.info-container {
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-paper);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 640px) {
  .info-container {
    grid-template-columns: 1fr;
  }
}

/* 可折叠区块 details/summary */
.info-section {
  padding: 0;
}

.info-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-weight: 500;
  margin: 0;
  padding: 0.2rem 0;
  color: var(--text);
  letter-spacing: 0.08em;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
  list-style: none;
}

.info-section summary::-webkit-details-marker,
.info-section summary::marker {
  display: none;
}

.info-section summary::after {
  content: '▼';
  font-size: 0.65rem;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.info-section:not([open]) summary::after {
  transform: rotate(-90deg);
}

.info-section summary:hover {
  color: var(--accent);
}

.info-section > *:not(summary) {
  margin-top: 0.5rem;
}

.feature-highlights {
  padding: 0;
}

.feature-highlights .section-title {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-weight: 500;
  margin: 0 0 0;
  color: var(--text);
  letter-spacing: 0.08em;
}

.feature-highlights ul {
  margin: 0;
  padding: 0 0 0 1.1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.feature-highlights li {
  margin-bottom: 0.2rem;
}

.feature-highlights strong {
  color: var(--text);
  font-weight: 500;
}

.feature-highlights a,
.usage-content a {
  color: var(--accent);
  text-decoration: none;
}

.feature-highlights a:hover,
.usage-content a:hover {
  text-decoration: underline;
}

.notes-section {
  grid-column: 1 / -1;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-light);
}

.notes-section .section-title {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-weight: 500;
  margin: 0 0 0.4rem;
  color: var(--text);
  letter-spacing: 0.08em;
}

.notes-section p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--accent);
  line-height: 1.6;
}

/* 使用说明 */
.usage-guide {
  padding: 0;
}

.usage-guide .section-title {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-weight: 500;
  margin: 0 0 0.5rem;
  color: var(--text);
  letter-spacing: 0.08em;
}

.usage-content {
  padding: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.usage-content p {
  margin: 0 0 0.4rem;
}

.usage-content p:last-child {
  margin-bottom: 0;
}

.usage-content strong {
  color: var(--text);
  font-weight: 500;
}

.usage-tip {
  margin-top: 0.5rem !important;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border-light);
  font-size: 0.75rem;
  color: var(--accent);
}

.record-item .record-info {
  flex: 1;
  min-width: 0;
}

.record-item .record-label {
  font-weight: 500;
  color: var(--text);
}

/* 文字加粗适度减弱 */
.legal-content strong {
  font-weight: 500;
}

.record-item .record-detail {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.record-item .record-delete {
  padding: 0.2rem 0.35rem;
  font-size: 0.7rem;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.record-item .record-delete:hover {
  background: var(--danger-light);
  color: var(--danger);
}

/* Legal / compliance pages */
.logo-link {
  text-decoration: none;
  color: inherit;
}

.logo-link:hover .logo {
  color: var(--accent);
}

.legal-main {
  flex: 1;
  padding: 0 0 2rem;
}

.legal-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 0;
}

.legal-content h1 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 500;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.legal-content .legal-updated {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 1.5rem;
}

.legal-content h2 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 500;
  margin: 1.5rem 0 0.5rem;
  color: var(--text);
}

.legal-content p, .legal-content ul {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin: 0 0 0.75rem;
}

.legal-content ul {
  padding-left: 1.5rem;
}

.legal-content li {
  margin-bottom: 0.35rem;
}

.legal-content a {
  color: var(--accent);
  text-decoration: none;
}

.legal-content a:hover {
  text-decoration: underline;
}

.legal-content code {
  font-size: 0.85em;
  background: var(--bg-card);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.legal-content pre {
  overflow-x: auto;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  line-height: 1.5;
}

.legal-content pre code {
  padding: 0;
  border: none;
}

.legal-footer {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legal-footer a {
  color: var(--accent);
  text-decoration: none;
}

.legal-footer a:hover {
  text-decoration: underline;
}

.legal-footer span {
  margin: 0 0.4rem;
  color: var(--border);
}

/* Footer on main page */
.main-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.main-footer a {
  color: var(--accent);
  text-decoration: none;
}

.main-footer a:hover {
  text-decoration: underline;
}

.main-footer span {
  margin: 0 0.35rem;
  color: var(--border);
}
