/**
 * Z5 Unlimited — Live Manifest (matches z5-unlimited.com tokens & cards)
 */

:root {
    --z5-bg-void: #090d18;
    --z5-bg-deep: #0c1220;
    --z5-bg-elevated: #111728;
    --z5-green-500: #37d39a;
    --z5-green-400: #6de8b4;
    --z5-cyan-400: #65d8ff;
    --z5-success: #37d39a;
    --z5-warning: #f7ba53;
    --z5-danger: #f88383;
    --z5-text-primary: #eaf2ff;
    --z5-text-secondary: rgba(234, 242, 255, 0.72);
    --z5-text-muted: #7a96bc;
    --z5-border-subtle: #1e2d47;
    --z5-border-default: #27324d;
    --z5-border-glow: rgba(55, 211, 154, 0.45);
    --z5-gradient-text: linear-gradient(120deg, #6de8b4 0%, #65d8ff 100%);
    --z5-gradient-primary: linear-gradient(135deg, #37d39a 0%, #27a87a 100%);
    --z5-font-sans: 'Inter', system-ui, sans-serif;
    --z5-font-mono: Consolas, 'Cascadia Mono', monospace;
    --z5-sidebar-width: 260px;
    --z5-space-3: 0.75rem;
    --z5-space-4: 1rem;
    --z5-space-6: 1.5rem;
    --z5-space-8: 2rem;
    --z5-radius-md: 12px;
    --z5-radius-sm: 8px;
    --z5-glass-blur-heavy: 24px;
    --z5-scrollbar-thumb: rgba(55, 211, 154, 0.22);
    --z5-scrollbar-thumb-hover: rgba(55, 211, 154, 0.42);
    --z5-scrollbar-thumb-active: rgba(101, 216, 255, 0.45);
    --z5-scrollbar-track: transparent;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scrollbar-width: thin;
    scrollbar-color: var(--z5-scrollbar-thumb-hover) var(--z5-scrollbar-track);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--z5-scrollbar-thumb-hover) var(--z5-scrollbar-track);
}

*::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

*::-webkit-scrollbar-track {
    background: var(--z5-scrollbar-track);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
    background: var(--z5-scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: background 0.15s ease;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--z5-scrollbar-thumb-hover);
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:active {
    background: var(--z5-scrollbar-thumb-active);
    background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
    background: var(--z5-scrollbar-track);
}

body.z5-app {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--z5-font-sans);
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--z5-text-primary);
    background: var(--z5-bg-void);
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid rgba(101, 216, 255, 0.55);
    outline-offset: 2px;
}

/* Background scene */
.z5-app-scene {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.z5-app-scene__base {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 10% 10%, rgba(60, 100, 200, 0.14) 0%, transparent 65%),
        radial-gradient(ellipse 50% 60% at 90% 85%, rgba(80, 40, 180, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse 40% 40% at 75% 15%, rgba(40, 130, 170, 0.07) 0%, transparent 55%),
        linear-gradient(165deg, var(--z5-bg-void) 0%, var(--z5-bg-deep) 50%, var(--z5-bg-elevated) 100%);
}

.z5-app-scene__noise {
    position: absolute;
    inset: 0;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Layout */
.z5-app-layout {
    position: relative;
    z-index: 1;
    display: flex;
    min-height: 100dvh;
}

.z5-app-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 350;
    background: rgba(9, 13, 24, 0.65);
}

.z5-app-overlay.is-open {
    display: block;
}

.z5-app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.z5-app-content {
    flex: 1;
    width: 100%;
    padding: var(--z5-space-6) var(--z5-space-8);
}

.z5-app-menu-toggle {
    display: none;
}

/* Sidebar */
.z5-sidebar {
    display: flex;
    flex-direction: column;
    width: var(--z5-sidebar-width);
    min-height: 100dvh;
    flex-shrink: 0;
    background: rgba(12, 18, 32, 0.94);
    backdrop-filter: blur(var(--z5-glass-blur-heavy));
    -webkit-backdrop-filter: blur(var(--z5-glass-blur-heavy));
    border-right: 1px solid var(--z5-border-subtle);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
}

.z5-sidebar__brand {
    padding: var(--z5-space-6);
    border-bottom: 1px solid var(--z5-border-subtle);
}

.z5-app-brand {
    display: flex;
    align-items: center;
    gap: var(--z5-space-3);
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: -0.025em;
    color: var(--z5-text-primary);
}

.z5-app-brand:hover {
    color: var(--z5-green-400);
}

.z5-app-brand > span {
    color: var(--z5-green-400);
}

.z5-app-brand__mark {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.z5-logo {
    display: block;
    width: 100%;
    height: 100%;
    filter:
        drop-shadow(0 0 6px rgba(255, 255, 255, 0.35))
        drop-shadow(0 0 10px rgba(55, 211, 154, 0.45));
}

.z5-app-brand__sub {
    display: block;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--z5-text-muted);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.z5-sidebar__scroll {
    flex: 1;
    overflow-y: auto;
    padding: var(--z5-space-4);
}

.z5-sidebar__section {
    margin-bottom: var(--z5-space-6);
}

.z5-sidebar__label {
    padding: 0.5rem 1rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--z5-text-muted);
}

.z5-sidebar__item {
    display: flex;
    align-items: center;
    gap: var(--z5-space-3);
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--z5-radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--z5-text-secondary);
    border: 1px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.z5-sidebar__item:hover {
    background: rgba(55, 211, 154, 0.08);
    color: var(--z5-text-primary);
}

.z5-sidebar__item.is-active {
    background: linear-gradient(90deg, rgba(55, 211, 154, 0.15) 0%, transparent 100%);
    color: var(--z5-green-400);
    border-color: rgba(55, 211, 154, 0.12);
    box-shadow: inset 3px 0 0 var(--z5-green-500);
    pointer-events: none;
}

.z5-sidebar__icon {
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    flex-shrink: 0;
    color: inherit;
}

.z5-sidebar__text {
    flex: 1;
    min-width: 0;
}

.z5-sidebar__footer {
    padding: var(--z5-space-4) var(--z5-space-6);
    border-top: 1px solid var(--z5-border-subtle);
}

.z5-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--z5-text-muted);
}

