/* Вхід і реєстрація: спільний вигляд (верхня панель, картка, поля, кнопка).
   Без backdrop-filter і без transition: all — щоб не гальмувало на телефонах. */
:root {
    --ink: #1a1a1a;
    --ink-2: #3a3a3a;
    --muted: #6b6f78;
    --faint: #9a9ea7;
    --line: #e3e6eb;
    --field: #f7f8fa;
    --gold: #8f6f26; /* було #a98a3e: контраст 3.3:1 → 5:1 (WCAG AA) */
    --gold-ring: rgba(169, 138, 62, 0.22);
    --err: #b42318;
    --bar-h: 80px;
    --ctl-h: 50px;
    --field-gap: 14px;
    --serif: 'Cormorant Garamond', 'Playfair Display', Georgia, serif;
    --sans: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

body {
    font-family: var(--sans);
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
    color: var(--ink);
    /* iOS Safari: vh-фолбек ОБОВʼЯЗКОВО перед svh — інакше сторінка може відрендеритись порожньою. */
    min-height: 100vh;
    min-height: 100svh;
    padding: calc(var(--bar-h) + env(safe-area-inset-top)) 16px 0;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Верхня панель ---------- */
.app-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    padding-top: env(safe-area-inset-top);
    background: #fff;
    border-bottom: 1px solid rgba(26, 26, 26, 0.08);
    box-shadow: 0 2px 10px rgba(26, 26, 26, 0.05);
}
.bar-row, .flow-bar { max-width: 500px; margin: 0 auto; }
.bar-row {
    height: 46px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
}
.bar-home {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(26, 26, 26, 0.05);
    color: var(--ink);
    text-decoration: none;
    transition: background-color 0.18s ease;
}
.bar-home svg { width: 19px; height: 19px; }
.bar-time {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.bar-link {
    flex: 0 0 auto;
    height: 34px;
    padding: 0 13px;
    display: inline-flex;
    align-items: center;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.18s ease;
}
.app-bar .lang-btn {
    height: 34px;
    min-width: 40px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    transition: background-color 0.18s ease;
}
@media (hover: hover) {
    .bar-home:hover { background: rgba(26, 26, 26, 0.1); }
    .bar-link:hover, .app-bar .lang-btn:hover { background: #f1f3f6; }
}
.bar-home:focus-visible, .bar-link:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.flow-bar {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    height: 34px;
    padding: 0 12px 0 6px;
}
.flow-back {
    grid-column: 1;
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 12px 0 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(26, 26, 26, 0.05);
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
    touch-action: manipulation;
}
.flow-back svg { width: 14px; height: 14px; flex: 0 0 auto; }
.flow-back:active { transform: scale(0.96); background: var(--field); }
@media (hover: hover) { .flow-back:hover { background: var(--field); border-color: #cfd3da; } }
.flow-back:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.flow-step {
    grid-column: 2;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #6b6676;
    white-space: nowrap;
}
.flow-step.is-tagline { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 500; color: #6b6676; }
.flow-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: rgba(26, 26, 26, 0.04);
}
.flow-progress i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--gold);
    opacity: 0.85;
    transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Картка ---------- */
.auth-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--bar-h) - env(safe-area-inset-top));
    min-height: calc(100svh - var(--bar-h) - env(safe-area-inset-top));
    padding: 14px 0 max(20px, env(safe-area-inset-bottom));
}
.auth-card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border: 1px solid rgba(26, 26, 26, 0.06);
    border-radius: 22px;
    padding: 24px 20px 18px;
    box-shadow: 0 1px 2px rgba(26, 26, 26, 0.04), 0 22px 46px -22px rgba(26, 26, 26, 0.24);
    animation: authIn 0.35s cubic-bezier(0.22, 0.8, 0.3, 1) both;
}
@media (min-width: 600px) {
    .auth-card { padding: 36px 36px 26px; }
}
@keyframes authIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

.auth-head { text-align: center; margin-bottom: 20px; }
.auth-kicker {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 8px;
}
.auth-kicker::before, .auth-kicker::after {
    content: '';
    width: 20px;
    height: 1px;
    background: currentColor;
    opacity: 0.55;
}
.auth-head h1 {
    font-family: var(--serif);
    font-size: 34px;
    font-weight: 700;
    line-height: 1.04;
    letter-spacing: -0.01em;
    text-wrap: balance;
}
.auth-sub {
    margin: 8px auto 0;
    max-width: 330px;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--muted);
    text-wrap: balance;
}

