/* =========================================================
   БАЗА
   ========================================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --grad-start: #667eea;
    --grad-end:   #764ba2;
    --text:       #1a1a2e;
    --text-muted: #6b7280;
    --border:     #e5e7eb;
}

html { height: 100%; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* =========================================================
   ФОРМА (главная страница)
   ========================================================= */
body.form-page {
    background: linear-gradient(135deg, var(--grad-start) 0%, var(--grad-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-height: 100vh;
}

.container {
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
    padding: 40px;
    width: 100%;
    max-width: 640px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    letter-spacing: -0.01em;
}

.brand-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.form-group input[type="url"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 0.95rem;
    background: #fafafa;
    font-family: inherit;
    transition: border-color .2s, box-shadow .2s, background .2s;
}

.form-group input[type="url"]:focus {
    outline: none;
    border-color: var(--grad-start);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, .15);
    background: #fff;
}

.input-hint {
    display: block;
    font-size: .8rem;
    margin-top: 6px;
    min-height: 1em;
}
.input-hint.valid { color: #10b981; }
.input-hint.invalid { color: #ef4444; }

.submit-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: transform .2s, box-shadow .2s, opacity .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, .4);
}

.submit-btn:disabled { opacity: .7; cursor: not-allowed; }

.btn-spinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.btn-spinner.hidden { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

.error {
    background: #fef2f2;
    color: #dc2626;
    padding: 14px 18px;
    border-radius: 12px;
    margin-top: 20px;
    font-size: .9rem;
    border: 1px solid #fecaca;
    line-height: 1.4;
}
.error.hidden { display: none; }

.result {
    margin-top: 28px;
    padding: 24px;
    background: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 100%);
    border-radius: 16px;
    border: 2px solid #e0e7ff;
    animation: fadeIn .4s ease;
}
.result.hidden { display: none; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-label {
    font-size: .8rem;
    font-weight: 600;
    color: #4338ca;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 14px;
}

.result-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.result-cover {
    width: 64px; height: 64px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    display: none;
}

.result-meta h3 { font-size: 1rem; color: #111827; line-height: 1.3; }
.result-meta p  { font-size: .85rem; color: var(--text-muted); }

.shortlink-box { display: flex; gap: 8px; margin-bottom: 12px; }

.shortlink-box input {
    flex: 1;
    padding: 12px 14px;
    border: 2px solid #c7d2fe;
    border-radius: 10px;
    font-size: .9rem;
    background: #fff;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    color: #1e1b4b;
    cursor: pointer;
}

.shortlink-box input:focus { outline: none; border-color: var(--grad-start); }

.copy-btn {
    padding: 0 16px;
    border: none;
    background: var(--grad-start);
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    transition: background .2s, transform .15s;
}

.copy-btn:hover { background: #5568d3; transform: scale(1.05); }
.copy-btn:active { transform: scale(.95); }
.copy-btn.copied { background: #10b981; }

.result-actions { display: flex; gap: 10px; }

.action-btn {
    flex: 1;
    padding: 12px 18px;
    border-radius: 10px;
    text-align: center;
    text-decoration: none;
    font-weight: 600;
    font-size: .9rem;
    transition: all .2s;
    display: inline-block;
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
    color: #fff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, .3);
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, .4);
}

.platforms-info {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.platforms-title {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.platforms-badges { display: flex; flex-wrap: wrap; gap: 6px; }

.badge {
    background: #f3f4f6;
    color: #4b5563;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 500;
}

/* =========================================================
   ЛЕНДИНГ СМАРТССЫЛКИ (view.php)
   ========================================================= */

/* Ключевое: НЕ центрируем через justify-content — используем margin:auto
   у .view-content. Иначе при переполнении верх обрезается и не скроллится. */
body.view-page {
    background: #0d0d14;
    color: #fff;
    min-height: 100vh;
    min-height: 100dvh;          /* корректная высота на мобильных */
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    position: relative;
}

.view-bg {
    position: fixed;
    inset: -40px;
    background-size: cover;
    background-position: center;
    filter: blur(60px) saturate(1.5);
    transform: scale(1.15);
    z-index: 0;
    opacity: .7;
    pointer-events: none;
}

.view-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center,
        rgba(13,13,20,.55) 0%,
        rgba(13,13,20,.85) 60%,
        rgba(13,13,20,.97) 100%);
    z-index: 1;
    pointer-events: none;
}

/* margin: auto — вот это даёт правильный скролл */
.view-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 440px;
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.view-card {
    width: 100%;
    padding: 32px 24px 24px;
    background: rgba(24, 24, 34, .65);
    backdrop-filter: blur(40px) saturate(1.8);
    -webkit-backdrop-filter: blur(40px) saturate(1.8);
    border-radius: 28px;
    border: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 30px 80px rgba(0,0,0,.5);
    text-align: center;
    animation: cardIn .5s ease;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(20px) scale(.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes coverIn {
    from { opacity: 0; transform: translateY(12px) scale(.92); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.view-cover-placeholder {
    width: 200px;
    height: 200px;
    margin: 0 auto 26px;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e1e2e, #2a2a3e);
    color: #fff;
}

.view-title {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
    color: #fff;
}

.view-artist {
    font-size: .95rem;
    color: rgba(255,255,255,.6);
    margin-bottom: 26px;
    font-weight: 500;
}

.view-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.listen-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 14px;
    text-decoration: none;
    color: #fff;
    font-weight: 600;
    font-size: .95rem;
    transition: all .2s ease;
    position: relative;
    overflow: hidden;
}

.listen-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--brand-color);
    opacity: 0;
    transition: opacity .2s ease;
    z-index: 0;
}

.listen-btn:hover {
    border-color: var(--brand-color);
    transform: translateY(-2px);
    box-shadow: 0 12px 30px color-mix(in srgb, var(--brand-color) 40%, transparent);
}

.listen-btn:hover::before { opacity: .12; }

.listen-btn > * { position: relative; z-index: 1; }

.platform-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

.platform-icon img {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 22px;
    height: 22px;
    z-index: 2;
}

.platform-icon-fallback {
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    z-index: 1;
}

.listen-name { flex: 1; text-align: left; }

.listen-action {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: rgba(255,255,255,.5);
    transition: color .2s ease;
}

.listen-btn:hover .listen-action { color: #fff; }

.view-empty {
    color: rgba(255,255,255,.5);
    padding: 20px 0;
    font-size: .9rem;
}

.view-share {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.view-share input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 10px;
    color: rgba(255,255,255,.7);
    font-size: .8rem;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    cursor: pointer;
}

.view-share input:focus { outline: none; border-color: rgba(255,255,255,.3); }

.share-btn {
    padding: 10px 16px;
    background: rgba(255,255,255,.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 10px;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, opacity .2s;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}

.share-btn:hover:not(:disabled) { background: rgba(255,255,255,.18); }
.share-btn:disabled { opacity: .6; cursor: default; }

.qr-toggle-btn {
    width: 100%;
    margin-top: 12px;
    padding: 11px 16px;
    background: transparent;
    color: rgba(255,255,255,.7);
    border: 1px dashed rgba(255,255,255,.15);
    border-radius: 10px;
    font-size: .85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all .2s ease;
}

.qr-toggle-btn:hover {
    color: #fff;
    border-color: rgba(255,255,255,.4);
    background: rgba(255,255,255,.04);
}

.qr-toggle-btn svg { flex-shrink: 0; }

.qr-panel {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    transition: max-height .3s ease, opacity .25s ease, margin-top .25s ease;
}

.qr-panel.open {
    max-height: 400px;
    opacity: 1;
    margin-top: 16px;
}

.qr-frame {
    display: inline-block;
    padding: 16px;
    background: #fff;
    border-radius: 16px;
    box-shadow:
        0 12px 40px rgba(0,0,0,.4),
        0 0 0 1px rgba(255,255,255,.1);
    margin: 0 auto;
    line-height: 0;
    animation: qrIn .35s ease;
}

@keyframes qrIn {
    from { transform: scale(.9); opacity: 0; }
    to   { transform: scale(1);  opacity: 1; }
}

.qr-hint {
    margin-top: 12px;
    font-size: .78rem;
    color: rgba(255,255,255,.5);
    line-height: 1.4;
}

.view-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: .85rem;
    color: rgba(255,255,255,.4);
    text-decoration: none;
    font-weight: 600;
    transition: color .2s;
}

.view-brand:hover { color: rgba(255,255,255,.8); }

.view-brand .brand-dot {
    width: 6px; height: 6px;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(255,255,255,.1);
}

.not-found {
    text-align: center;
    padding: 40px;
    color: #fff;
    margin: auto;
}
.not-found h1 {
    font-size: 4rem;
    background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}
.not-found p {
    color: rgba(255,255,255,.6);
    margin-bottom: 24px;
}

/* =========================================================
   АДАПТИВНОСТЬ
   ========================================================= */
@media (max-width: 600px) {
    .container { padding: 24px; border-radius: 16px; }
    h1 { font-size: 1.6rem; }

    .shortlink-box { flex-direction: column; }
    .copy-btn { padding: 12px; }

    body.view-page {
        padding: 12px;
        padding-top: max(12px, env(safe-area-inset-top));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .view-content { gap: 16px; }

    .view-card { padding: 24px 18px 18px; border-radius: 22px; }

    .view-title { font-size: 1.15rem; }

    .listen-btn { padding: 10px 12px; gap: 12px; font-size: .9rem; }
    .platform-icon { width: 36px; height: 36px; border-radius: 9px; }
    .platform-icon img { width: 20px; height: 20px; }
    .listen-action { display: none; }

    .view-share { flex-direction: column; }
    .share-btn { padding: 11px 16px; }

    .qr-frame { padding: 12px; }
    .qr-frame img { width: 180px; height: 180px; }
}
.platform-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

.platform-icon img {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 22px;
    height: 22px;
    z-index: 2;
    /* Делаем иконку белой (SVG из Simple Icons чёрные по умолчанию) */
    filter: brightness(0) invert(1);
}

.platform-icon-fallback {
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    z-index: 1;
}