/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* === Accessibility === */
.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    background: var(--accent);
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 999;
    text-decoration: none;
}
.skip-link:focus { top: 8px; }
*:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}

:root {
    --bg:        #1a1a2e;
    --surface:   #16213e;
    --surface2:  #0f3460;
    --accent:    #e94560;
    --accent2:   #533483;
    --text:      #eee;
    --text-dim:  #8892b0;
    --green:     #64ffda;
    --yellow:    #ffd369;
    --radius:    8px;
    --mono:      "SF Mono", "Fira Code", "Cascadia Code", Menlo, monospace;
}

/* === Light Theme === */
[data-theme="light"] {
    --bg:        #f5f5f7;
    --surface:   #ffffff;
    --surface2:  #e5e5ea;
    --accent:    #0071e3;
    --accent2:   #7c3aed;
    --text:      #1d1d1f;
    --text-dim:  #6e6e73;
    --green:     #059669;
    --yellow:    #b45309;
}
[data-theme="light"] .radio-pill:checked + label {
    background: rgba(0, 113, 227, 0.1);
    color: #0071e3;
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg:        #f5f5f7;
        --surface:   #ffffff;
        --surface2:  #e5e5ea;
        --accent:    #0071e3;
        --accent2:   #7c3aed;
        --text:      #1d1d1f;
        --text-dim:  #6e6e73;
        --green:     #059669;
        --yellow:    #b45309;
    }
    :root:not([data-theme="dark"]) .radio-pill:checked + label {
        background: rgba(0, 113, 227, 0.1);
        color: #0071e3;
    }
}

/* === Theme Toggle === */
.theme-toggle {
    margin-left: auto;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.theme-toggle:hover {
    color: var(--yellow);
    background: rgba(128, 128, 128, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.app {
    width: 100%;
    max-width: 1200px;
    padding: 60px 20px 60px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* === Site Nav === */
.site-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 44px;
    background: var(--surface);
    border-bottom: 1px solid var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.site-nav-inner {
    width: 100%;
    max-width: 1200px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.nav-brand {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.nav-brand:hover {
    color: var(--green);
    background: rgba(100, 255, 218, 0.08);
}
.nav-links {
    display: flex;
    gap: 6px;
    list-style: none;
}
.nav-links a {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-dim);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.nav-links a:hover {
    color: var(--text);
    background: var(--surface2);
}
.nav-links a.active {
    color: var(--green);
    background: rgba(100, 255, 218, 0.08);
}

/* === Hamburger Menu === */
.nav-hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
    transition: background 0.15s;
}
.nav-hamburger:hover {
    background: var(--surface2);
}

@media (max-width: 768px) {
    .nav-hamburger {
        display: block;
    }
    .nav-links {
        display: none;
        position: absolute;
        top: 44px;
        left: 0;
        right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--surface2);
        flex-direction: column;
        padding: 8px 20px 12px;
        gap: 2px;
        z-index: 199;
    }
    .nav-links.open {
        display: flex;
    }
    .nav-links a {
        display: block;
        padding: 8px 10px;
        font-size: 0.82rem;
    }
}

/* === Header === */
.header {
    text-align: center;
    padding: 20px 0 8px;
}
.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.version {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-family: var(--mono);
}
.beta-badge {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--yellow);
    color: var(--bg);
    padding: 2px 8px;
    border-radius: 10px;
    vertical-align: middle;
    position: relative;
    top: -2px;
}
.badge {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 2px 8px;
    border-radius: 10px;
    vertical-align: middle;
    position: relative;
    top: -2px;
}
.badge-beta {
    background: var(--yellow);
    color: var(--bg);
}
.badge-alpha {
    background: var(--accent);
    color: #fff;
}
.header-sub {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-top: 6px;
}

/* === Configurator Layout === */
.configurator {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    min-height: 400px;
}
.config-columns {
    display: flex;
    gap: 24px;
}
.config-form {
    flex: 1;
    min-width: 0;
}
.config-output {
    width: 420px;
    flex-shrink: 0;
    position: sticky;
    top: 68px;
    align-self: flex-start;
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
}
.preview-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--green);
}
.output-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.output-actions {
    display: flex;
    gap: 6px;
}
.btn-action {
    background: var(--accent);
    border: none;
    border-radius: 6px;
    color: #fff;
    padding: 5px 14px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.75rem;
    transition: opacity 0.15s;
}
.btn-action:hover { opacity: 0.85; }
.btn-download {
    background: var(--green);
    color: var(--bg);
}
.xml-output {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 12px;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--text-dim);
    overflow: auto;
    line-height: 1.6;
    white-space: pre;
    flex: 1;
    min-height: 300px;
    max-height: calc(100vh - 180px);
}
.xml-output .xml-tag { color: var(--text-dim); }
.xml-output .xml-key { color: var(--green); }
.xml-output .xml-val { color: var(--yellow); }
.xml-output .xml-comment { color: var(--accent2); opacity: 0.7; }

.copy-toast {
    position: absolute;
    top: -30px;
    right: 20px;
    background: var(--green);
    color: var(--bg);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.copy-toast.show { opacity: 1; }

/* === Form Elements === */
.form-section {
    margin-bottom: 16px;
}
.form-section:last-child { margin-bottom: 0; }
.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.radio-pill { display: none; }
.radio-pill + label {
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    white-space: nowrap;
}
.radio-pill + label:hover { border-color: var(--accent); }
.radio-pill:checked + label {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.15);
    color: #fff;
}

