:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --accent: #0ea5e9;
    --accent-dark: #0284c7;
    --white: #ffffff;
    --bg-body: #f8fafc;
    --bg-panel: #ffffff;
    --bg-input: #f1f5f9;
    --bg-hover: #e2e8f0;
    --border: #cbd5e1;
    --border-light: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --success: #10b981;
    --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.25);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -50px;
    left: 0;
    background: var(--accent);
    color: var(--white);
    padding: 0.75rem 1.5rem;
    z-index: 1000;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 4px 0;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

header {
    background-color: var(--bg-panel);
    color: var(--text-primary);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 10;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-brand svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.75rem;
    line-height: 1;
}

.header-actions label.header-btn {
    margin: 0;
    font-weight: 500;
}

.save-indicator {
    font-size: 0.875rem;
    color: var(--accent);
    opacity: 0;
    transition: opacity 0.3s ease;
    margin-right: 0.5rem;
}

.save-indicator.visible {
    opacity: 1;
}

.container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 1.5rem;
    padding: 1.5rem;
}


.panel {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.panel-header {
    background: var(--bg-panel);
    padding: 0.875rem 1.5rem;
    font-weight: 600;
    font-size: 0.9375rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.panel-body {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.template-section {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.template-section .section-title {
    color: var(--primary);
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.template-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

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

.template-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 150px;
}

.template-card h4 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.template-card p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.template-actions {
    margin-top: auto;
    display: flex;
    justify-content: flex-end;
}

.template-import {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}

.template-import-note {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

label small {
    font-weight: 400;
    color: var(--text-secondary);
}

.form-hint {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

input[type="text"],
input[type="url"],
input[type="number"],
select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: var(--bg-input);
    color: var(--text-primary);
}

input.empty-warning {
    border-color: var(--danger);
    background-color: rgba(255, 107, 107, 0.1);
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

input[type="text"]:focus-visible,
input[type="url"]:focus-visible,
input[type="number"]:focus-visible,
select:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 1px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

.checkbox-group input[type="checkbox"]:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-primary:focus-visible {
    outline-color: var(--accent);
}

.btn-secondary {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
}

.btn-danger {
    background-color: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background-color: var(--danger-dark);
}

.btn-danger:focus-visible {
    outline-color: var(--danger);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    min-height: 36px;
    min-width: 36px;
}

.btn-generate {
    background-color: var(--primary);
    color: var(--white);
    font-weight: 600;
    padding: 0.875rem 2rem;
    font-size: 1rem;
    min-height: 48px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.btn-generate:hover {
    background-color: var(--primary-dark);
    box-shadow: var(--shadow-lg);
}

.btn-generate:focus-visible {
    outline-color: var(--primary);
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .btn,
    input[type="text"],
    input[type="url"] {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }

    input[type="text"],
    input[type="url"] {
        border-width: 2px;
    }
}

/* Visually hidden but accessible to screen readers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Groups Section */
.groups-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.group-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    padding: 0;
    margin: 0;
    background: var(--bg-panel);
    box-shadow: var(--shadow-sm);
}

.group-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border);
}

.group-header input {
    flex: 1;
    font-weight: 500;
}

.group-icon-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.group-icon-label {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0;
    white-space: nowrap;
}

.group-icon-row input[type="url"] {
    flex: 1;
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
}

.group-icon-row .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.group-links {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.link-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.link-row input {
    flex: 1;
    min-width: 120px;
}

.link-row input:first-of-type {
    max-width: 35%;
}

.link-row .link-icon-input {
    max-width: 180px;
    min-width: 140px;
}

.link-row select.link-type-select {
    width: 65px;
    flex: 0 0 auto;
    font-size: 0.75rem;
    padding: 0.375rem 0.25rem;
    border-radius: 4px;
}

.link-row select.app-preset-select {
    min-width: 170px;
    flex: 0 0 auto;
    font-size: 0.75rem;
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
}

/* Drag and drop styles */
.drag-handle {
    cursor: grab;
    padding: 0.25rem;
    color: var(--text-secondary);
    font-size: 1rem;
    user-select: none;
    display: flex;
    align-items: center;
}

.drag-handle:active {
    cursor: grabbing;
}

.group-card.dragging,
.link-row.dragging {
    opacity: 0.5;
    background: var(--bg-hover);
}

.group-card.drag-over {
    border: 2px dashed var(--primary);
    background: rgba(37, 99, 235, 0.08);
}

.link-row.drag-over {
    border-top: 2px solid var(--primary);
}

.group-links.drag-over {
    border: 2px dashed var(--primary);
    background: rgba(37, 99, 235, 0.08);
    border-radius: var(--radius-md);
}

.ungrouped-drop-zone {
    padding: 1rem;
    border: 2px dashed var(--border);
    border-radius: 6px;
    text-align: center;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.ungrouped-drop-zone.drag-over,
#ungroupedLinksContainer > div[role="list"].drag-over {
    border: 2px dashed var(--primary);
    background: rgba(37, 99, 235, 0.08);
}

/* Collapsible sections */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 0.5rem 0;
    user-select: none;
}

.section-header:hover {
    opacity: 0.8;
}

.section-header h3,
.section-header legend {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.collapse-icon {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
    color: var(--text-secondary);
}

.section-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.section-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    max-height: 2000px;
    opacity: 1;
}

.section-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0;
    margin: 0;
}

@media (prefers-reduced-motion: reduce) {
    .collapse-icon,
    .section-content {
        transition: none;
    }
}

/* Input validation */
input.invalid {
    border-color: var(--danger);
    background-color: rgba(255, 107, 107, 0.1);
}

input.invalid:focus {
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.3);
}

.validation-error {
    color: var(--danger);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: none;
}

.validation-error.visible {
    display: block;
}

.empty-message {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

.actions-bar {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Preview Section */
.preview-container {
    position: sticky;
    top: 1.5rem;
}

.preview-frame {
    background: var(--bg-input);
    border-radius: 6px;
    min-height: 500px;
    overflow: hidden;
}

.preview-frame iframe {
    width: 100%;
    height: 600px;
    border: none;
}

/* Output Section */
.output-section {
    margin-top: 1.5rem;
}

.output-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    padding: 1rem;
}

/* Info text */
.info-text {
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

/* Scrollable editor */
.editor-scroll {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

footer {
    text-align: center;
    padding: 1.25rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    border-top: 1px solid var(--border-light);
    background: var(--bg-panel);
}

footer a {
    color: var(--primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Theme swatches */
.theme-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.theme-swatch {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    cursor: pointer;
    border: 3px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.theme-swatch:hover {
    border-color: var(--text-secondary);
}

.theme-swatch.selected {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.theme-swatch:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.theme-swatch .swatch-primary,
.theme-swatch .swatch-accent {
    flex: 1;
}

.theme-swatch-custom {
    background: linear-gradient(135deg, #ff6b6b 0%, #feca57 25%, #48dbfb 50%, #ff9ff3 75%, #54a0ff 100%);
    position: relative;
}

.theme-swatch-custom::after {
    content: '+';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.swatch-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.25rem;
}

.swatch-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Custom colors section */
.custom-colors {
    display: none;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem;
    background: var(--bg-input);
    border-radius: 6px;
    margin-top: 0.5rem;
}

.custom-colors.visible {
    display: flex;
}

.color-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.color-input-group label {
    font-size: 0.875rem;
    margin-bottom: 0;
}

.color-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-input-row input[type="color"] {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
}

.color-input-row input[type="text"] {
    width: 90px;
    font-family: monospace;
}

/* Advanced colors section */
.advanced-colors-section {
    margin-top: 1.5rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
}

.advanced-colors-section legend {
    font-weight: 600;
    color: var(--text-primary);
    padding: 0 0.5rem;
}

.advanced-colors-section .section-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

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

.advanced-colors-grid .color-input-group {
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.advanced-colors-grid .color-input-group.customized {
    background-color: rgba(37, 99, 235, 0.08);
    border-left: 3px solid var(--primary);
}

.advanced-colors-grid .color-input-group label {
    font-size: 0.8125rem;
    font-weight: 500;
}

/* Logo input row */
.logo-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.logo-input-row input[type="url"] {
    flex: 1;
}

.logo-input-row .upload-btn {
    cursor: pointer;
    white-space: nowrap;
}

.logo-input-row .btn-sm:last-child {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
    background: var(--bg-input);
    color: var(--text-secondary);
}

.logo-input-row .btn-sm:last-child:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.custom-warning {
    display: none;
    background: rgba(255, 193, 7, 0.15);
    border: 1px solid #ffc107;
    border-radius: 4px;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: #ffc107;
    margin-top: 0.5rem;
}

.custom-warning.visible {
    display: block;
}

@media (prefers-reduced-motion: reduce) {
    .theme-swatch {
        transition: none;
    }
}

/* Instruction modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.visible {
    display: flex;
}

.modal {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    max-width: 550px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-light);
}

.modal-header {
    background: var(--bg-panel);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.modal-close:hover {
    opacity: 0.8;
}

.modal-body {
    padding: 1.5rem;
    color: var(--text-primary);
}

.modal-body h3 {
    color: var(--primary);
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.modal-body p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.modal-body ol {
    margin: 0 0 1rem 1.25rem;
    line-height: 1.8;
}

.modal-body code {
    background: var(--bg-input);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875rem;
    word-break: break-all;
}

.modal-body .code-block {
    background: var(--bg-body);
    color: var(--accent);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    overflow-x: auto;
    margin: 0.5rem 0 1rem;
}

.deployment-section {
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.deployment-section summary {
    padding: 0.75rem 1rem;
    background: var(--bg-body);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.deployment-section summary::-webkit-details-marker {
    display: none;
}

.deployment-section summary::before {
    content: '\25B6';
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.deployment-section[open] summary::before {
    transform: rotate(90deg);
}

.deployment-section summary h3 {
    margin: 0;
    font-size: 1rem;
    display: inline;
}

.deployment-section > *:not(summary) {
    padding: 0 1rem;
}

.deployment-section h4 {
    margin: 1rem 0 0.5rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.deployment-section p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

.deployment-section ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.deployment-section ol li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.detection-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0 1rem;
    font-size: 0.85rem;
}

.detection-table td {
    padding: 0.5rem;
    border: 1px solid var(--border);
}

.detection-table td:first-child {
    width: 40%;
    background: var(--bg-body);
}

.detection-table code {
    background: var(--bg-body);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    word-break: break-all;
}

.deployment-section a {
    color: var(--accent);
}

.deployment-section a:hover {
    text-decoration: underline;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

/* Icon picker modal */
.icon-picker-modal {
    max-width: 650px;
}

.icon-picker-search {
    margin-bottom: 1rem;
}

.icon-picker-search input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    background-color: var(--bg-input);
    color: var(--text-primary);
}

.icon-picker-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.icon-picker-grid {
    max-height: 400px;
    overflow-y: auto;
}

.icon-category {
    margin-bottom: 1.25rem;
}

.icon-category.hidden {
    display: none;
}

.icon-category-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.icon-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 0.5rem;
}

.icon-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.25rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.icon-option:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

.icon-option:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.icon-option.hidden {
    display: none;
}

.icon-option svg {
    width: 24px;
    height: 24px;
    color: var(--text-primary);
    flex-shrink: 0;
}

.icon-option-label {
    font-size: 0.625rem;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.icon-picker-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Tab Navigation */
.step-nav {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    padding: 0.25rem;
    background: var(--bg-input);
    border-radius: var(--radius-lg);
}

.step-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.step-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.step-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.step-btn .step-number {
    display: none;
}

.step-btn.active {
    color: var(--primary);
    background: var(--bg-panel);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.step-arrow {
    display: none;
}

/* Responsive tabs */
@media (max-width: 600px) {
    .step-nav {
        flex-wrap: wrap;
    }
    .step-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Slider row with value label */
.slider-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.slider-row input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    cursor: pointer;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.slider-row input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-dark);
}

.slider-row input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.slider-row input[type="range"]:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.slider-value {
    min-width: 60px;
    text-align: right;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Section labels */
.section-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    margin: 1.25rem 0 0.75rem 0;
}

.section-label:first-child {
    margin-top: 0;
}

/* Preset Picker Modal */
.preset-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.preset-picker-overlay[hidden] {
    display: none;
}

.preset-picker-container {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-light);
}

.preset-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

.preset-picker-header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.preset-picker-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease, background-color 0.15s ease;
}

.preset-picker-close:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

.preset-picker-close:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.preset-picker-search {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

.preset-picker-search input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background-color: var(--bg-input);
    color: var(--text-primary);
}

.preset-picker-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.preset-picker-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

/* Preset Grid */
.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.preset-category {
    grid-column: 1 / -1;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin: 0.5rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-light);
}

.preset-category:first-child {
    margin-top: 0;
}

.preset-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

.preset-card:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

.preset-card:focus {
    outline: none;
    box-shadow: var(--focus-ring);
    border-color: var(--primary);
}

.preset-card:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.preset-card svg {
    width: 32px;
    height: 32px;
    color: var(--text-primary);
}

.preset-card span {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
}

@media (prefers-reduced-motion: reduce) {
    .preset-picker-close,
    .preset-card {
        transition: none;
    }
}

/* Create Custom Application Button */
.preset-create-btn {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    background: var(--bg-input);
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    margin-bottom: 0.5rem;
}

.preset-create-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-hover);
}

.preset-create-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.preset-create-btn svg {
    width: 20px;
    height: 20px;
}

/* Custom Preset Card Styling */
.preset-card-custom {
    position: relative;
}

.preset-card-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.preset-card-custom:hover .preset-card-actions,
.preset-card-custom:focus-within .preset-card-actions {
    opacity: 1;
}

.preset-action-btn {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.preset-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.preset-action-delete:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* Custom Preset Form */
.custom-preset-form-container {
    max-width: 450px;
}

.custom-preset-icon-row {
    display: flex;
    gap: 0.5rem;
}

.custom-preset-icon-row input {
    flex: 1;
}

.icon-preview {
    margin-top: 0.5rem;
    min-height: 40px;
}

.icon-preview svg {
    width: 32px;
    height: 32px;
    color: var(--text-primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-panel);
}

.help-text {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.required {
    color: var(--danger);
}

@media (prefers-reduced-motion: reduce) {
    .preset-create-btn,
    .preset-card-actions,
    .preset-action-btn {
        transition: none;
    }
}
