/* ===========================================================================
   UTM · VIPAVENUE — тёмная тема, тил + латунь.
   Один экран, всё крупное, действия внизу под большой палец.
   ======================================================================== */

:root {
  --ink:        #06181A;   /* фон */
  --ink-2:      #0B2327;   /* карточка */
  --ink-3:      #103036;   /* поле ввода */
  --teal:       #0D5257;   /* бренд */
  --teal-lit:   #14757E;
  --brass:      #C8A96A;   /* акцент — латунная фурнитура бутика */
  --brass-dim:  #8A7647;
  --text:       #E6F0EF;
  --muted:      #7C9899;
  --danger:     #E4816B;
  --line:       rgba(200, 169, 106, .16);

  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 10px;

  --pad: 20px;
  --dock-h: calc(60px + 24px + env(safe-area-inset-bottom, 0px));

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100svh;
  background:
    radial-gradient(120% 60% at 50% -10%, #0F3A3F 0%, transparent 62%),
    var(--ink);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

/* Ничто не должно уезжать вбок */
body, main { overflow-x: hidden; }

button, input { font: inherit; color: inherit; }

button {
  border: 0; background: none; padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 3px;
  border-radius: 6px;
}

/* --- Шапка -------------------------------------------------------------- */

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) var(--pad) 6px;
}

.mark { display: block; width: 26px; height: 26px; color: var(--brass); flex: none; }
.mark svg { width: 100%; height: 100%; display: block; }

.topbar h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--brass);
}
.topbar h1 span { color: var(--muted); font-weight: 500; }

/* --- Секции ------------------------------------------------------------- */

main {
  padding: 14px var(--pad) calc(var(--dock-h) + 28px);
  display: flex;
  flex-direction: column;
  gap: 26px;
  max-width: 560px;
  margin: 0 auto;
}

.eyebrow {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 0 2px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--brass-dim);
}

.ghost {
  font-size: 11px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  padding: 4px 2px;
}
.ghost:active { color: var(--brass); }

/* --- Поле ссылки -------------------------------------------------------- */

.input-row {
  display: flex; align-items: stretch; gap: 8px;
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 6px 6px 6px 4px;
  transition: border-color .18s ease;
}
.input-row:focus-within { border-color: var(--teal-lit); }

#src {
  flex: 1 1 auto;
  min-width: 0;
  height: 52px;
  padding: 0 4px 0 14px;
  background: none;
  border: 0;
  font-family: var(--mono);
  /* 16px обязательно: на меньшем размере iOS Safari зумит страницу при фокусе */
  font-size: 16px;
  letter-spacing: -.02em;
}
#src::placeholder { color: #4E6E70; }
#src:focus { outline: none; }

.paste {
  flex: none;
  height: 52px;
  padding: 0 18px;
  border-radius: 13px;
  background: var(--teal);
  color: #DCEDEB;
  font-size: 15px; font-weight: 600;
  transition: transform .12s ease, background .16s ease;
}
.paste:active { transform: scale(.96); background: var(--teal-lit); }

.hint {
  margin: 8px 4px 0;
  font-size: 13px;
  color: var(--muted);
}
/* красным — только когда человек правда ошибся, а не «ещё не выбрал» */
.hint[data-tone="error"] { color: var(--danger); }

/* --- Площадка: два крупных сегмента ------------------------------------- */

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 6px;
}

.seg {
  height: 54px;
  border-radius: 13px;
  font-size: 16px; font-weight: 600;
  color: var(--muted);
  transition: background .18s ease, color .18s ease;
}
.seg[aria-checked="true"] {
  background: var(--teal);
  color: #EAF6F4;
  box-shadow: inset 0 0 0 1px rgba(200, 169, 106, .25);
}
.seg:active { transform: scale(.985); }

/* --- Бутик: кнопка, открывающая шторку ---------------------------------- */

.picker {
  width: 100%;
  min-height: 62px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 18px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  text-align: left;
  transition: border-color .16s ease;
}
.picker:active { border-color: var(--brass-dim); }

.picker-value { font-size: 19px; font-weight: 600; color: var(--muted); }
.picker[data-chosen="true"] .picker-value { color: var(--brass); }

.picker-caret { width: 20px; height: 20px; color: var(--muted); flex: none; }
.picker-caret svg { width: 100%; height: 100%; display: block; }

/* --- Результат: «бирка» ------------------------------------------------- */

.tag {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  min-height: 92px;
  display: flex; flex-direction: column; justify-content: center;
}
.tag[data-state="ready"] { border-color: rgba(200, 169, 106, .34); }

