:root {
    --bg: #0f1419;
    --surface: #1a2332;
    --surface-hover: #243044;
    --accent: #3b82f6;
    --accent-soft: rgba(59, 130, 246, 0.15);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.12);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    --radius: 16px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

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

body {
    margin: 0;
    min-height: 100dvh;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background:
        radial-gradient(ellipse at top, #1e293b 0%, transparent 55%),
        var(--bg);
    color: var(--text);
    padding:
        calc(12px + var(--safe-top))
        16px
        calc(20px + var(--safe-bottom));
}

.app-shell {
    max-width: 480px;
    margin: 0 auto;
}

.app-header {
    text-align: center;
    margin-bottom: 24px;
}

.app-header h1 {
    margin: 0 0 4px;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.app-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 1fr;
    gap: 12px;
}

.app-cell {
    aspect-ratio: 1;
    min-height: 0;
    min-width: 0;
}

.app-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 12px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: inherit;
    text-decoration: none;
    transition: transform 0.15s ease, background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.app-tile--empty {
    pointer-events: none;
    background: rgba(26, 35, 50, 0.45);
    box-shadow: none;
    border-style: dashed;
    border-color: rgba(148, 163, 184, 0.18);
}

.app-tile--empty .icon {
    opacity: 0.15;
    font-size: 1.5rem;
}

.app-tile--empty .label {
    visibility: hidden;
}

.app-tile:active {
    transform: scale(0.96);
    background: var(--surface-hover);
}

.app-tile .icon {
    font-size: 2.25rem;
    line-height: 1;
}

.app-tile .label {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.app-footer {
    margin-top: 28px;
    text-align: center;
}

.app-footer a {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-decoration: none;
}

.app-footer a:active {
    color: var(--accent);
}

.loading,
.error-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-muted);
}

.error-state {
    color: #f87171;
}

@media (min-width: 768px) {
    body {
        padding-top: calc(32px + var(--safe-top));
    }

    .app-shell {
        max-width: 540px;
    }

    .app-tile:hover {
        background: var(--surface-hover);
        transform: translateY(-2px);
    }
}
