:root {
    --bg: #f7f9fd;
    --text: #122033;
    --ink: #122033;
    --text-muted: #36445a;
    --line: #d8e0ec;
    --panel: #ffffff;
    --soft: #eef3f9;
    --blue: #164db8;
    --blue-hover: #0c3e99;
    --red: #b91c1c;
    --green: #087a59;
    --yellow: #8f5f00;
    --text-inverse: #ffffff;
    --text-inverse-muted: #d8e2f2;
    --status-success-text: #055c3e;
    --status-warning-text: #6f4700;
    --status-danger-text: #8f161d;
    --pink: #e4559a;
    --rail-bg: #f3f6fb;
    --shadow: rgba(16, 24, 40, 0.08);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --border-radius: 12px;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --text: #e5eefb;
    --ink: #e5eefb;
    --text-muted: #c7d2e6;
    --line: #2b3a52;
    --panel: #152238;
    --soft: #1e2c43;
    --blue: #8fb2ff;
    --blue-hover: #b5caff;
    --red: #ff9aa2;
    --green: #7de4bd;
    --yellow: #ffd779;
    --text-inverse: #ffffff;
    --text-inverse-muted: #d8e2f2;
    --status-success-text: #a4f0d1;
    --status-warning-text: #ffe2a1;
    --status-danger-text: #ffc2c7;
    --pink: #f08fc0;
    --rail-bg: #0f172a;
    --shadow: rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

body.amani-theme {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, #eef4ff 0%, #f7f9fd 34%, #ffffff 100%);
    color: var(--text);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.amani-theme a {
    color: var(--blue);
}

body.amani-theme button,
body.amani-theme input,
body.amani-theme select,
body.amani-theme textarea {
    font: inherit;
}

body.amani-theme button {
    cursor: pointer;
}

img.amani-brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transform: scale(1.12);
  transform-origin: center;
}

.amani-surface {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--border-radius);
    box-shadow: 0 16px 40px var(--shadow);
}

.amani-button,
.amani-button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.amani-button {
    background: var(--blue);
    color: #fff;
}

.amani-button:hover {
    background: var(--blue-hover);
}

.amani-button-secondary {
    background: var(--soft);
    color: var(--text);
    border-color: var(--line);
}

.amani-button-secondary:hover {
    background: var(--panel);
}

.amani-icon-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    color: var(--text);
    display: inline-grid;
    place-items: center;
    box-shadow: 0 10px 24px var(--shadow);
}

.amani-icon-btn:hover {
    background: var(--soft);
}

/* ── Launcher toggle button ─────────────────────────────────────────────── */

.amani-launcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.amani-launcher-toggle {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    display: inline-grid;
    place-items: center;
    box-shadow: 0 10px 24px var(--shadow);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.amani-launcher-toggle:hover {
    background: var(--soft);
}

.amani-launcher-toggle.is-open {
    background: var(--soft);
    border-color: var(--blue);
    color: var(--blue);
}

.amani-launcher-icons {
    position: relative;
    width: 24px;
    height: 24px;
    display: inline-grid;
    place-items: center;
}

.amani-launcher-icons i {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 24px;
    line-height: 1;
    transition: opacity 0.15s;
}

.amani-launcher-icons .amani-launcher-icon-fill {
    opacity: 0;
}

.amani-launcher-toggle.is-open .amani-launcher-icon-line {
    opacity: 0;
}

.amani-launcher-toggle.is-open .amani-launcher-icon-fill {
    opacity: 1;
}

/* ── Dialog / Modal ─────────────────────────────────────────────────────── */

dialog.amani-launcher-panel {
    border: none;
    padding: 0;
    width: min(780px, calc(100vw - 24px));
    max-height: min(80vh, 820px);
    margin: auto;
    border-radius: 20px;
    background:
        radial-gradient(circle at top right, rgba(47, 109, 246, 0.10), transparent 40%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(247, 249, 253, 0.99));
    box-shadow: 0 32px 80px rgba(15, 23, 42, 0.26), 0 0 0 1px var(--line);
    overflow: hidden;
    animation: launcher-modal-in 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

dialog.amani-launcher-panel:not([open]) {
    display: none !important;
}

dialog.amani-launcher-panel[open] {
    display: flex;
    flex-direction: column;
}

dialog.amani-launcher-panel::backdrop {
    background: rgba(10, 18, 36, 0.48);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: launcher-backdrop-in 200ms ease;
}

.amani-launcher-inner {
    overflow-y: auto;
    padding: 18px;
    flex: 1;
    overscroll-behavior: contain;
}

@keyframes launcher-modal-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes launcher-backdrop-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Panel head ─────────────────────────────────────────────────────────── */

.amani-launcher-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 14px;
}

.amani-launcher-panel-copy {
    display: grid;
    gap: 2px;
}

.amani-launcher-kicker {
    color: var(--blue);
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.amani-launcher-panel-copy strong {
    font-size: 20px;
    line-height: 1.1;
    color: var(--text);
    font-family: var(--font-heading);
}

.amani-launcher-panel-copy span {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.4;
}

/* ── Search ─────────────────────────────────────────────────────────────── */

.amani-launcher-search {
    position: relative;
    margin-bottom: 12px;
}

.amani-launcher-search i {
    position: absolute;
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
}

.amani-launcher-search input {
    width: 100%;
    padding: 11px 14px 11px 40px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.amani-launcher-search input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent);
}

/* ── Spotlight cards ────────────────────────────────────────────────────── */

.amani-launcher-spotlight {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.amani-launcher-spotlight-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--panel) 82%, var(--soft));
    padding: 12px 14px;
    display: grid;
    gap: 4px;
}