.z5-status-pill__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--z5-success);
    box-shadow: 0 0 8px var(--z5-success);
}

/* w3-mm tool scope (matches Z5 dashboard) */
.w3-mm {
    --bg: #090d18;
    --panel: #111728;
    --line: #1e2d47;
    --text: #eaf2ff;
    --muted: #7a96bc;
    --dim: #3a5070;
    --cyan: #65d8ff;
    --ok: #37d39a;
    --warn: #f7ba53;
    --err: #f88383;
    --radius: 13px;
    --radius-sm: 8px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.w3-mm__page {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.w3-mm .token-hint {
    margin: 0 0 16px;
    padding: 12px 14px;
    font-size: 0.8125rem;
    line-height: 1.55;
    color: var(--muted);
    border-radius: 10px;
    border: 1px solid var(--line);
    border-left: 2px solid rgba(101, 216, 255, 0.45);
    background: rgba(8, 14, 26, 0.55);
}

/* Header bar */
.w3-mm .hdr {
    background: linear-gradient(135deg, #13203a 0%, #0d1828 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 13px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.3);
}

.w3-mm .hdr-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.w3-mm .hdr-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(55, 211, 154, 0.15);
    border: 1px solid rgba(55, 211, 154, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ok);
}

.w3-mm .hdr-z5 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--ok);
    letter-spacing: 0.04em;
}

.w3-mm .hdr-sep {
    color: var(--dim);
    margin: 0 2px;
}

.w3-mm .hdr-title {
    font-size: 0.85rem;
    color: var(--muted);
    letter-spacing: 0.03em;
}

.w3-mm .hdr-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.w3-mm .btn-sm {
    appearance: none;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    padding: 5px 12px;
    font-size: 0.72rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: border-color var(--transition), color var(--transition), background var(--transition), transform var(--transition);
}

.w3-mm .btn-sm:hover {
    border-color: #4d6fa8;
    color: var(--text);
    background: rgba(255, 255, 255, 0.07);
    transform: translateY(-1px);
}

/* Card shell */
.w3-mm .card {
    background: linear-gradient(175deg, #111d32 0%, #0c1424 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    animation: w3CardIn 0.35s ease both;
}

@keyframes w3CardIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.w3-mm .card-head {
    padding: 11px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.02);
}

.w3-mm .card-title {
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--dim);
    display: flex;
    align-items: center;
    gap: 7px;
}

.w3-mm .card-title svg {
    color: #2d4a72;
    opacity: 0.9;
}

.w3-mm .card-badge {
    font-size: 0.72rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(8, 14, 26, 0.55);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.w3-mm .card-badge.has-value {
    color: var(--ok);
    border-color: rgba(55, 211, 154, 0.28);
    background: rgba(55, 211, 154, 0.08);
}

.w3-mm .card-body {
    padding: 16px 18px;
}

.manifest-form {
    margin: 0;
}

.token-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dim);
    margin-bottom: 8px;
}

