/* Нічний концертний зал: лак рояля, слонова кістка, один акцент (пильна троянда).
   Форми: усе, що натискається, — пігулки; поля 14px; панель форми 24px. */
:root {
  --bg: #0e0b12;
  --bg-2: #17121c;
  --ink: #f4ede4;
  --ink-2: #d2c7cb;
  --muted: #a3969f;
  --accent: #e7a6b3;
  --accent-deep: #6d2a3a;
  --error: #f3b1bb;
  --line: rgba(244, 237, 228, 0.14);
  --serif: 'Cormorant Garamond', 'Times New Roman', serif;
  --sans: 'Manrope', system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}
::selection { background: rgba(231, 166, 179, 0.35); }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; font-weight: 400; }
h1:focus, h2:focus { outline: none; }

/* ---------- атмосфера ---------- */
.bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }
.glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(60% 50% at 88% -6%, rgba(242, 196, 168, 0.13), transparent 70%),
    radial-gradient(55% 45% at -6% 104%, rgba(231, 166, 179, 0.09), transparent 70%);
}
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- верхня панель ---------- */
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center;
  padding: calc(env(safe-area-inset-top) + 14px) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
#mute-btn { margin-left: auto; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 999px;
  display: grid; place-items: center; cursor: pointer;
  color: var(--ink); font-size: 20px;
  background: rgba(26, 20, 30, 0.55);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: transform 0.25s var(--ease), border-color 0.25s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- екрани ---------- */
main { position: relative; z-index: 2; }
.screen {
  display: none;
  width: 100%; max-width: 1180px; margin: 0 auto;
  min-height: 100vh; min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 80px) max(20px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 44px) max(20px, env(safe-area-inset-left));
  flex-direction: column; justify-content: center;
}
.screen--active { display: flex; }

.rv { opacity: 0; }
.screen--active .rv {
  animation: rise 0.95s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 110ms + 100ms);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 26px; border-radius: 999px;
  font-family: var(--sans); font-size: 16px; font-weight: 600; letter-spacing: 0.01em;
  white-space: nowrap; cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), background 0.3s;
  -webkit-tap-highlight-color: transparent;
  align-self: flex-start;
}
.btn i { font-size: 20px; transition: transform 0.3s var(--ease); }
.btn--primary {
  background: var(--ink); color: #150f18;
  box-shadow: 0 12px 32px -14px rgba(231, 166, 179, 0.55);
}
.btn--ghost { background: transparent; color: var(--ink); border-color: rgba(244, 237, 228, 0.26); }
.btn--wide { width: 100%; }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn[disabled] { opacity: 0.6; cursor: progress; }
@media (hover: hover) {
  .btn--primary:hover { transform: translateY(-2px); box-shadow: 0 18px 38px -14px rgba(231, 166, 179, 0.7); }
  .btn--primary:hover .ph-arrow-right { transform: translateX(3px); }
  .btn--ghost:hover { border-color: rgba(244, 237, 228, 0.5); }
  .icon-btn:hover { border-color: rgba(244, 237, 228, 0.32); }
}

/* ---------- обкладинка ---------- */
.cover { max-width: 940px; padding-left: clamp(0px, 6vw, 96px); display: flex; flex-direction: column; }
.cover__lead { display: flex; flex-direction: column; align-items: flex-start; }
.cover__title {
  display: flex; flex-direction: column;
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(52px, 11vw, 132px); line-height: 1.02; letter-spacing: -0.02em;
}
.cover__line { font-style: italic; color: var(--accent); line-height: 1.14; padding-bottom: 0.06em; }
.cover__sub {
  color: var(--ink-2); font-size: clamp(16px, 0.6vw + 13px, 19px); line-height: 1.65;
  max-width: 34ch; margin: 26px 0 36px;
}