.tag-empty { margin: 0; color: var(--muted); font-size: 15px; }

.tag-base {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  word-break: break-all;
}

.tag-params { margin: 0; display: flex; flex-direction: column; gap: 6px; }

.tag-params .row {
  display: flex; gap: 8px; align-items: baseline;
  font-family: var(--mono);
  font-size: 13px;
  padding-top: 6px;
  border-top: 1px dashed rgba(200, 169, 106, .16);
}
.tag-params dt { color: var(--brass-dim); flex: none; }
.tag-params dd { margin: 0; color: var(--brass); word-break: break-all; }

/* --- История ------------------------------------------------------------ */

.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.history li {
  display: flex; align-items: center; gap: 12px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
}

.history .meta { flex: 1 1 auto; min-width: 0; }

.history .badges {
  display: flex; gap: 6px; margin-bottom: 4px;
  font-size: 10px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
}
.history .badges span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--brass-dim);
}

.history .url {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.history .copy-one {
  flex: none;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--ink-3);
  color: var(--brass);
}
.history .copy-one svg { width: 19px; height: 19px; }
.history .copy-one:active { background: var(--teal); }

/* --- Док ---------------------------------------------------------------- */

.dock {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 12px var(--pad) calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: linear-gradient(to top, var(--ink) 62%, rgba(6, 24, 26, 0));
  z-index: 40;
}

.dock-inner {
  display: flex; gap: 10px;
  max-width: 560px;
  margin: 0 auto;
}

.btn {
  height: 60px;
  border-radius: 16px;
  font-size: 17px; font-weight: 650;
  display: grid; place-items: center;
  transition: transform .12s ease, opacity .16s ease, background .2s ease;
}
.btn:active:not(:disabled) { transform: scale(.975); }
.btn:disabled { opacity: .38; }

.btn-primary {
  flex: 1 1 auto;
  background: var(--brass);
  color: #14201A;
}
.btn-primary[data-done="true"] { background: #2E7D5B; color: #E8F5ED; }

.btn-secondary {
  flex: none; width: 60px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  color: var(--brass);
}
.btn-secondary svg { width: 22px; height: 22px; }

/* --- Шторка ------------------------------------------------------------- */

.sheet { position: fixed; inset: 0; z-index: 60; }

.sheet-scrim {
  position: absolute; inset: 0;
  background: rgba(3, 12, 13, .66);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .26s ease;
}

.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: #0A2024;
  border-top: 1px solid var(--line);
  border-radius: 24px 24px 0 0;
  padding: 10px var(--pad) calc(env(safe-area-inset-bottom, 0px) + 20px);
  max-height: 86svh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.22, .9, .3, 1);
}

.sheet[data-open="true"] .sheet-scrim { opacity: 1; }
.sheet[data-open="true"] .sheet-panel { transform: translateY(0); }

.sheet-grip {
  width: 38px; height: 4px; border-radius: 2px;
  background: #24484C;
  margin: 0 auto 14px;
}

.sheet-title {
  margin: 0 2px 14px;
  font-size: 11px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--brass-dim);
}

.sheet-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.boutique {
  min-height: 62px;
  padding: 0 16px;
  display: flex; align-items: center;
  border-radius: var(--r-md);
  background: var(--ink-3);
  border: 1px solid transparent;
  font-size: 17px; font-weight: 600;
  color: var(--text);
}
.boutique[aria-checked="true"] {
  background: var(--teal);
  border-color: var(--brass);
  color: #F2E3C4;
}
.boutique:active { transform: scale(.97); }

/* --- Тост --------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + 16px);
  transform: translate(-50%, 12px);
  z-index: 80;
  padding: 11px 20px;
  border-radius: 999px;
  background: #123B3D;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 14px; font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .22s ease;
}
.toast[data-show="true"] { opacity: 1; transform: translate(-50%, 0); }

/* --- Подсказка про установку ------------------------------------------- */

.install {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: -6px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: #0E2C2F;
  border: 1px solid var(--line);
}
.install[hidden] { display: none; }
.install p { margin: 0; font-size: 13px; line-height: 1.35; color: var(--muted); }
.install b { color: var(--brass); font-weight: 650; }
.install button { flex: none; width: 30px; height: 30px; color: var(--muted); font-size: 15px; }

/* --- Уважение к настройкам ---------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Узкие телефоны (SE) */
@media (max-width: 359px) {
  .sheet-grid { grid-template-columns: 1fr; }
  .paste { padding: 0 14px; }
}
