:root {
  --sea-900: #08324a;
  --sea-700: #0b5578;
  --sea-600: #0f6a99;
  --sea-500: #1b87bd;
  --sea-200: #bfe3f4;
  --sea-100: #e3f3fb;
  --sea-50: #f4fafd;
  /* 地図のマーキング色（画面B）。満潮・干潮の色は --tide-high / --tide-low を使う */
  --low: #c2570a;
  --text: #12303f;
  --muted: #4d6b7a;
  --line: #cfe4ef;
  --line-soft: #e2eef6;
  --tide-high: #c2185b;
  --tide-low: #1a64a8;
  --white: #fff;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(8, 50, 74, 0.08), 0 4px 12px rgba(8, 50, 74, 0.06);
}

* {
  box-sizing: border-box;
}

/* .btn などの display 指定が [hidden] を打ち消さないようにする */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--sea-50);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Hiragino Sans",
    "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

a {
  color: var(--sea-600);
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  background: var(--sea-50);
}

#main {
  flex: 1 0 auto;
  padding: 14px 12px 20px;
}

.view[hidden] {
  display: none;
}

/* ---------------------------------------------------------------- 見出し */

.view-head {
  padding: 4px 2px 12px;
}

.view-head-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
}

.app-title {
  margin: 0;
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: 0.02em;
  color: var(--sea-900);
}

.app-sub {
  margin: 4px 0 0;
  font-size: 16px;
  color: var(--muted);
}

.view-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
  color: var(--sea-900);
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- ボタン */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(15, 106, 153, 0.15);
}

.btn[disabled] {
  opacity: 0.5;
  cursor: default;
}

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

.btn-secondary {
  background: #fff;
  border-color: var(--sea-600);
  color: var(--sea-700);
}

.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--sea-700);
  min-height: 44px;
  padding: 6px 14px;
  font-size: 16px;
}

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

.btn-danger-armed {
  background: #fdecea;
  border-color: var(--danger);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-back {
  flex: 0 0 auto;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn-row .btn {
  flex: 1 1 0;
  min-width: 0;
}

/* ---------------------------------------------------------------- 画面A */

.place-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.place-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.place-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.place-name {
  margin: 0;
  font-size: 19px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.place-link {
  color: var(--sea-900);
  text-decoration: none;
  display: inline-block;
  padding: 2px 0;
  min-height: 32px;
}

.place-region {
  margin: 4px 0 10px;
  font-size: 16px;
  color: var(--muted);
}

.card-summary {
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  margin: 0 0 12px;
}

.card-loading,
.card-summary-muted,
.card-summary-error {
  margin: 0;
  font-size: 16px;
  color: var(--muted);
}

.card-summary-error {
  color: var(--danger);
}

/* --- 今日の潮汐（一覧カード） ------------------------------------- */

/* 1. 次の潮の強調 */
.next-tide {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--sea-100);
  border-radius: 12px;
  background: var(--sea-50);
}

.next-tide-icon {
  flex: 0 0 auto;
  display: block;
  width: 28px;
  height: 28px;
}

.next-tide-body {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 5px;
  min-width: 0;
}

.next-tide-label {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.next-tide-time {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.next-tide-level {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.next-tide-level small,
.today-level small {
  margin-left: 1px;
  font-size: 13px;
  font-weight: 700;
}

.next-tide-in {
  margin-left: auto;
  font-size: 16px;
  color: var(--muted);
  white-space: nowrap;
}

/* 2. 今日の潮汐のリスト（満潮・干潮で体裁は同じ、色だけ違う） */
.today-title {
  margin: 12px 0 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--sea-900);
}

.today-list {
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line-soft);
}

.today-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 16px;
  line-height: 1.4;
}

.today-icon {
  flex: 0 0 auto;
  display: block;
  width: 22px;
  height: 22px;
}

.today-label {
  flex: 0 0 3.1em;
  font-weight: 700;
}

.today-time {
  flex: 0 0 4.3em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.today-level {
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.next-tide.is-high .next-tide-icon,
.next-tide.is-high .next-tide-label,
.next-tide.is-high .next-tide-level,
.today-row.is-high .today-icon,
.today-row.is-high .today-label,
.today-row.is-high .today-level {
  color: var(--tide-high);
}

.next-tide.is-low .next-tide-icon,
.next-tide.is-low .next-tide-label,
.next-tide.is-low .next-tide-level,
.today-row.is-low .today-icon,
.today-row.is-low .today-label,
.today-row.is-low .today-level {
  color: var(--tide-low);
}

/* 3. 24時間タイドグラフ */
.tide-graph {
  margin: 10px 0 0;
}

.tide-graph-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.tide-graph-note {
  margin: 10px 0 0;
  padding: 16px 12px;
  border: 1px dashed var(--sea-200);
  border-radius: 10px;
  font-size: 16px;
  color: var(--muted);
  text-align: center;
}

.btn-weekly {
  width: 100%;
}

.empty {
  margin: 8px 0 16px;
  padding: 22px 16px;
  background: #fff;
  border: 1px dashed var(--sea-200);
  border-radius: var(--radius);
  font-size: 16px;
  color: var(--muted);
  text-align: center;
}

.btn-add {
  margin-top: 16px;
}

.badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-caution {
  background: #fff4d6;
  color: #7a5200;
  border: 1px solid #f0d089;
}

.badge-reference,
.badge-unsupported {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #e4b4b1;
}

/* ---------------------------------------------------------------- 画面B */

.map-wrap {
  position: relative;
}

.map {
  height: 48vh;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--sea-100);
}

.map-failed {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  font-size: 16px;
  color: var(--muted);
  text-align: center;
}

.map-status {
  margin: 8px 2px 0;
  font-size: 16px;
  color: var(--muted);
}

.map-panel {
  margin-top: 12px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.coord {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--sea-900);
}

.nearest {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--text);
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--sea-900);
}

.field-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--sea-200);
  border-radius: 10px;
  font-family: inherit;
  font-size: 17px;
  color: var(--text);
  background: #fff;
}

