:root {
  --bg: #f4f7fa;
  --bg-card: #ffffff;
  --text: #0b1f2a;
  --text-muted: #5b6b78;
  --primary: #0b3954;
  --accent: #1aa3ff;
  --high: #d62828;
  --low: #2a9d8f;
  --border: #e1e8ee;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
  --tab-h: 64px;
  --top-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1620;
    --bg-card: #14222e;
    --text: #e8eef3;
    --text-muted: #9bb0bf;
    --primary: #1aa3ff;
    --border: #25394a;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  padding-top: calc(var(--top-h) + var(--safe-top));
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom));
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--top-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--primary);
  color: #fff;
  z-index: 10;
  display: flex;
  align-items: center;
}

.topbar-inner {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
}

.topbar h1 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
}

.topbar h1 span {
  font-weight: 400;
  opacity: 0.85;
}

.badge {
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 8px;
  border-radius: 999px;
}

.view {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 720px;
  margin: 0 auto;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border: 1px solid var(--border);
}

.card h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.now {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.now-h {
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--primary);
}

.now-unit {
  font-size: 1rem;
  color: var(--text-muted);
}

.next-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.next-cell {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.next-cell .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.next-cell.high .label {
  color: var(--high);
}

.next-cell.low .label {
  color: var(--low);
}

.next-cell .time {
  font-size: 1.4rem;
  font-weight: 600;
  margin-top: 4px;
}

.next-cell .h {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.coef {
  display: flex;
  align-items: center;
  gap: 16px;
}

.coef-num {
  font-size: 2.2rem;
  font-weight: 700;
}

.coef-class {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 240px;
}

.tide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.tide-table th, .tide-table td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.tide-table th {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}

.tide-table td.h-up { color: var(--high); font-weight: 600; }
.tide-table td.h-down { color: var(--low); font-weight: 600; }

.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 10;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 4px;
}

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

.tab-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.tab-label {
  font-size: 0.72rem;
  font-weight: 500;
}

.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 24px 0;
}

.error {
  background: #fdecea;
  color: #b3261e;
  border-radius: 8px;
  padding: 12px;
  font-size: 0.9rem;
}

@media (prefers-color-scheme: dark) {
  .error { background: #3b1c1a; color: #ff8a80; }
}

.astro-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.astro-cell .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.astro-cell .value {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 2px;
}

.subtle {
  font-size: 0.85rem;
  color: var(--text-muted);
}
