:root {
  --bg: #fafafa;
  --fg: #111;
  --muted: #666;
  --border: #ddd;
  --accent: #c0392b;
  --accent-fg: #fff;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.brand {
  font-weight: 600;
  text-decoration: none;
  color: var(--fg);
}

.lang-switcher select {
  padding: 0.25rem 0.5rem;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
  align-items: center;
}

.filters input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
}

.filters input[type="search"], .filters input[type="text"] { flex: 1 1 12rem; min-width: 8rem; }
.filters input[type="number"] { width: 6rem; }

.view-toggle {
  margin-left: auto;
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.view-toggle button {
  padding: 0.4rem 0.8rem;
  background: #fff;
  border: 0;
  cursor: pointer;
  font: inherit;
}

.view-toggle button.active {
  background: var(--fg);
  color: #fff;
}

.view {
  flex: 1;
  min-height: 0;
  display: none;
  position: relative;
}

.view.active { display: flex; flex-direction: column; }

#map { flex: 1; min-height: 60vh; }

#list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}

#list li {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

#list .meta {
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

#list audio { width: 100%; margin-top: 0.5rem; }

#list-loading, #list-empty {
  text-align: center;
  color: var(--muted);
  padding: 1rem;
}

.rec-button {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  z-index: 1000;
}

.rec-button.recording { animation: pulse 1.2s ease-in-out infinite; }
.rec-button .rec-dot { width: 0.7rem; height: 0.7rem; background: #fff; border-radius: 50%; }
.rec-button .rec-label { font-size: 0.75rem; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); box-shadow: 0 4px 18px rgba(192,57,43,0.6); }
}

dialog#publish-dialog {
  border: 0;
  border-radius: 8px;
  padding: 1.25rem;
  max-width: 28rem;
  width: 100%;
}

dialog#publish-dialog::backdrop { background: rgba(0,0,0,0.4); }

#publish-form { display: flex; flex-direction: column; gap: 0.6rem; }
#publish-form h2 { margin: 0 0 0.25rem; }
#publish-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
#publish-form input, #publish-form textarea { padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: 4px; font: inherit; }
#publish-form .coords { display: flex; gap: 1rem; color: var(--muted); margin: 0; font-size: 0.85rem; }
#publish-form .hint { color: var(--muted); font-size: 0.8rem; margin: 0; }
#publish-form menu { display: flex; gap: 0.5rem; justify-content: flex-end; padding: 0; margin: 0.5rem 0 0; }
#publish-form button { padding: 0.5rem 1rem; border: 1px solid var(--border); border-radius: 4px; background: #fff; cursor: pointer; font: inherit; }
#publish-form #publish-submit { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

.toast {
  position: fixed;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
  z-index: 1100;
}

.popup-content { font-size: 0.9rem; min-width: 12rem; }
.popup-content h3 { margin: 0 0 0.25rem; font-size: 1rem; }
.popup-content .tags { margin: 0.25rem 0; }
.popup-content .tag { display: inline-block; background: #eee; padding: 0.05rem 0.4rem; border-radius: 999px; font-size: 0.75rem; margin-right: 0.25rem; }
.popup-content audio { width: 100%; margin: 0.4rem 0; }
.popup-content .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; font-size: 0.8rem; }
.popup-content .actions button, .popup-content .actions a { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

@media (max-width: 600px) {
  .filters { gap: 0.4rem; }
  .filters input[type="number"] { width: 5rem; }
  .rec-button { width: 3.4rem; height: 3.4rem; bottom: 1rem; right: 1rem; }
}