/* ---------- Поля ---------- */
.field { margin-bottom: var(--field-gap); }
.field label, .field-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: #4a4e57;
    margin-bottom: 5px;
}
.field label.chip { display: inline-flex; margin-bottom: 0; font-size: 12.5px; color: var(--ink); }
.field label.chip.on { color: #fff; }
.field-label-2 { margin-top: 10px; }
.label-opt { font-weight: 400; color: var(--faint); }

.input-field {
    display: block;
    width: 100%;
    height: var(--ctl-h);
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--field);
    color: var(--ink);
    /* iOS: мінімум 16px, інакше сторінка автозумиться при фокусі */
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}
textarea.input-field { height: auto; min-height: 72px; padding: 12px 16px; line-height: 1.45; resize: vertical; }
.input-field::placeholder { color: #a7abb3; }
@media (hover: hover) {
    .input-field:hover:not(:disabled):not(:focus) { border-color: #cfd3da; }
}
.input-field:focus {
    outline: none;
    background: #fff;
    border-color: var(--ink);
    box-shadow: 0 0 0 4px var(--gold-ring);
}
.input-field:disabled { opacity: 0.55; cursor: not-allowed; }

select.input-field {
    padding-right: 42px;
    cursor: pointer;
    text-overflow: ellipsis;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%236b6f78' stroke-width='1.7' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
}

.control { position: relative; }
.control .ico {
    position: absolute;
    left: 15px;
    top: 50%;
    width: 18px;
    height: 18px;
    margin-top: -9px;
    color: var(--faint);
    pointer-events: none;
    transition: color 0.18s ease;
}
.control:focus-within .ico { color: var(--ink); }
.control .input-field { padding-left: 44px; }
.control.no-ico .input-field { padding-left: 16px; }
.control.has-toggle .input-field { padding-right: 52px; }
input[type="password"].input-field:not(:placeholder-shown) { letter-spacing: -3px; }

.pw-toggle {
    position: absolute;
    right: 5px;
    top: 50%;
    width: 42px;
    height: 42px;
    margin-top: -21px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--faint);
    cursor: pointer;
    transition: color 0.18s ease, background-color 0.18s ease;
}
.pw-toggle svg { width: 19px; height: 19px; }
.pw-toggle .eye-off { display: none; }
.pw-toggle.is-on .eye { display: none; }
.pw-toggle.is-on .eye-off { display: block; }
.pw-toggle.is-on { color: var(--ink); }
@media (hover: hover) { .pw-toggle:hover { color: var(--ink); background: rgba(26, 26, 26, 0.05); } }
.pw-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: 0; }