.text-input, textarea.text-input, select.text-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--surface2);
    border-radius: var(--radius);
    padding: 8px 12px;
    color: var(--text);
    font-size: 0.85rem;
    font-family: var(--mono);
    outline: none;
    transition: border-color 0.15s;
}
textarea.text-input {
    resize: vertical;
    min-height: 50px;
    line-height: 1.5;
}
select.text-input {
    cursor: pointer;
    appearance: auto;
}
.text-input:focus, textarea.text-input:focus, select.text-input:focus {
    border-color: var(--accent);
}
.text-input:focus-visible, textarea.text-input:focus-visible, select.text-input:focus-visible {
    outline: none;
}
.text-input::placeholder, textarea.text-input::placeholder {
    color: var(--text-dim);
    opacity: 0.6;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.checkbox-row input[type="checkbox"] {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
}
.checkbox-row label {
    font-size: 0.84rem;
    cursor: pointer;
}

.hint {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 4px;
}
.warning {
    font-size: 0.75rem;
    color: var(--accent);
    margin-top: 4px;
    font-weight: 500;
}

.form-divider {
    border: none;
    border-top: 1px solid var(--surface2);
    margin: 12px 0;
}

/* === App Entry Cards === */
.app-entry {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 10px;
    border: 1px solid var(--surface2);
}
.app-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.app-entry-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--green);
    font-family: var(--mono);
}
.app-entry-controls {
    display: flex;
    gap: 4px;
}
.btn-icon {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.btn-icon:hover {
    color: var(--accent);
    background: rgba(233, 69, 96, 0.1);
}

/* === Service Rows === */
.service-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.service-row {
    background: var(--surface);
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.service-row-top {
    display: flex;
    gap: 8px;
    align-items: center;
}
.service-row-top select {
    flex: 1;
    max-width: 220px;
}
.service-row-top .radio-group {
    flex: 1;
}
.service-row-top .btn-icon {
    flex-shrink: 0;
}
.ae-fields {
    padding: 8px 0 0;
    border-top: 1px solid var(--surface2);
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ae-fields .form-label {
    font-size: 0.7rem;
    margin-bottom: 4px;
}

/* === Add Buttons === */
.btn-add {
    background: var(--surface2);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: var(--text);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.82rem;
    white-space: nowrap;
    transition: background 0.15s;
    margin-top: 8px;
}
.btn-add:hover {
    background: rgba(233, 69, 96, 0.2);
}

/* === Breadcrumb === */
.breadcrumb {
    font-size: 0.78rem;
    color: var(--text-dim);
    padding: 8px 0 0;
}
.breadcrumb a {
    color: var(--green);
    text-decoration: none;
}
.breadcrumb a:hover {
    text-decoration: underline;
}

/* === Related Tools === */
.related-tools {
    font-size: 0.82rem;
    color: var(--text-dim);
    text-align: center;
    padding: 16px;
    margin-top: 8px;
}
.related-tools a {
    color: var(--green);
    text-decoration: none;
}
.related-tools a:hover {
    text-decoration: underline;
}

/* === Site Footer === */
.site-footer {
    text-align: center;
    padding: 24px 16px;
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.7;
    border-top: 1px solid var(--surface2);
    margin-top: 8px;
}
.footer-copy {
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--text-dim);
    opacity: 0.7;
}

/* === Changelog === */
.changelog {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--surface2);
    margin-top: 8px;
}
.changelog summary {
    padding: 12px 16px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    cursor: pointer;
    list-style: none;
}
.changelog summary::-webkit-details-marker { display: none; }
.changelog summary::before {
    content: "\25B6";
    display: inline-block;
    margin-right: 8px;
    font-size: 0.6rem;
    transition: transform 0.15s;
}
.changelog[open] summary::before { transform: rotate(90deg); }
.changelog-content {
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.changelog-entry h3 {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--green);
    font-family: var(--mono);
    margin-bottom: 4px;
}
.changelog-entry ul {
    list-style: disc;
    padding-left: 20px;
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.7;
}

/* === Responsive === */
@media (max-width: 800px) {
    .config-columns { flex-direction: column; }
    .config-output {
        width: 100%;
        position: static;
        order: -1;
        margin-bottom: 16px;
        max-height: none;
    }
    .xml-output { max-height: 250px; min-height: 150px; }
}
@media (max-width: 500px) {
    .app { padding: 56px 10px 40px; }
    .xml-output { font-size: 0.65rem; }
}

/* === Shareable Link Box === */
.share-link-box {
    margin: 16px auto 12px;
    max-width: 760px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--surface2);
    border-radius: 10px;
}
.share-link-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 6px;
}
.share-link-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.share-link-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--surface2);
    border-radius: 6px;
    color: var(--text);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.78rem;
    padding: 6px 10px;
    outline: none;
    overflow: hidden;
    text-overflow: ellipsis;
}
.share-link-input:focus {
    border-color: var(--accent);
}
.share-link-copy {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s;
}
.share-link-copy:hover {
    opacity: 0.85;
}
