/* === 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;
}
[data-theme="light"] .op-btn.active {
    background: rgba(0, 113, 227, 0.06);
}
@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;
    }
    :root:not([data-theme="dark"]) .op-btn.active {
        background: rgba(0, 113, 227, 0.06);
    }
}

/* === 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;
}

/* === 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: 1100px;
    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);
}

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

/* === 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);
}
.header-sub {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-top: 6px;
}
.header-sub a {
    color: var(--green);
    text-decoration: none;
}
.header-sub a:hover {
    text-decoration: underline;
}

/* === Category Nav === */
.op-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}
.op-btn {
    background: var(--surface);
    border: 2px solid transparent;
    border-radius: var(--radius);
    color: var(--text);
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: border-color 0.15s, background 0.15s;
    min-width: 70px;
}
.op-btn:hover {
    background: var(--surface2);
}
.op-btn.active {
    border-color: var(--accent);
    background: var(--surface2);
}
.op-icon {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1;
}
.op-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* === 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-preview {
    width: 340px;
    flex-shrink: 0;
    position: sticky;
    top: 24px;
    align-self: flex-start;
}
.preview-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--green);
    margin-bottom: 10px;
}

/* === Category Sections (Accordion) === */
.cat-section {
    border-top: 1px solid var(--surface2);
    padding-top: 16px;
    margin-bottom: 16px;
}
.cat-section:first-child {
    border-top: none;
    padding-top: 0;
}
.cat-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 4px 0 12px;
    user-select: none;
}
.cat-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}
.cat-badge {
    font-size: 0.7rem;
    font-family: var(--mono);
    color: var(--green);
    background: rgba(100, 255, 218, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 10px;
}
.cat-toggle {
    font-size: 0.8rem;
    color: var(--text-dim);
    transition: transform 0.2s;
}
.cat-section.collapsed .cat-toggle {
    transform: rotate(-90deg);
}
.cat-section-body {
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.cat-section.collapsed .cat-section-body {
    max-height: 0 !important;
    overflow: hidden;
}

/* === 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 {
    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: 60px;
    line-height: 1.5;
}
.text-input:focus, textarea.text-input:focus {
    border-color: var(--accent);
}
.text-input:focus-visible, textarea.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;
}

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

/* === Dynamic List (add/remove items) === */
.dynamic-list {
    list-style: none;
    margin: 6px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.dynamic-item {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.dynamic-item-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.dynamic-item-row .text-input {
    flex: 1;
}
.dynamic-item .remove-item {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
}
.dynamic-item .checkbox-row {
    margin-top: 0;
}
.dynamic-item .checkbox-row label {
    font-size: 0.78rem;
}
.dynamic-modifiers {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}
.btn-add {
    background: var(--surface2);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: var(--text);
    padding: 6px 14px;
    cursor: pointer;
    font-size: 0.82rem;
    white-space: nowrap;
    transition: background 0.15s;
    margin-top: 6px;
}
.btn-add:hover {
    background: rgba(233, 69, 96, 0.2);
}

/* === Mock Dialog Preview === */
.dialog-preview {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    transition: background 0.2s;
}
.dialog-preview[data-appearance="light"] {
    background: #f0f0f0;
    color: #1d1d1f;
}
.dialog-preview[data-appearance="dark"] {
    background: #2d2d2d;
    color: #f5f5f7;
}
.dialog-titlebar {
    height: 28px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
}
.dialog-preview[data-appearance="light"] .dialog-titlebar {
    background: #e0e0e0;
}
.dialog-preview[data-appearance="dark"] .dialog-titlebar {
    background: #3a3a3a;
}
.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.dot.red { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green { background: #28c840; }

.dialog-banner-area {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.8);
    background: var(--accent2);
    overflow: hidden;
}
.dialog-body {
    padding: 16px;
    display: flex;
    gap: 14px;
}
.dialog-body.centered {
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.dialog-icon-area {
    flex-shrink: 0;
}
.dialog-icon {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    background: var(--accent2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: rgba(255,255,255,0.7);
    overflow: hidden;
    text-align: center;
    word-break: break-all;
    padding: 4px;
}
.dialog-text-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.dialog-title-text {
    font-size: 0.85rem;
    font-weight: 700;
    word-break: break-word;
}
.dialog-message-text {
    font-size: 0.72rem;
    line-height: 1.4;
    opacity: 0.85;
    word-break: break-word;
    white-space: pre-wrap;
}
.dialog-infobox-area {
    font-size: 0.65rem;
    opacity: 0.7;
    padding: 8px;
    border-top: 1px solid rgba(128,128,128,0.2);
    margin-top: 4px;
    word-break: break-word;
}

/* Preview form elements */
.dialog-inputs-area {
    padding: 0 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.dialog-input-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.dialog-input-label {
    font-size: 0.6rem;
    opacity: 0.6;
    font-weight: 600;
}
.dialog-input-field {
    height: 22px;
    border-radius: 4px;
    border: 1px solid rgba(128,128,128,0.3);
    background: rgba(128,128,128,0.1);
}

.dialog-checkbox-area {
    padding: 0 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.dialog-checkbox-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.65rem;
}
.dialog-checkbox-box {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(128,128,128,0.4);
    flex-shrink: 0;
}

.dialog-select-area {
    padding: 0 16px 8px;
}
.dialog-select-box {
    height: 24px;
    border-radius: 4px;
    border: 1px solid rgba(128,128,128,0.3);
    background: rgba(128,128,128,0.1);
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 0.65rem;
    justify-content: space-between;
}

.dialog-list-area {
    padding: 0 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.dialog-list-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 4px;
    background: rgba(128,128,128,0.08);
    font-size: 0.65rem;
}
.dialog-list-icon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background: var(--accent2);
    flex-shrink: 0;
}

.dialog-progress-area {
    padding: 0 16px 8px;
}
.dialog-progress-label {
    font-size: 0.6rem;
    opacity: 0.6;
    margin-bottom: 4px;
}
.dialog-progress-bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(128,128,128,0.2);
    overflow: hidden;
}
.dialog-progress-fill {
    height: 100%;
    border-radius: 3px;
    background: #007aff;
    transition: width 0.2s;
}

.dialog-timer-area {
    padding: 0 16px 4px;
}
.dialog-timer-label {
    font-size: 0.6rem;
    opacity: 0.5;
    text-align: center;
}

.dialog-button-row {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 8px 16px 14px;
}
.dialog-button-row.centered {
    justify-content: center;
}
.dialog-btn {
    padding: 4px 14px;
    border-radius: 5px;
    font-size: 0.7rem;
    font-weight: 500;
    border: none;
    cursor: default;
}
.dialog-btn-primary {
    background: #007aff;
    color: #fff;
}
.dialog-btn-secondary {
    background: rgba(128,128,128,0.2);
}
.dialog-preview[data-appearance="light"] .dialog-btn-secondary {
    color: #1d1d1f;
}
.dialog-preview[data-appearance="dark"] .dialog-btn-secondary {
    color: #f5f5f7;
}
.dialog-btn-info {
    background: none;
    color: #007aff;
    font-size: 0.65rem;
    margin-right: auto;
}

/* Mini style preview */
.dialog-body.mini-layout {
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
    gap: 10px;
}
.dialog-body.mini-layout .dialog-icon {
    width: 36px;
    height: 36px;
    font-size: 0.5rem;
}

/* === Output Bar === */
.output-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1100px;
    background: var(--surface);
    border-top: 2px solid var(--accent);
    padding: 10px 20px 14px;
    z-index: 100;
}
.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.output-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--green);
}
.output-toggle {
    display: flex;
    gap: 4px;
}
.toggle-btn {
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 14px;
    padding: 3px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-dim);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.toggle-btn:hover {
    border-color: var(--accent);
}
.toggle-btn.active {
    border-color: var(--accent);
    color: #fff;
    background: rgba(233, 69, 96, 0.15);
}
.output-row {
    display: flex;
    gap: 10px;
    align-items: center;
}
.output-cmd {
    flex: 1;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--yellow);
    overflow-x: auto;
    white-space: pre;
    line-height: 1.5;
    max-height: 160px;
    overflow-y: auto;
}
.copy-btn {
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    padding: 8px 18px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.82rem;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.copy-btn:hover {
    opacity: 0.85;
}
.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;
}

/* === 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;
}
.site-footer a {
    color: var(--green);
    text-decoration: none;
}
.site-footer a:hover {
    text-decoration: underline;
}
.site-footer strong {
    color: var(--text);
    font-weight: 600;
}
.footer-copy {
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--text-dim);
    opacity: 0.7;
}

/* === Responsive === */
@media (max-width: 800px) {
    .config-columns {
        flex-direction: column;
    }
    .config-preview {
        width: 100%;
        position: static;
        order: -1;
        margin-bottom: 16px;
    }
}
@media (max-width: 500px) {
    .app { padding: 56px 10px 170px; }
    .op-btn { min-width: 55px; padding: 8px 10px; }
    .op-label { font-size: 0.6rem; }
    .op-icon { font-size: 1rem; }
    .output-cmd { font-size: 0.72rem; }
}