.field-hint { display: block; font-size: 12px; color: var(--err); margin-top: 6px; min-height: 14px; }
.field-hint:empty { display: none; }
.chip-hint { display: block; font-size: 12px; line-height: 1.4; color: #878b94; margin-top: 8px; }
.chip-hint.warn { color: var(--err); font-weight: 600; }

/* ---------- Повідомлення ---------- */
.notice {
    padding: 11px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 14px;
}
.notice-error { background: #fdf1f0; border: 1px solid #f4c7c3; color: var(--err); }
.notice-warn { background: #fbf6ea; border: 1px solid #eadcb4; color: #7a5d14; }

/* ---------- Кнопка ---------- */
.btn-primary {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: calc(var(--ctl-h) + 2px);
    border: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, #1a1a1a 0%, #3a3a3a 100%);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 22px -10px rgba(26, 26, 26, 0.6);
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}
@media (hover: hover) {
    .btn-primary:hover:not(:disabled) {
        transform: translateY(-1px);
        filter: brightness(1.14);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 14px 26px -10px rgba(26, 26, 26, 0.65);
    }
}
.btn-primary:active:not(:disabled) {
    transform: translateY(0) scale(0.985);
    filter: brightness(1.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 4px 10px -6px rgba(26, 26, 26, 0.6);
}
.btn-primary:focus-visible { outline: 3px solid var(--gold-ring); outline-offset: 2px; }
.btn-primary:disabled { opacity: 0.42; cursor: not-allowed; box-shadow: none; }
.btn-primary.is-loading:disabled { opacity: 0.88; cursor: progress; box-shadow: 0 10px 22px -10px rgba(26, 26, 26, 0.5); }
.btn-spin {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.32);
    border-top-color: #fff;
    border-radius: 50%;
    animation: authSpin 0.7s linear infinite;
}
.btn-primary.is-loading .btn-spin { display: block; }
@keyframes authSpin { to { transform: rotate(360deg); } }

/* ---------- Нижній рядок картки ---------- */
.auth-alt {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    text-align: center;
    font-size: 13.5px;
    color: var(--muted);
}
.auth-alt a {
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid var(--gold);
    padding-bottom: 1px;
}
.auth-forgot { margin: -4px 0 10px; text-align: right; font-size: 13px; }
.auth-forgot a { color: var(--muted); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.auth-forgot a:hover { color: var(--ink); }
.auth-alt a:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 3px; }

@media (max-width: 375px) {
    .bar-row { gap: 6px; padding: 5px 6px; }
    .bar-link { padding: 0 10px; font-size: 12px; }
    .bar-time { font-size: 12px; }
    .auth-card { padding: 22px 16px 16px; }
    .auth-head h1 { font-size: 30px; }
}
/* ---------- Телефон: код країни + номер ---------- */
.phone-ctl {
    display: flex;
    align-items: stretch;
    height: var(--ctl-h);
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--field);
    transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}
@media (hover: hover) { .phone-ctl:hover:not(:focus-within) { border-color: #cfd3da; } }
.phone-ctl:focus-within { background: #fff; border-color: var(--ink); box-shadow: 0 0 0 4px var(--gold-ring); }
.phone-ctl .input-field {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    padding: 0 14px 0 12px;
    border: 0;
    border-radius: 0 13px 13px 0;
    background: transparent;
    box-shadow: none;
}
.phone-ctl .input-field:focus { background: transparent; box-shadow: none; }
.dial {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0 10px 0 13px;
    border-right: 1px solid var(--line);
    color: var(--ink);
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}
.field .dial { display: flex; margin-bottom: 0; font-size: 15px; font-weight: 500; color: var(--ink); }
.dial-label b { font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); margin-right: 1px; }
.dial-chev { color: var(--faint); flex: 0 0 auto; }
.dial-select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    font-size: 16px;
}
.phone-ctl:focus-within .dial { border-right-color: var(--line); }

/* ---------- Щільний режим (реєстрація) ---------- */
.auth-card.is-dense { --ctl-h: 46px; --field-gap: 11px; }
.auth-card.is-dense .auth-head { margin-bottom: 14px; }
.auth-card.is-dense .auth-head h1 { font-size: 30px; }
.auth-card.is-dense .auth-sub { margin-top: 5px; font-size: 13px; }
.auth-card.is-dense .btn-primary { margin-top: 4px; }
.auth-card.is-dense .notice { margin-bottom: 10px; padding: 9px 12px; }
.auth-card.is-dense .auth-alt { margin-top: 12px; padding-top: 10px; }
.auth-card.is-dense .field label, .auth-card.is-dense .field-label { margin-bottom: 4px; }
.auth-card.is-dense .field-hint { margin-top: 4px; min-height: 0; }

@media (prefers-reduced-motion: reduce) {
    .auth-card { animation: none; }
    .btn-primary, .input-field, .phone-ctl, .flow-progress i { transition: none; }
}

/* Вхід на телефоні: форма стоїть ВИЩЕ (не по центру), щоб екранна клавіатура її не перекривала і сторінка не «підстрибувала» */
@media (max-width: 700px) {
    .page-login .auth-main { justify-content: flex-start; min-height: 0; padding: 10px 0 max(240px, env(safe-area-inset-bottom)); }
    .page-login .auth-card { padding: 16px 16px 12px; animation: none; }
    .page-login .auth-head { margin-bottom: 8px; }
    .page-login .auth-kicker, .page-login .auth-sub { display: none; }
    .page-login .auth-head h1 { font-size: 28px; margin: 0; }
    .page-login .auth-card { --ctl-h: 46px; --field-gap: 10px; }
}