.field-input:focus {
  outline: 3px solid var(--sea-200);
  outline-offset: 1px;
}

.field-input.has-error {
  border-color: var(--danger);
}

.field-hint {
  margin: 8px 0 0;
  font-size: 16px;
  color: var(--muted);
}

.field-hint-caution {
  color: #7a5200;
}

.field-hint-reference,
.field-hint-unsupported {
  color: var(--danger);
  font-weight: 700;
}

#locate {
  margin-top: 12px;
}

.map-pin {
  background: none;
  border: none;
}

.map-pin-dot {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--sea-600);
  border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
}

.map-pin-active .map-pin-dot {
  background: var(--low);
}

.map-pin-pending .map-pin-dot {
  background: var(--low);
  box-shadow:
    0 0 0 6px rgba(194, 87, 10, 0.22),
    0 1px 6px rgba(0, 0, 0, 0.45);
}

/* ---------------------------------------------------------------- 画面C */

.tide-meta {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.meta-row {
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 16px;
  line-height: 1.5;
}

.meta-row:first-child {
  padding-top: 0;
}

.meta-row:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.meta-key {
  display: block;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.4;
}

.meta-value {
  display: block;
  overflow-wrap: anywhere;
}

.tide-table {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 16px;
}

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

.tide-table thead th {
  padding: 8px 6px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  border-bottom: none;
}

.tide-table thead th.col-date {
  background: var(--sea-700);
}

.tide-table thead th.col-high {
  background: var(--tide-high);
}

.tide-table thead th.col-low {
  background: var(--tide-low);
}

.tide-table tbody tr:last-child th,
.tide-table tbody tr:last-child td {
  border-bottom: none;
}

.col-date {
  width: 25%;
}

.col-high,
.col-low {
  width: 37.5%;
}

.date-md {
  display: block;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--sea-900);
}

.date-w {
  display: block;
  font-size: 16px;
  line-height: 1.3;
  color: var(--muted);
}

.date-today {
  display: inline-block;
  margin-top: 2px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--sea-100);
  color: var(--sea-700);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}

.is-today-row td {
  background: #f2fafd;
}

.ev {
  display: flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
  line-height: 1.5;
}

.col-high .ev-t {
  color: var(--tide-high);
  font-weight: 700;
}

.col-low .ev-t {
  color: var(--tide-low);
  font-weight: 700;
}

.ev-v {
  font-weight: 700;
}

.ev-v small {
  font-size: 16px;
  font-weight: 400;
}

.ev-empty {
  color: var(--muted);
}

.cell-missing {
  color: var(--muted);
  font-size: 16px;
}

.tide-notes {
  margin-top: 14px;
  font-size: 16px;
  color: var(--muted);
}

.tide-notes p {
  margin: 0 0 6px;
}

/* ---------------------------------------------------------------- 注意・状態 */

.note {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 16px;
  line-height: 1.5;
}

.note-small {
  color: var(--muted);
  background: transparent;
  padding: 10px 2px;
  margin: 8px 0 0;
}

.note-loading {
  background: var(--sea-100);
  color: var(--sea-900);
}

.note-error {
  background: #fdecea;
  border: 1px solid #e4b4b1;
  color: var(--danger);
}

.note-info {
  background: #eef7fd;
  border: 1px solid var(--sea-200);
  color: var(--sea-900);
}

.notice {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 16px;
}

.notice-info {
  background: #eef7fd;
  border: 1px solid var(--sea-200);
}

.notice-warn {
  background: #fff6e6;
  border: 1px solid #f0d089;
}

.notice p {
  margin: 0 0 6px;
}

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

.notice-title {
  font-weight: 700;
  font-size: 17px;
}

.notice-sub {
  color: var(--muted);
}

.notice .btn {
  margin-top: 10px;
}

/* ---------------------------------------------------------------- フッター */

.app-footer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 22px;
  border: 1px solid var(--sea-200);
  border-radius: 999px;
  background: var(--sea-50);
  color: var(--sea-700);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
}

.footer-note {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

.footer-note a {
  color: var(--sea-600);
}

/* ---------------------------------------------------------------- トースト */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(92vw, 480px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(8, 50, 74, 0.94);
  color: #fff;
  font-size: 16px;
  line-height: 1.5;
  text-align: center;
  z-index: 1200;
}

/* ---------------------------------------------------------------- その他 */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.leaflet-container {
  font-family: inherit;
  font-size: 14px;
}

.leaflet-control-attribution {
  font-size: 12px !important;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