/* ---------- лист ---------- */
.letter { max-width: 720px; display: flex; flex-direction: column; }
.mark {
  font-family: var(--serif); font-style: italic; color: var(--accent);
  font-size: 22px; line-height: 1.2; margin-bottom: 10px;
}
.letter__title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(38px, 5.2vw, 68px); line-height: 1.1; letter-spacing: -0.01em;
  margin-bottom: 30px; padding-bottom: 0.04em;
}
.letter__body p {
  font-family: var(--serif); color: var(--ink-2);
  font-size: clamp(21px, 0.9vw + 16px, 27px); line-height: 1.5;
  margin-bottom: 18px;
}
.letter__sign {
  font-family: var(--serif); font-style: italic; color: var(--ink);
  font-size: clamp(22px, 1vw + 17px, 29px); line-height: 1.45;
  margin: 6px 0 38px; padding: 2px 0 4px 20px;
  border-left: 1px solid var(--accent);
}

/* ---------- піаніно ---------- */
.screen--piano { align-items: center; gap: 30px; }
.piano-intro { width: 100%; max-width: 920px; }
.piano-intro__title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(36px, 4.8vw, 64px); line-height: 1.1; letter-spacing: -0.01em;
  max-width: 16ch; margin-bottom: 18px; padding-bottom: 0.04em;
}
.piano-intro__body { color: var(--ink-2); font-size: clamp(16px, 0.5vw + 13px, 18px); line-height: 1.7; max-width: 48ch; }
.piano-wrap { width: 100%; max-width: 920px; }
.piano-hint {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 14px; letter-spacing: 0.02em;
}
.piano-hint i { color: var(--accent); font-size: 18px; }
.notes-fx { display: block; width: 100%; height: 110px; }
.piano {
  position: relative; display: flex;
  height: clamp(150px, 24vw, 230px);
  padding: 18px 10px 10px;
  border-radius: 18px 18px 14px 14px;
  background: linear-gradient(180deg, #211a26 0%, #120e15 100%);
  border: 1px solid rgba(244, 237, 228, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 34px 60px -24px rgba(0, 0, 0, 0.8);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.piano::before {
  content: ''; position: absolute; left: 10px; right: 10px; top: 11px; height: 4px;
  border-radius: 2px; background: var(--accent-deep);
}
.keys { position: relative; flex: 1; display: flex; }
.key { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.key--white {
  flex: 1; position: relative; margin: 0 1.5px;
  border-radius: 0 0 7px 7px;
  background: linear-gradient(180deg, #e9e1d6 0%, #f8f3ec 62%, #e4dbcf 100%);
  box-shadow: inset 0 -7px 0 rgba(20, 12, 18, 0.08), 0 2px 0 rgba(0, 0, 0, 0.45);
  transition: transform 0.08s, box-shadow 0.2s, background 0.2s;
}
.key--white.key--down {
  transform: translateY(2px);
  background: linear-gradient(180deg, #e2d2cc 0%, #f3e3df 70%, #e8d6d0 100%);
  box-shadow: inset 0 -3px 0 rgba(20, 12, 18, 0.08), 0 0 26px rgba(231, 166, 179, 0.5);
}
.key--black {
  position: absolute; top: 0; z-index: 2;
  width: calc(100% / var(--n) * 0.6);
  left: calc(100% / var(--n) * var(--pos) - 100% / var(--n) * 0.3);
  height: 62%;
  border-radius: 0 0 5px 5px;
  background: linear-gradient(180deg, #2b2331 0%, #0c090e 86%);
  box-shadow: inset 0 -4px 0 rgba(255, 255, 255, 0.07), 0 4px 5px rgba(0, 0, 0, 0.55);
  transition: box-shadow 0.2s, background 0.2s;
}
.key--black.key--down {
  background: linear-gradient(180deg, #3f2d3b 0%, #1b1219 86%);
  box-shadow: inset 0 -2px 0 rgba(255, 255, 255, 0.05), 0 0 20px rgba(231, 166, 179, 0.6);
}
.piano-reply {
  min-height: 1.5em; margin-top: 16px;
  font-family: var(--serif); font-style: italic; color: var(--accent);
  font-size: clamp(20px, 0.8vw + 16px, 26px); line-height: 1.35;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}
.piano-reply--on { opacity: 1; transform: none; }
.piano-next { width: 100%; max-width: 920px; display: flex; }

/* ---------- подяка ---------- */
.screen--thanks { align-items: center; text-align: center; }
.thanks { max-width: 780px; display: flex; flex-direction: column; align-items: center; }
.thanks__title {
  font-family: var(--serif); font-style: italic; font-weight: 300;
  font-size: clamp(60px, 11vw, 148px); line-height: 1.12; letter-spacing: -0.02em;
  padding-bottom: 0.08em; margin-bottom: 26px;
}
.thanks__list { list-style: none; padding: 0; margin: 0 0 30px; display: grid; gap: 16px; }
.thanks__list li {
  font-family: var(--serif); color: var(--ink-2);
  font-size: clamp(21px, 0.9vw + 16px, 28px); line-height: 1.45;
}
.thanks__close {
  font-family: var(--serif); font-style: italic; color: var(--accent);
  font-size: clamp(24px, 1.2vw + 18px, 34px); line-height: 1.3; margin-bottom: 38px;
}
.thanks .btn { align-self: center; }

/* ---------- сюрприз ---------- */
.surprise { display: grid; grid-template-columns: 1fr; gap: 28px; width: 100%; }
.surprise__title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(38px, 4.8vw, 64px); line-height: 1.1; letter-spacing: -0.01em;
  margin-bottom: 18px; padding-bottom: 0.04em;
}
.surprise__sub { color: var(--ink-2); font-size: clamp(16px, 0.5vw + 13px, 18px); line-height: 1.7; max-width: 36ch; }
.form {
  display: grid; gap: 18px;
  padding: clamp(20px, 3vw, 32px);
  border-radius: 24px;
  background: rgba(26, 20, 30, 0.66);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 40px 80px -40px rgba(0, 0, 0, 0.85);
}
.form__row { display: grid; grid-template-columns: 1fr; gap: 18px; }
.field { display: grid; gap: 8px; min-width: 0; }
.field__label { color: var(--ink-2); font-size: 14px; font-weight: 500; letter-spacing: 0.02em; }
.field__opt { color: var(--muted); font-weight: 400; margin-left: 6px; }
.field__box { position: relative; }
.field__icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--accent); font-size: 20px; pointer-events: none; z-index: 1;
}
.field__ghost {
  position: absolute; left: 48px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 17px; pointer-events: none; display: none;
}
.field[data-empty] .field__ghost { display: block; }
.field[data-empty] .field__box:focus-within .field__ghost { display: none; }
.field__input, .field__area {
  display: block; width: 100%; margin: 0;
  color: var(--ink); font-family: var(--sans); font-size: 17px; font-weight: 500;
  background: rgba(14, 11, 18, 0.72);
  border: 1px solid rgba(244, 237, 228, 0.2);
  border-radius: 14px;
  color-scheme: dark;
  transition: border-color 0.2s;
}
.field__input {
  min-height: 56px; line-height: 26px;
  padding: 14px 16px 14px 48px;
  -webkit-appearance: none; appearance: none;
}
.field__input::-webkit-date-and-time-value { text-align: left; }
/* свою іконку вже малюємо зліва, а календар відкриває клік по полю (showPicker) */
.field__input::-webkit-calendar-picker-indicator { display: none; }
.field[data-empty] input.field__input { color: transparent; }
.field[data-empty] input.field__input:focus { color: var(--ink); }
/* кнопка-поле дня, що відкриває наш календар */
.field__pick { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; cursor: pointer; }
.field[data-empty] .field__pick { color: var(--muted); font-weight: 400; }
.field__pick-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field__caret { font-size: 16px; color: var(--muted); transition: transform 0.35s var(--ease); flex: none; }
.field__pick[aria-expanded="true"] .field__caret { transform: rotate(180deg); }

/* ---------- календар ---------- */
.cal {
  width: 100%; max-width: 420px; padding: 14px 14px 12px;
  border-radius: 18px;
  background: rgba(14, 11, 18, 0.86);
  border: 1px solid rgba(244, 237, 228, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 24px 50px -30px rgba(0, 0, 0, 0.9);
  animation: cal-in 0.45s var(--ease) both;
}
@keyframes cal-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.cal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.cal__title { font-family: var(--serif); font-style: italic; font-size: 25px; line-height: 1.2; color: var(--ink); padding: 0 0 2px 6px; }
.cal__navs { display: flex; gap: 6px; }
.cal__nav {
  width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--line); color: var(--ink); font-size: 18px; cursor: pointer;
  transition: border-color 0.2s, transform 0.2s var(--ease); -webkit-tap-highlight-color: transparent;
}
.cal__nav:disabled { opacity: 0.28; cursor: default; }
.cal__nav:active:not(:disabled) { transform: scale(0.94); }
.cal__week, .cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal__week span { text-align: center; font-size: 12px; letter-spacing: 0.04em; color: var(--muted); padding: 6px 0 4px; }
.cal__week span:nth-child(n+6) { color: var(--accent); }
.cal__day {
  aspect-ratio: 1 / 1; min-height: 36px; width: 100%; padding: 0;
  border-radius: 999px; border: 1px solid transparent; background: transparent;
  color: var(--ink); font-family: var(--sans); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums;
  cursor: pointer; transition: background 0.2s, color 0.2s, transform 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.cal__day:disabled { color: rgba(244, 237, 228, 0.24); cursor: default; }
.cal__day--today { border-color: rgba(231, 166, 179, 0.6); }
.cal__day--on { background: var(--accent); color: #1a1016; font-weight: 600; box-shadow: 0 6px 18px -6px rgba(231, 166, 179, 0.65); }
.cal__day:active:not(:disabled) { transform: scale(0.92); }
.cal__day:focus-visible, .cal__nav:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (hover: hover) {
  .cal__day:not(:disabled):not(.cal__day--on):hover { background: rgba(244, 237, 228, 0.08); }
  .cal__nav:not(:disabled):hover { border-color: rgba(244, 237, 228, 0.34); }
}

.field__area { min-height: 56px; padding: 15px 16px; resize: none; line-height: 1.5; }
.field__area::placeholder { color: var(--muted); opacity: 1; }
.field__input:focus, .field__area:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: transparent; }
.field--invalid .field__input { border-color: var(--error); }
.field__err { color: var(--error); font-size: 14px; line-height: 1.4; }
.field__err:empty { display: none; }
.form .btn { margin-top: 4px; }

/* ---------- фінал і помилка ---------- */
.done, .err { max-width: 880px; padding-left: clamp(0px, 6vw, 96px); display: flex; flex-direction: column; }
.done__title, .err__title {
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(56px, 10vw, 124px); line-height: 1.06; letter-spacing: -0.02em;
  padding-bottom: 0.04em;
}
.err__title { font-size: clamp(44px, 7vw, 88px); }
.done__when {
  font-family: var(--serif); font-style: italic; color: var(--accent);
  font-size: clamp(27px, 2.4vw + 14px, 42px); line-height: 1.22;
  margin: 14px 0 26px; padding-bottom: 0.06em;
}
.done__body, .err__sub { color: var(--ink-2); font-size: clamp(16px, 0.5vw + 13px, 18px); line-height: 1.7; max-width: 40ch; }
.err__sub { margin: 18px 0 34px; }
.done__sign {
  font-family: var(--serif); font-style: italic; color: var(--ink);
  font-size: clamp(23px, 1.2vw + 17px, 31px); line-height: 1.4;
  margin: 26px 0 38px; max-width: 26ch;
}

/* ---------- ширші екрани ---------- */
@media (min-width: 520px) {
  .form__row { grid-template-columns: 1.35fr 1fr; }
  /* дві колонки: календар окремим рядком на всю ширину під обома полями */
  #field-time { grid-column: 2; grid-row: 1; }
  .form__row .cal { grid-column: 1 / -1; grid-row: 2; }
  .screen { padding-left: max(32px, env(safe-area-inset-left)); padding-right: max(32px, env(safe-area-inset-right)); }
}
@media (min-width: 960px) {
  .letter { margin-left: clamp(0px, 10vw, 170px); }
  .surprise { grid-template-columns: 5fr 6fr; gap: 72px; align-items: center; }
  .piano-next { justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  .rv, .screen--active .rv { opacity: 1; animation: none; }
  .btn, .icon-btn, .key--white, .key--black, .piano-reply, .cal__day, .field__caret { transition: none; }
  .cal { animation: none; }
}
