/* Курилка HOMA — гид. Цвета берём из темы Telegram, свои — только море и состояния моря. */
:root {
  color-scheme: light;
  --bg: var(--tg-theme-secondary-bg-color, #EDF3F2);
  --card: var(--tg-theme-bg-color, #FFFFFF);
  --text: var(--tg-theme-text-color, #0F2629);
  --hint: var(--tg-theme-hint-color, #6A7E80);
  --link: var(--tg-theme-link-color, #0A7C78);
  --btn: var(--tg-theme-button-color, #0B5D5B);
  --btn-text: var(--tg-theme-button-text-color, #FFFFFF);
  --line: color-mix(in srgb, var(--hint) 22%, transparent);

  --sea-deep: #0B5D5B;
  --sea: #1FA3A0;
  --foam: color-mix(in srgb, var(--sea) 14%, var(--card));
  --calm: #2E9E5B;
  --small: #D9A21B;
  --careful: #E07A2F;
  --rough: #D64533;
  --line-bangtao: #0A9488;
  --line-east: #7B5CD6;

  --display: "Unbounded", system-ui, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", sans-serif;
  --r: 16px;
  --gap: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tg]) {
    color-scheme: dark;
    --bg: #0B1719; --card: #132225; --text: #E4EFED; --hint: #8AA0A2; --link: #4CC7C0;
    --btn: #1FA3A0; --btn-text: #06201F;
    --line-bangtao: #1F9E93; --line-east: #9085E9;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 var(--body);
  padding: 0 16px calc(84px + env(safe-area-inset-bottom));
}
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; }
a { color: var(--link); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 0 6px; }
.brand { display: flex; gap: 8px; align-items: center; font: 600 13px/1 var(--display); letter-spacing: .02em; }
.seal { font-size: 18px; }
.updated { font-size: 12px; color: var(--hint); font-variant-numeric: tabular-nums; }

.tab { display: grid; gap: var(--gap); padding-top: 6px; }
.screen-title { font: 700 26px/1.1 var(--display); letter-spacing: -.01em; margin: 4px 0 2px; }
.section { font: 600 13px/1 var(--body); text-transform: uppercase; letter-spacing: .06em; color: var(--hint); margin-top: 8px; }
.card { background: var(--card); border-radius: var(--r); padding: 14px; display: grid; gap: 10px; }
.card h2 { font: 600 15px/1.2 var(--body); }
.note { font-size: 12.5px; color: var(--hint); }
.error { background: color-mix(in srgb, var(--rough) 12%, var(--card)); color: var(--text); padding: 12px; border-radius: 12px; }

/* ---------- Футшток: водомерная рейка с флажком ---------- */
.gauges { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.gauge {
  --fill: 0; --state: var(--calm);
  background: var(--card); border-radius: var(--r); padding: 14px 14px 12px;
  display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: end; min-height: 232px;
}
.staff {
  position: relative; height: 196px; border-radius: 10px; overflow: hidden;
  background:
    repeating-linear-gradient(to top, transparent 0 calc(20% - 1px), color-mix(in srgb, var(--hint) 45%, transparent) calc(20% - 1px) 20%),
    color-mix(in srgb, var(--hint) 10%, var(--card));
}
.staff::after { /* мелкие деления каждые 0,1 м */
  content: ""; position: absolute; inset: 0 60% 0 0;
  background: repeating-linear-gradient(to top, transparent 0 calc(4% - 1px), color-mix(in srgb, var(--hint) 30%, transparent) calc(4% - 1px) 4%);
}
.water {
  position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--fill) * 100%);
  background: linear-gradient(to top, var(--sea-deep), var(--sea));
  transition: height .9s cubic-bezier(.2, .8, .2, 1);
}
.water::before { /* гребень волны */
  content: ""; position: absolute; left: -50%; top: -7px; width: 200%; height: 14px;
  background: radial-gradient(10px 7px at 10px 7px, var(--sea) 98%, transparent) 0 0 / 20px 14px repeat-x;
  animation: drift 6s linear infinite;
}
@keyframes drift { to { transform: translateX(20px); } }
.flag {
  position: absolute; left: 50%; top: 6px; width: 2px; height: 26px; background: var(--text); z-index: 2; opacity: .75;
}
.flag::after {
  content: ""; position: absolute; left: 2px; top: 0; width: 16px; height: 11px; background: var(--state);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.marks { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.marks span { position: absolute; right: 3px; font: 600 9px/1 var(--display); color: var(--text); opacity: .7; transform: translateY(50%);
  text-shadow: 0 0 3px var(--card), 0 0 3px var(--card); }
.gauge-body { display: grid; gap: 4px; align-content: end; }
.gauge-place { font-size: 13px; color: var(--hint); }
.gauge-value { font: 700 34px/1 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.gauge-value small { font-size: 14px; font-weight: 500; margin-left: 3px; }
.gauge-verdict {
  font-size: 12.5px; font-weight: 600; line-height: 1.25; color: var(--state);
  padding-left: 9px; border-left: 3px solid var(--state);
}
.lv-calm { --state: var(--calm); } .lv-small { --state: var(--small); }
.lv-careful { --state: var(--careful); } .lv-rough { --state: var(--rough); }

.strip { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--card); border-radius: var(--r); padding: 12px 6px; }
.strip div { display: grid; justify-items: center; gap: 3px; }
.strip b { font: 700 17px/1 var(--display); font-variant-numeric: tabular-nums; }
.strip span { font-size: 11.5px; color: var(--hint); }

/* дождь по часам */
.rain { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; align-items: end; height: 84px; }
.rain i { display: block; border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--sea) 35%, transparent); min-height: 3px; }
.rain i.wet { background: var(--sea-deep); }
.rain-axis { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; font-size: 10.5px; color: var(--hint); text-align: center; font-variant-numeric: tabular-nums; }

.reports { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.reports li { display: grid; gap: 2px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.reports li:last-child { border-bottom: 0; padding-bottom: 0; }
.reports b { font-size: 14px; }
.reports span { font-size: 12px; color: var(--hint); }
.empty { font-size: 13.5px; color: var(--hint); }
.tomorrow { font-size: 13.5px; color: var(--hint); text-align: center; padding: 4px 0 8px; }

/* кнопки и чипы */
.btn {
  appearance: none; border: 0; border-radius: 12px; padding: 12px 14px; font-weight: 600; cursor: pointer;
  background: var(--btn); color: var(--btn-text); text-align: center; text-decoration: none; display: block;
}
.btn.ghost { background: var(--foam); color: var(--sea-deep); }
.btn:active { transform: scale(.98); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips button {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 13px; white-space: nowrap; cursor: pointer; font-size: 13.5px;
}
.chips button[aria-pressed="true"] { background: var(--text); color: var(--card); border-color: var(--text); }

.place h3 { font: 600 16px/1.25 var(--display); letter-spacing: -.01em; }
.meta { display: grid; gap: 3px; font-size: 13.5px; }
.meta span { color: var(--hint); display: inline-block; min-width: 44px; }
.why { font-size: 13.5px; }

/* афиша */
.event { display: grid; grid-template-columns: 58px 1fr; gap: 12px; align-items: center; }
.days { display: grid; justify-items: center; line-height: 1; background: var(--foam); border-radius: 12px; padding: 9px 0; }
.days b { font: 700 22px/1 var(--display); color: var(--sea-deep); font-variant-numeric: tabular-nums; }
.days span { font-size: 10.5px; color: var(--hint); margin-top: 3px; }
.event h3 { font-size: 15px; }
.event p { font-size: 13px; color: var(--hint); }
.today-badge { display: inline-block; font-size: 11px; font-weight: 700; color: var(--btn-text); background: var(--sea-deep); border-radius: 6px; padding: 2px 6px; margin-left: 6px; vertical-align: 1px; }
.meetup { background: linear-gradient(135deg, var(--sea-deep), var(--sea)); color: #fff; }
.meetup .note { color: rgba(255,255,255,.8); }

/* SOS */
.calls { display: grid; gap: 8px; }
.call {
  display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; text-decoration: none; color: var(--text);
  background: var(--card); border-radius: var(--r); padding: 12px 14px; border-left: 5px solid var(--rough);
}
.call b { font: 700 28px/1 var(--display); color: var(--rough); font-variant-numeric: tabular-nums; }
.call span { font-size: 13px; color: var(--hint); display: block; }
.call strong { font-size: 15px; }

/* полезное */
details.tip { background: var(--card); border-radius: 14px; padding: 0 14px; }
details.tip summary { cursor: pointer; padding: 13px 0; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
details.tip summary::after { content: "+"; color: var(--hint); font-weight: 400; }
details.tip[open] summary::after { content: "–"; }
details.tip p { padding-bottom: 8px; white-space: pre-line; }
details.tip .src { font-size: 12px; color: var(--hint); padding-bottom: 13px; }
.visa ul { margin: 0; padding-left: 18px; display: grid; gap: 7px; font-size: 14px; }
.visa .src { font-size: 12px; color: var(--hint); display: grid; gap: 3px; }

/* нижние вкладки */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar button { border: 0; background: none; display: grid; justify-items: center; gap: 3px; padding: 4px 0; color: var(--hint); cursor: pointer; font-size: 10.5px; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button[aria-current="page"] { color: var(--sea-deep); }
.tabbar button.sos { color: var(--rough); }
@media (prefers-color-scheme: dark) { .tabbar button[aria-current="page"] { color: var(--sea); } }

@media (prefers-reduced-motion: reduce) {
  .water { transition: none; }
  .water::before { animation: none; }
}
@media (min-width: 560px) {
  body { max-width: 560px; margin: 0 auto; }
}

/* ---------- Перекур ---------- */
.perekur { display: grid; gap: 8px; margin-top: 2px; }
.perekur-btn {
  appearance: none; border: 0; cursor: pointer; border-radius: 18px; padding: 15px 16px;
  font: 700 17px/1 var(--display); letter-spacing: -.01em; text-align: left;
  color: #FFF8EE; background:
    radial-gradient(120% 140% at 100% 0%, rgba(255,255,255,.18), transparent 55%),
    linear-gradient(120deg, #3A2A22, #6B4A3A);
  box-shadow: 0 6px 18px rgba(58, 42, 34, .25);
  position: relative; overflow: hidden;
}
.perekur-btn::after { /* дымок */
  content: ""; position: absolute; right: 18px; top: 50%; width: 38px; height: 38px; transform: translateY(-50%);
  background: radial-gradient(circle at 30% 70%, rgba(255,255,255,.35), transparent 40%),
              radial-gradient(circle at 60% 40%, rgba(255,255,255,.25), transparent 45%),
              radial-gradient(circle at 80% 20%, rgba(255,255,255,.18), transparent 40%);
  animation: smoke 4s ease-in-out infinite;
}
@keyframes smoke { 50% { transform: translateY(-62%) scale(1.15); opacity: .7; } }
.perekur-btn:active { transform: scale(.985); }
.perekur-sheet { background: var(--card); border-radius: var(--r); padding: 12px; display: grid; gap: 10px; }
.perekur-sheet p { font-weight: 600; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choices button { border: 0; border-radius: 12px; padding: 11px 6px; background: var(--foam); color: var(--sea-deep); font-weight: 600; cursor: pointer; }
.choices button:disabled { opacity: .5; }
@media (prefers-reduced-motion: reduce) { .perekur-btn::after { animation: none; } }

/* ---------- v2 ---------- */
.updated { border: 0; background: none; cursor: pointer; padding: 4px 0; }
.title-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.share { border: 1px solid var(--line); background: var(--card); color: var(--sea-deep); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.window { font-size: 14px; background: var(--card); border-radius: 12px; padding: 10px 12px; }
.skeleton { background: linear-gradient(100deg, var(--card) 40%, color-mix(in srgb, var(--hint) 12%, var(--card)) 50%, var(--card) 60%) 0 0 / 200% 100%;
  animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--hint); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: 3px; }
.k-bangtao { background: var(--line-bangtao); } .k-east { background: var(--line-east); }
.wave-chart svg { width: 100%; height: auto; display: block; }
.wave-chart .grid { stroke: var(--line); stroke-width: 1; }
.wave-chart .axis { fill: var(--hint); font-size: 9px; font-family: var(--body); }
.wave-chart path { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.wave-chart .l-bangtao { stroke: var(--line-bangtao); } .wave-chart .l-east { stroke: var(--line-east); }
.wave-chart .bangtao-dot { fill: var(--line-bangtao); stroke: var(--card); stroke-width: 2; }
.wave-chart .east-dot { fill: var(--line-east); stroke: var(--card); stroke-width: 2; }
.wave-chart .hit { fill: transparent; }

.tides { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.tide { background: var(--foam); border-radius: 12px; padding: 9px 10px; display: grid; gap: 2px; }
.tide b { font-size: 13px; color: var(--sea-deep); } .tide.low b { color: var(--hint); }
.tide span { font: 700 16px/1.1 var(--display); font-variant-numeric: tabular-nums; }

.week { display: grid; grid-template-columns: repeat(7, minmax(40px, 1fr)); gap: 5px; overflow-x: auto; padding-top: 11px; }
.day { position: relative; display: grid; justify-items: center; gap: 2px; padding: 8px 2px 7px; border-radius: 12px; background: color-mix(in srgb, var(--state) 12%, var(--card)); border-top: 3px solid var(--state); }
.day .wd { font-size: 11px; color: var(--hint); } .day .dt { font-size: 12px; font-weight: 600; }
.day b { font: 700 14px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.day .rn { font-size: 10px; color: var(--hint); }
.day.best { outline: 2px solid var(--calm); }
.day em { position: absolute; top: -9px; font-style: normal; font-size: 9px; font-weight: 700; background: var(--calm); color: #fff; border-radius: 6px; padding: 1px 5px; }

.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; display: inline-block; }
.report { display: grid; gap: 10px; }
.report fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.report legend { font-size: 12px; color: var(--hint); padding: 0; margin-bottom: 4px; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.btn:disabled { opacity: .45; cursor: default; }

.perekur-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; background: var(--card); border-radius: 14px; padding: 10px 12px; }
.perekur-item span, .perekur-item p { font-size: 12.5px; color: var(--hint); }
#perekury { display: grid; gap: 8px; }

.info-sec { display: grid; gap: var(--gap); }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--hint); }
.field input, .convert input, .convert select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%;
}
.check, .toggle { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input, .toggle input { width: 20px; height: 20px; accent-color: var(--sea-deep); flex: none; margin-top: 1px; }
.toggle { padding: 8px 0; border-bottom: 1px solid var(--line); }
.big-date { display: grid; gap: 2px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--state) 12%, var(--card)); border-left: 4px solid var(--state); }
.big-date span { font-size: 12.5px; color: var(--hint); }
.big-date b { font: 700 24px/1.15 var(--display); }
.big-date em { font-style: normal; font-size: 13.5px; font-weight: 600; color: var(--state); }
.stay-result { display: grid; gap: 8px; }
.convert { display: grid; grid-template-columns: 1fr 96px; gap: 8px; }
.convert-result { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.convert-result div { background: var(--foam); border-radius: 12px; padding: 10px 6px; display: grid; justify-items: center; gap: 2px; }
.convert-result b { font: 700 16px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.convert-result span { font-size: 12px; color: var(--hint); }

#phrases { display: grid; gap: 8px; }
.phrase { text-align: left; border: 0; background: var(--card); border-radius: 14px; padding: 11px 14px; display: grid; gap: 2px; cursor: pointer; }
.phrase .ru { font-weight: 600; } .phrase .say { color: var(--sea-deep); font-size: 15px; } .phrase .th { color: var(--hint); font-size: 13px; }
.show-thai { position: fixed; inset: 0; z-index: 30; background: var(--card); display: grid; place-content: center; gap: 18px; padding: 24px; text-align: center; }
.thai-big { font-size: clamp(40px, 13vw, 72px); line-height: 1.25; font-weight: 600; }
.thai-ru { color: var(--hint); font-size: 16px; }