.amani-launcher-spotlight-card span {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.amani-launcher-spotlight-card strong {
    color: var(--text);
    font-size: 15px;
    line-height: 1.2;
}

/* ── App grid ───────────────────────────────────────────────────────────── */

.amani-launcher-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.amani-launcher-item {
    min-height: 100px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    text-decoration: none;
    color: var(--text);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 248, 255, 0.98));
    display: grid;
    gap: 8px;
    align-content: start;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.amani-launcher-item:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--blue) 38%, var(--line));
    box-shadow: 0 10px 24px rgba(47, 109, 246, 0.12);
}

.amani-launcher-item.is-active {
    border-color: var(--blue);
    background: linear-gradient(180deg, rgba(240, 246, 255, 0.98), rgba(230, 241, 255, 0.98));
    box-shadow: 0 0 0 1px rgba(47, 109, 246, 0.12);
}

.amani-launcher-item-icon {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: #eaf1ff;
    color: var(--blue);
    font-size: 18px;
    overflow: hidden;
}

.amani-launcher-item-icon i {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    line-height: 1;
    font-style: normal;
}

.amani-launcher-item strong {
    display: block;
    margin: 0;
    font-size: 14px;
    line-height: 1.2;
}

.amani-launcher-item span {
    display: block;
    color: var(--text-muted);
    font-size: 11.5px;
    line-height: 1.4;
}

/* ── Empty state ────────────────────────────────────────────────────────── */

.amani-launcher-empty {
    grid-column: 1 / -1;
    border: 1px dashed var(--line);
    border-radius: 14px;
    background: var(--soft);
    color: var(--text-muted);
    padding: 18px;
    display: grid;
    justify-items: center;
    gap: 8px;
    text-align: center;
}

.amani-launcher-empty i {
    font-size: 28px;
    color: var(--blue);
}

.amani-launcher-empty strong {
    color: var(--text);
    font-size: 15px;
}

.amani-launcher-empty span {
    font-size: 12px;
}

/* ── Close button ───────────────────────────────────────────────────────── */

.amani-launcher-close {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--soft);
    color: var(--text);
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    cursor: pointer;
}

.amani-launcher-close:hover {
    background: var(--panel);
}

/* ── Contrast-safe final layer ─────────────────────────────────────────── */

body.amani-theme,
.amani-surface,
.amani-launcher-item,
.amani-launcher-spotlight-card {
    color: var(--text);
}

body.amani-theme input,
body.amani-theme select,
body.amani-theme textarea {
    background: var(--panel);
    color: var(--text);
    border-color: var(--line);
}

body.amani-theme input::placeholder,
body.amani-theme textarea::placeholder,
.amani-launcher-item span,
.amani-launcher-spotlight-card span,
.amani-launcher-empty,
.amani-page-subtle,
.muted {
    color: var(--text-muted);
    opacity: 1;
}

.amani-button,
body.amani-theme button[type="submit"] {
    background: var(--blue);
    color: #ffffff;
    border-color: var(--blue);
}

.amani-button:hover,
body.amani-theme button[type="submit"]:hover {
    background: var(--blue-hover);
    color: #ffffff;
}

.success,
.status-success,
.badge-success { color: var(--status-success-text); }
.warning,
.status-warning,
.badge-warning { color: var(--status-warning-text); }
.error,
.danger,
.status-danger,
.badge-danger { color: var(--status-danger-text); }

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    dialog.amani-launcher-panel {
        width: min(640px, calc(100vw - 16px));
    }

    .amani-launcher-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    dialog.amani-launcher-panel {
        width: calc(100vw - 16px);
        max-height: calc(100dvh - 32px);
        margin: auto 8px 8px;
        border-radius: 18px 18px 14px 14px;
    }

    .amani-launcher-grid {
        grid-template-columns: 1fr 1fr;
    }

    .amani-launcher-spotlight {
        grid-template-columns: 1fr;
    }
}
