:root {
    --color-bg: #f6f7fb;
    --color-surface: #ffffff;
    --color-border: #e1e3ea;
    --color-text: #1a1a1a;
    --color-text-secondary: #5a5a66;
    --color-primary: #1676d3;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 1rem;
}

.app-header-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    color: inherit;
    text-decoration: none;
}

.lang-switch {
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
}

.lang-switch:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.app-logo {
    height: 28px;
    width: 28px;
    border-radius: min(40%, 8px);
}

.app-name {
    font-size: 1.15rem;
    font-weight: 600;
}

/* Layout */
.app-layout {
    display: flex;
    flex: 1;
    align-items: flex-start;
}

.app-nav {
    width: 200px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem 0.5rem;
}

.nav-search {
    width: 100%;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.nav-categories {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-category {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
}

.nav-category-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.45rem 0.6rem;
    background: none;
    border: none;
    font: inherit;
    color: var(--color-text);
    cursor: pointer;
    text-align: left;
}

.nav-category-toggle::-webkit-details-marker {
    display: none;
}

.nav-category-toggle::after {
    content: '';
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.15s;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.nav-category[open] > .nav-category-toggle::after {
    transform: rotate(-135deg);
}

.nav-tools-list {
    list-style: none;
    margin: 0;
    padding: 0 0 0.25rem 0.5rem;
}

.nav-tools-list .nav-link {
    padding: 0.35rem 0.5rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 6px;
    color: var(--color-text);
    text-decoration: none;
}

.nav-tools-list .nav-link:hover {
    background: var(--color-bg);
}

.nav-tools-list .nav-link.active {
    background: var(--color-primary);
    color: #fff;
}

.nav-tools-list .nav-icon {
    width: 18px;
    height: 18px;
}

.nav-category[hidden],
.nav-tools-list li[hidden] {
    display: none;
}

.app-main {
    flex: 1;
    min-width: 0;
    padding: 1.5rem 1rem;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
}

.page-content {
    margin: 0 auto;
}

/* Dashboard */
.dashboard-header {
    margin: 0 0 1rem;
    font-size: 1.6rem;
    font-weight: 600;
}

.dashboard-intro {
    max-width: 760px;
    line-height: 1.6;
    margin-bottom: 1.75rem;
}

.dashboard-intro h1 {
    margin: 0 0 0.75rem;
    font-size: 1.6rem;
    font-weight: 600;
}

.dashboard-intro h2 {
    margin: 1.25rem 0 0.5rem;
    font-size: 1.15rem;
    font-weight: 600;
}

.dashboard-intro p {
    margin: 0.5rem 0;
}

.dashboard-intro ul {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.dashboard-intro li {
    margin-bottom: 0.35rem;
}

.dashboard-intro a {
    color: var(--color-primary);
}

.dashboard-controls {
    margin-bottom: 1rem;
}

.dashboard-search {
    width: min(100%, 400px);
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 1rem;
}

.dashboard-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.dashboard-category {
    text-transform: capitalize;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    cursor: pointer;
}

.dashboard-category.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.dashboard-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
}

.dashboard-card:hover {
    border-color: var(--color-primary);
}

.dashboard-card[hidden] {
    display: none;
}

.dashboard-card-icon {
    width: 24px;
    height: 24px;
}

.dashboard-card-title {
    font-weight: 600;
}

.dashboard-card-category {
    color: var(--color-text-secondary);
    font-size: 0.85rem;
}

.dashboard-empty {
    color: var(--color-text-secondary);
}

/* Tool page */
.tool-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.tool-main {
    flex: 1;
    min-width: 0;
}

.tool-description {
    margin-top: 1.5rem;
    line-height: 1.6;
}

.tool-description li {
    margin-bottom: 0.25rem;
}

.ad-container {
    width: 150px;
    flex-shrink: 0;
}

.ad-label {
    display: block;
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
}

.ad-slot {
    width: 100%;
}

/* Legal */
.legal {
    line-height: 1.6;
    max-width: 800px;
}

/* Footer */
.app-footer {
    padding: 1rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.footer-links {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.footer-link {
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
}

.footer-link:hover {
    text-decoration: underline;
}

.footer-separator {
    color: var(--color-text-secondary);
}

@media (max-width: 720px) {
    .app-layout {
        flex-direction: column;
    }

    .app-nav {
        width: 100%;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 0.5rem;
        border-bottom: 1px solid var(--color-border);
    }

    .app-main {
        border-left: none;
    }

    .tool-layout {
        flex-direction: column;
    }

    .ad-container {
        width: 100%;
    }
}
/* Fallback text inside a tool's custom element. Hidden while the component
   script loads (it replaces the content with its shadow root); revealed after
   a few seconds only if the component never initialised. */
.tool-fallback {
    visibility: hidden;
    margin: 2rem auto;
    max-width: 720px;
    padding: 1rem;
    border: 1px solid #e0b64b;
    border-radius: 8px;
    background: #fff8e1;
    color: #6b5313;
    animation: tool-fallback-reveal 0s linear 3s forwards;
}

@keyframes tool-fallback-reveal {
    to {
        visibility: visible;
    }
}