.token-input {
    width: 100%;
    min-height: 2.75rem;
    max-height: min(40vh, 320px);
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(8, 14, 26, 0.6);
    border-left: 2px solid rgba(55, 211, 154, 0.3);
    color: var(--text);
    font-family: var(--z5-font-mono);
    font-size: 0.78rem;
    line-height: 1.45;
    resize: none;
    overflow-y: hidden;
    field-sizing: content;
    transition: border-color var(--transition), box-shadow var(--transition);
}

@supports not (field-sizing: content) {
    .token-input {
        overflow-y: auto;
    }
}

.token-input::placeholder {
    color: var(--dim);
}

.token-input:focus {
    outline: none;
    border-color: #2a3f60;
    border-left-color: var(--ok);
    box-shadow: 0 0 0 1px rgba(55, 211, 154, 0.15);
}

.manifest-actions {
    margin-top: 12px;
}

.manifest-actions__primary,
.manifest-actions__secondary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.manifest-actions__secondary {
    display: none;
}

.manifest-actions.is-loading .manifest-actions__primary,
.manifest-actions.is-result .manifest-actions__primary {
    display: none;
}

.manifest-actions.is-result .manifest-actions__secondary {
    display: flex;
}

.manifest-actions.is-loading .manifest-actions__secondary {
    display: none;
}

.w3-mm .btn-find {
    min-width: 8.25rem;
    height: 38px;
    padding: 0 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s cubic-bezier(0.34, 1.2, 0.64, 1), box-shadow 0.22s ease;
}

.w3-mm .btn-find--start {
    background: linear-gradient(165deg, #3ee9a8 0%, #22b87d 48%, #1a9a68 100%);
    color: #032116;
    border-color: rgba(62, 233, 168, 0.35);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.15) inset,
        0 4px 16px rgba(34, 184, 125, 0.35);
}

.w3-mm .btn-find--start:hover:not(:disabled) {
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.2) inset,
        0 6px 22px rgba(34, 184, 125, 0.48);
    transform: translateY(-1px);
}

.w3-mm .btn-find:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* Result */
.result {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(8, 14, 26, 0.55);
    display: none;
}

.result.visible {
    display: block;
}

.result.success {
    border-color: rgba(55, 211, 154, 0.28);
    background: rgba(55, 211, 154, 0.06);
}

.result.error {
    border-color: rgba(248, 131, 131, 0.28);
    background: rgba(248, 131, 131, 0.06);
}

.result-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dim);
}

.result.success .result-label {
    color: var(--ok);
}

.result.error .result-label {
    color: var(--err);
}

.manifest-display {
    margin: 8px 0 10px;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    word-break: break-all;
    color: var(--ok);
    font-variant-numeric: tabular-nums;
}

.manifest-display:empty {
    display: none;
}

.result-message {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--muted);
}

.result.error .result-message {
    color: #fecaca;
}

.manifest-json-wrap {
    margin-top: 14px;
}

.manifest-json-wrap[hidden] {
    display: none;
}

.manifest-json-head {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dim);
    margin-bottom: 8px;
}

.manifest-json {
    margin: 0;
    padding: 12px 8px 12px 12px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.1);
    background: transparent;
    font-family: Consolas, "Cascadia Mono", "Segoe UI Mono", monospace;
    font-size: 0.68rem;
    line-height: 1.45;
    color: #c8d6f0;
    overflow: auto;
    max-height: 320px;
    white-space: pre-wrap;
    word-break: break-word;
}

.spinner-wrap {
    display: none;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.78rem;
}

.spinner-wrap.active {
    display: flex;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--line);
    border-top-color: var(--cyan);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 18px;
    border-radius: var(--z5-radius-sm);
    background: rgba(17, 29, 50, 0.95);
    border: 1px solid rgba(55, 211, 154, 0.35);
    color: var(--z5-green-400);
    font-size: 0.88rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Mobile */
@media (max-width: 767px) {
    .z5-app-menu-toggle {
        display: flex;
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 500;
        width: 40px;
        height: 40px;
        align-items: center;
        justify-content: center;
        border-radius: var(--z5-radius-sm);
        border: 1px solid var(--z5-border-subtle);
        background: rgba(12, 18, 32, 0.94);
        color: var(--z5-text-primary);
    }

    .z5-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 400;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .z5-sidebar.is-open {
        transform: translateX(0);
    }

    .z5-app-content {
        padding: 56px 16px 32px;
    }
}
