/* ============ ThisTimezone — fintech "profit green" theme ============
   Pocket-Option-inspired: deep navy slate, vivid green CTAs with glow,
   rounded panels, clean sans UI, mono for every time value. */

:root {
  --bg: #131a26;
  --bg-soft: #1a2332;
  --card: #1d2637;
  --border: #2b3852;
  --text: #eef2f8;
  --muted: #8b98ad;
  --accent: #2fca6e;                 /* profit green */
  --accent-strong: #21ad57;
  --accent-grad: linear-gradient(180deg, #38d97a 0%, #21ad57 100%);
  --accent-glow: 0 6px 18px rgba(47, 202, 110, .35);
  --accent-soft: rgba(47, 202, 110, .12);
  --blue: #3d8bfd;
  --warn: #ffb020;
  --danger: #ff5b5b;
  --brand-bg: #131a26;
  --shadow: 0 8px 24px rgba(4, 10, 20, .45);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f2f5f9;
  --bg-soft: #e9eef5;
  --card: #ffffff;
  --border: #dde5f0;
  --text: #17233c;
  --muted: #64748b;
  --accent: #1fab57;
  --accent-strong: #178f47;
  --accent-grad: linear-gradient(180deg, #2fc96c 0%, #1fa855 100%);
  --accent-glow: 0 6px 16px rgba(31, 171, 87, .3);
  --accent-soft: rgba(31, 171, 87, .1);
  --blue: #2f6fe4;
  --warn: #d98f00;
  --danger: #e03e3e;
  --brand-bg: #17233c;
  --shadow: 0 6px 20px rgba(23, 35, 60, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
.mono { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
::selection { background: var(--accent-soft); }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; gap: 12px;
  padding-top: 11px; padding-bottom: 11px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.brand svg rect { fill: var(--brand-bg); }
.brand-name { font-size: 1.15rem; font-weight: 800; letter-spacing: -.4px; white-space: nowrap; }
.brand-accent { color: var(--accent); }

.tabs {
  display: flex; gap: 4px; flex-wrap: wrap; margin-inline-start: auto;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 12px; padding: 4px;
}
.tab {
  appearance: none; border: none; background: none;
  color: var(--muted); font: inherit; font-weight: 600; font-size: .9rem;
  padding: 7px 11px; border-radius: 9px; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] {
  color: #fff; background: var(--accent-grad); box-shadow: var(--accent-glow);
}
:root[data-theme="light"] .tab[aria-selected="true"] { color: #fff; }

.header-controls { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  appearance: none; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  width: 38px; height: 38px; font-size: 1rem; cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.lang-select {
  appearance: none; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  height: 38px; padding: 0 10px; font: inherit; font-size: .88rem; cursor: pointer;
}
.lang-select:hover { border-color: var(--accent); }

.hour-btn { width: auto; padding: 0 12px; font-size: .85rem; font-weight: 700; }

/* ---------- zone autocomplete ---------- */
.ac-anchor { position: relative; }
.ac-list {
  display: none; position: absolute; top: calc(100% + 4px); inset-inline-start: 0;
  min-width: 100%; max-width: 340px; max-height: 300px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); z-index: 70; padding: 4px;
}
.ac-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: .88rem;
}
.ac-item:hover, .ac-item.active { background: var(--accent-soft); }
.ac-item.active { outline: 1px solid var(--accent); }
.ac-city { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-city .muted { font-size: .76rem; }
.ac-time { font-size: .78rem; color: var(--muted); white-space: nowrap; }

/* ---------- local zone marker / empty state ---------- */
.local-dot { color: var(--blue); font-size: .65rem; margin-inline-end: 6px; cursor: help; vertical-align: 2px; }
.empty-note { padding: 10px 4px; font-size: .9rem; }

/* ---------- tooltips ---------- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px 10px;
  font-size: .76rem; font-weight: 500; line-height: 1.4; text-align: center;
  width: max-content; max-width: 230px; white-space: normal;
  letter-spacing: 0; text-transform: none;
  opacity: 0; pointer-events: none; transition: opacity .15s;
  z-index: 60;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; }
main [data-tip]::after { top: auto; bottom: calc(100% + 8px); }

/* ---------- layout ---------- */
main { padding: 30px 16px 54px; }
.panel { display: none; }
.panel.active { display: block; animation: fadeup .16s ease-out; }
@keyframes fadeup { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; } }

.page-title {
  font-size: clamp(1.5rem, 3.2vw, 1.9rem); font-weight: 800; letter-spacing: -.5px;
  margin: 28px 0 20px; line-height: 1.25;
}
/* Landing typewriter effect: blinking caret while the title types out. */
.page-title.typing::after {
  content: ""; display: inline-block;
  width: 3px; height: .95em; background: var(--accent);
  margin-inline-start: 5px; vertical-align: -.12em; border-radius: 2px;
  animation: caret-blink .9s steps(1) infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }
@media (max-width: 640px) {
  .page-title { margin-top: 18px; }
}
.sub-head { font-size: 1.05rem; font-weight: 700; margin: 24px 0 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-label {
  font-size: .74rem; font-weight: 700; color: var(--muted);
  margin: 0 0 8px; text-transform: uppercase; letter-spacing: 1px;
}

.now-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 18px; }
.now-card { margin-bottom: 0; }
.big-time {
  font-size: clamp(1.3rem, 2.4vw + .5rem, 2.2rem);
  font-weight: 700; margin: 0 0 4px; letter-spacing: -.5px; white-space: nowrap;
}
#now-epoch, #epoch-live { color: var(--accent); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }

/* ---------- rolling digits ---------- */
.digit { display: inline-block; position: relative; overflow: hidden; vertical-align: bottom; }
.digit .in { display: inline-block; animation: digit-in .3s ease-out; }
.digit .out {
  position: absolute; inset-inline-start: 0; top: 0; pointer-events: none;
  animation: digit-out .3s ease-out forwards;
}
@keyframes digit-in { from { transform: translateY(.5em); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes digit-out { to { transform: translateY(-.5em); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .digit .in, .panel.active { animation: none; }
  .digit .out { display: none; }
}

/* ---------- forms ---------- */
.form-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 180px; }
.field.grow { flex: 1; }
.field-btn { min-width: 0; }
.field label {
  font-size: .74rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .8px;
}
/* Hints inside labels keep their casing — "µs" must not become "MS". */
.field label .muted { text-transform: none; letter-spacing: normal; font-weight: 400; }
.field .zone-input { width: 100%; }
input[type="datetime-local"], input[type="date"], .zone-input, input.mono, #epoch-input {
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font: inherit; min-width: 0;
  transition: border-color .15s;
}
input::placeholder { color: var(--muted); opacity: .8; }
input:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
input:focus-visible, button:focus-visible, .tab:focus-visible, [role="button"]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.zone-add { display: flex; gap: 8px; }
.zone-add input { flex: 1; }
.card-head .zone-add { flex: 1; min-width: 260px; max-width: 430px; }

.btn {
  appearance: none; border: none; background: var(--accent-grad);
  color: #fff; font: inherit; font-weight: 700;
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
  box-shadow: var(--accent-glow);
  transition: transform .12s, filter .12s;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: transparent; color: var(--accent);
  border: 1.5px solid var(--accent); box-shadow: none;
}
.btn.ghost:hover { background: var(--accent-soft); }
.btn.small { padding: 4px 12px; font-size: .78rem; border-radius: 8px; box-shadow: none; }
.btn.copied { background: var(--blue); filter: none; }

/* ---------- results ---------- */
.result-list { display: flex; flex-direction: column; gap: 8px; }
.result-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 10px 14px;
}
.result-zone { font-weight: 600; min-width: 210px; }
.result-zone .muted { font-weight: 400; font-size: .78rem; }
.result-time { margin-inline-start: auto; text-align: end; }
.result-time .t { font-size: 1.15rem; font-weight: 700; }
.day-diff {
  font-size: .72rem; font-weight: 700; color: #201500;
  background: var(--warn); padding: 1px 8px; border-radius: 999px; margin-inline-start: 6px;
  cursor: help;
}
.dst-badge {
  font-size: .68rem; font-weight: 700; color: var(--warn);
  border: 1px solid var(--warn); border-radius: 999px;
  padding: 0 7px; margin-inline-start: 6px; cursor: help;
  vertical-align: 2px;
}
.share-row { margin: 10px 0 0; }
.remove-btn {
  appearance: none; background: none; border: none; color: var(--muted);
  font-size: .95rem; cursor: pointer; padding: 4px 6px; border-radius: 8px;
}
.remove-btn:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }

.kv-list { display: flex; flex-direction: column; gap: 7px; }
.kv-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 13px; flex-wrap: wrap;
}
.kv-key {
  font-size: .74rem; font-weight: 700; color: var(--muted); min-width: 160px;
  text-transform: uppercase; letter-spacing: .6px;
}
.kv-val {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: .93rem; word-break: break-all;
}
.kv-row .btn { margin-inline-start: auto; }
.small-note { font-size: .84rem; margin: 4px 0 14px; }

/* ---------- world clocks ---------- */
.clock-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.clock-list .result-row { margin: 0; }

/* ---------- epoch strip ---------- */
.current-epoch-strip { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.current-epoch-strip strong { font-size: 1.1rem; }

/* ---------- planner ---------- */
.planner-scroll { overflow-x: auto; padding-bottom: 6px; }
.planner-table { border-collapse: collapse; min-width: 700px; width: 100%; }
.planner-table th {
  text-align: start; font-size: .8rem; color: var(--text);
  padding: 6px 12px 6px 0; white-space: nowrap; font-weight: 600;
  position: sticky; inset-inline-start: 0; background: var(--card); z-index: 1;
}
.planner-table th .off { font-weight: 400; font-size: .72rem; }
.planner-table td { padding: 2px; text-align: center; cursor: pointer; border-radius: 7px; }
.planner-table td.col-hover { background: color-mix(in srgb, var(--blue) 16%, transparent); }
.hour-cell {
  border-radius: 7px; font-size: .72rem; font-weight: 700;
  padding: 7px 0; min-width: 30px;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}
.hc-good { background: var(--accent-grad); color: #fff; }
.hc-ok { background: var(--warn); color: #201500; }
.hc-bad { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--muted); }
.planner-table td.selected .hour-cell { outline: 2.5px solid var(--blue); outline-offset: 1px; }
.legend { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; }
.legend.good { background: var(--accent); }
.legend.ok { background: var(--warn); }
.legend.bad { background: color-mix(in srgb, var(--danger) 30%, transparent); }

/* ---------- ask ---------- */
.ask-thread {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 420px; overflow-y: auto; margin-bottom: 14px;
}
.ask-thread:empty { display: none; }
.ask-msg {
  padding: 10px 14px; border-radius: 12px; max-width: 85%;
  white-space: pre-wrap; overflow-wrap: break-word; font-size: .93rem;
}
.ask-msg.user {
  align-self: flex-end;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-end-end-radius: 4px;
}
.ask-msg.assistant {
  align-self: flex-start;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-end-start-radius: 4px;
}
.ask-msg.error { color: var(--danger); }

/* ---------- guide ---------- */
.guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; }
.guide-card { margin-bottom: 0; }
.guide-card p { margin: 0; font-size: .92rem; }
.guide-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent-grad); color: #fff; box-shadow: var(--accent-glow);
  font-size: .82rem; font-weight: 800; margin-inline-end: 6px;
  vertical-align: -4px;
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 0 38px; font-size: .86rem;
}
.site-footer p { margin: 4px 0; }
.site-footer strong { color: var(--accent); }

/* ---------- FAQ (Guide tab) ---------- */
.faq-card { margin-top: 18px; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item:last-child { border-bottom: none; }
.faq-item summary {
  cursor: pointer; padding: 12px 0; font-weight: 600;
  list-style: none; position: relative; padding-inline-end: 28px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+"; position: absolute; inset-inline-end: 4px; top: 50%;
  transform: translateY(-50%); color: var(--accent); font-weight: 800; font-size: 1.1rem;
}
.faq-item[open] summary::after { content: "−"; }
.faq-item summary:hover { color: var(--accent); }
.faq-item p { margin: 0 0 14px; }

/* ---------- tool-finder helper bot ---------- */
.helper { position: fixed; inset-block-end: 18px; inset-inline-end: 18px; z-index: 60; }
.helper-fab {
  display: grid; place-items: center;
  width: 54px; height: 54px; border: none; border-radius: 50%;
  background: var(--accent-grad); box-shadow: var(--accent-glow);
  cursor: pointer; transition: transform .15s ease;
}
.helper-fab:hover { transform: scale(1.06); }
.helper-fab.pulse { animation: helper-pulse 2s ease-out 3; }
@keyframes helper-pulse {
  0% { box-shadow: var(--accent-glow), 0 0 0 0 rgba(47, 202, 110, .45); }
  70% { box-shadow: var(--accent-glow), 0 0 0 14px rgba(47, 202, 110, 0); }
  100% { box-shadow: var(--accent-glow), 0 0 0 0 rgba(47, 202, 110, 0); }
}
.helper-panel[hidden] { display: none; }
.helper-panel {
  position: absolute; inset-block-end: 64px; inset-inline-end: 0;
  width: 330px; max-width: calc(100vw - 28px);
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column;
}
.helper-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; font-weight: 700; font-size: .95rem;
  background: var(--bg-soft); border-bottom: 1px solid var(--border);
}
.helper-x {
  margin-inline-start: auto; appearance: none; border: none; background: none;
  color: var(--muted); font-size: .95rem; cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.helper-x:hover { color: var(--text); background: var(--accent-soft); }
.helper-thread {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px; max-height: 320px; overflow-y: auto;
}
.hb-msg {
  max-width: 85%; padding: 8px 12px; border-radius: 12px; font-size: .9rem; line-height: 1.45;
}
.hb-msg.bot { background: var(--bg-soft); border: 1px solid var(--border); align-self: flex-start; border-start-start-radius: 4px; }
.hb-msg.user { background: var(--accent-soft); color: var(--text); align-self: flex-end; border-start-end-radius: 4px; }
.hb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hb-chip {
  appearance: none; cursor: pointer;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .85rem; font-weight: 600;
}
.hb-chip:hover { border-color: var(--accent); color: var(--accent); }
.helper-inputrow {
  display: flex; gap: 6px; padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.helper-inputrow input {
  flex: 1; min-width: 0; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; font: inherit; font-size: .9rem;
}
.helper-inputrow input:focus { outline: none; border-color: var(--accent); }
@media (max-width: 640px) {
  .helper { inset-block-end: 12px; inset-inline-end: 12px; }
  .helper-fab { width: 48px; height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  .helper-fab, .helper-fab.pulse { transition: none; animation: none; }
}

/* ============ animation system ============
   Professional motion: transform/opacity only (GPU-friendly), 150–500ms,
   consistent easing, all gated behind prefers-reduced-motion. */
:root {
  --ease-out: cubic-bezier(.22, .61, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

@media (prefers-reduced-motion: no-preference) {

  /* --- micro-interactions --- */
  .btn, .tab, .icon-btn, .lang-select, .hb-chip, .helper-fab, .remove-btn {
    transition: transform .16s var(--ease-out), box-shadow .16s var(--ease-out),
                background-color .16s ease, color .16s ease, border-color .16s ease;
  }
  .btn:hover { transform: translateY(-1px); }
  .btn:active, .tab:active, .hb-chip:active { transform: scale(.96); }
  .icon-btn:hover, .hb-chip:hover { transform: translateY(-1px); }
  .btn.copied { animation: pop .4s var(--ease-spring); }
  @keyframes pop { 40% { transform: scale(1.14); } }

  /* --- smooth theme switching --- */
  body, .card, .site-header, .tabs, .result-row, .kv-row, .helper-panel,
  .hb-msg, input, select, .ac-list, .faq-item {
    transition: background-color .35s ease, border-color .35s ease, color .35s ease;
  }

  /* --- load: header drops in, brand logo draws itself --- */
  .site-header { animation: header-in .5s var(--ease-out); }
  @keyframes header-in { from { opacity: 0; transform: translateY(-10px); } }
  .brand svg path { animation: logo-draw 1.1s var(--ease-out) .15s backwards; }
  @keyframes logo-draw { from { stroke-dasharray: 1 1; stroke-dashoffset: 1; } to { stroke-dasharray: 1 0; stroke-dashoffset: 0; } }

  /* --- tab switch: content rises in a stagger --- */
  .panel.active { animation: none; }
  .panel.active > * { animation: rise .45s var(--ease-out) backwards; }
  .panel.active > *:nth-child(2) { animation-delay: .06s; }
  .panel.active > *:nth-child(3) { animation-delay: .12s; }
  .panel.active > *:nth-child(4) { animation-delay: .18s; }
  .panel.active > *:nth-child(n+5) { animation-delay: .24s; }
  .now-grid .now-card { animation: rise .5s var(--ease-out) backwards; }
  .now-grid .now-card:nth-child(2) { animation-delay: .09s; }
  .now-grid .now-card:nth-child(3) { animation-delay: .18s; }
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } }

  /* --- rows fade in as they (re)render — opacity only, so live re-renders
         while typing stay calm --- */
  .result-row, .kv-row { animation: row-in .3s ease backwards; }
  .result-row:nth-child(2), .kv-row:nth-child(2) { animation-delay: .04s; }
  .result-row:nth-child(3), .kv-row:nth-child(3) { animation-delay: .08s; }
  .result-row:nth-child(4), .kv-row:nth-child(4) { animation-delay: .12s; }
  .result-row:nth-child(n+5), .kv-row:nth-child(n+5) { animation-delay: .16s; }
  @keyframes row-in { from { opacity: 0; } }

  /* --- zone autocomplete dropdown --- */
  .ac-list { transform-origin: top center; animation: dd-in .18s var(--ease-out); }
  @keyframes dd-in { from { opacity: 0; transform: translateY(-5px) scale(.985); } }

  /* --- helper bot: FAB springs in on load, panel springs open --- */
  .helper-fab { animation: fab-in .55s var(--ease-spring) .6s backwards; }
  .helper-fab.pulse { animation: fab-in .55s var(--ease-spring) .6s backwards, helper-pulse 2s ease-out 1.4s 3; }
  @keyframes fab-in { from { opacity: 0; transform: scale(.4); } }
  .helper-panel:not([hidden]) { transform-origin: 90% 100%; animation: panel-in .3s var(--ease-spring); }
  @keyframes panel-in { from { opacity: 0; transform: translateY(12px) scale(.92); } }
  .hb-msg { animation: rise .3s var(--ease-out) backwards; }

  /* --- FAQ answers slide open --- */
  .faq-item[open] p { animation: rise .32s var(--ease-out); }
  .faq-item summary::after { transition: transform .2s var(--ease-out); }
  .faq-item[open] summary::after { transform: translateY(-50%) rotate(180deg); }

  /* --- scroll reveal (JS adds .reveal, then .in when visible) --- */
  .reveal { opacity: 0; transform: translateY(16px); }
  .reveal.in {
    opacity: 1; transform: none;
    transition: opacity .55s var(--ease-out), transform .55s var(--ease-out);
  }
}

/* Mid widths: brand + controls on the first row, tabs on their own full row. */
@media (max-width: 940px) {
  .header-controls { margin-inline-start: auto; }
  .tabs {
    order: 3; width: 100%; margin-inline-start: 0;
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex: 1 0 auto; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .brand-name { font-size: 1rem; }
  .lang-select { max-width: 84px; }
  .header-controls { margin-inline-start: auto; }
  /* One scrollable row — long translated labels (de/ru) can never fit six tabs. */
  .tabs {
    order: 3; width: 100%; margin-inline-start: 0; padding: 3px;
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 5px 8px; font-size: .8rem; white-space: nowrap; flex: 1 0 auto; }
  .card { padding: 14px; }

  /* Forms: one field per row, action buttons share a row. */
  .form-row { gap: 10px; margin-bottom: 12px; }
  .form-row .field { flex: 1 1 100%; min-width: 0; }
  .form-row .field-btn { flex: 0 1 auto; }
  .form-row .field-btn .btn { width: 100%; }

  /* Key/value rows: label + copy on the first line, value on its own line —
     consistent regardless of value length. */
  .kv-row {
    display: grid; grid-template-areas: "key btn" "val val";
    grid-template-columns: 1fr auto; align-items: center; row-gap: 2px;
  }
  .kv-key { grid-area: key; min-width: 0; }
  .kv-val { grid-area: val; }
  .kv-row .btn { grid-area: btn; margin-inline-start: 0; justify-self: end; }

  /* Result rows: zone + actions on the first line, time on its own line —
     the same shape no matter how long the zone name is. */
  .result-row {
    display: grid; grid-template-columns: 1fr auto auto;
    grid-template-areas: "zone copy x" "time time time";
    align-items: center; column-gap: 8px; row-gap: 2px;
  }
  .result-zone { grid-area: zone; min-width: 0; }
  .result-time { grid-area: time; margin-inline-start: 0; text-align: start; }
  .result-row > .btn { grid-area: copy; }
  .result-row > .remove-btn { grid-area: x; }
}
