/* ============================================
   TOOL TEMPLATE CSS — Extracted from Duet
   The gold standard for all Ensemble tool pages.
   
   Import chain: shared.css → tool-template.css → inline (tool-specific)
   ============================================ */

/* === Tool Container === */
.tool-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* === Grain Texture Overlay === */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.4'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* === Ensemble Badge === */
.ensemble-badge {
    font-size: .65rem;
    font-weight: 700;
    color: var(--primary-accent);
    background: var(--glow);
    padding: .2rem .5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: .06em;
    border: 1px solid rgba(167, 139, 250, 0.2);
}

/* === Hero Section === */
.hero {
    padding: 2.5rem 0 1.5rem;
    text-align: center;
}

.hero h1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.5rem;
    color: var(--body-text);
}

.hero p {
    color: var(--secondary-text);
    font-size: 1.05rem;
    max-width: 520px;
    margin: 0 auto;
}

.hero-hint {
    color: var(--muted-text);
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

.hero-hint kbd {
    background: var(--surface-color);
    border: 1px solid var(--border-hover);
    border-radius: 3px;
    padding: .1rem .35rem;
    font-family: inherit;
    font-size: .75rem;
}

/* === Controls Panel === */
.controls {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.controls-row {
    display: flex;
    gap: 1rem;
    align-items: end;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
    min-width: 180px;
}

.control-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* === Form Elements === */
select {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-hover);
    border-radius: 6px;
    font-family: 'Instrument Sans', sans-serif;
    font-size: 0.9rem;
    color: var(--body-text);
    background: var(--bg-color);
    cursor: pointer;
    outline: none;
    width: 100%;
}

select:focus {
    border-color: var(--primary-accent);
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-hover);
    padding: 0;
    border: none;
    margin-top: 0.5rem;
    outline: none;
}

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

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

input[type="number"],
input[type="text"] {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-hover);
    border-radius: 6px;
    font-family: 'Instrument Sans', sans-serif;
    font-size: 0.9rem;
    color: var(--body-text);
    background: var(--bg-color);
    outline: none;
    width: 100%;
}

input[type="number"]:focus,
input[type="text"]:focus {
    border-color: var(--primary-accent);
}

.range-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.range-value {
    font-family: 'Instrument Sans', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-accent);
}

/* === Buttons === */
.btn {
    padding: 0.6rem 1.25rem;
    font-family: 'Instrument Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--secondary-accent);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    border-color: var(--primary-accent);
    color: var(--body-text);
    transform: translateY(-1px);
}

.btn-icon {
    padding: 0.6rem;
    background: var(--bg-color);
    border: 1px solid var(--border-hover);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
    line-height: 1;
}

.btn-icon:hover {
    border-color: var(--primary-accent);
    transform: translateY(-1px);
}

/* === Chip/Preset Bar === */
.chip-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

/* Scrollbar for chip bars */
.chip-bar::-webkit-scrollbar { height: 4px; }
.chip-bar::-webkit-scrollbar-track { background: transparent; }
.chip-bar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.chip {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border-hover);
    border-radius: 20px;
    background: var(--surface-color);
    color: var(--secondary-text);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.chip:hover,
.chip.active {
    background: var(--primary-accent);
    color: white;
    border-color: var(--primary-accent);
}

/* === Preview Card === */
.preview-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.preview-header {
    background: var(--surface-hover);
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-header-label {
    font-size: 0.8rem;
    color: var(--muted-text);
}

.preview-header-label strong {
    color: var(--body-text);
}

.preview-body {
    padding: 2.5rem;
}

/* === Toggle Buttons === */
.preview-toggles {
    display: flex;
    gap: 0.5rem;
}

.toggle-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border-hover);
    background: var(--bg-color);
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--secondary-text);
}

.toggle-btn:hover,
.toggle-btn.active {
    border-color: var(--primary-accent);
    background: var(--primary-accent);
    color: white;
}

/* === Viewport Tabs (for responsive tools) === */
.viewport-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.viewport-tab {
    padding: 0.5rem 1rem;
    font-family: 'Instrument Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--border-hover);
    border-radius: 8px;
    background: var(--surface-color);
    color: var(--secondary-text);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.viewport-tab.active {
    background: var(--primary-accent);
    color: white;
    border-color: var(--primary-accent);
}

/* === Export Section === */
.export-section {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.export-section h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.export-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.export-tab {
    padding: 0.4rem 0.85rem;
    font-family: 'Instrument Sans', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border-hover);
    border-radius: 20px;
    background: var(--bg-color);
    color: var(--secondary-text);
    cursor: pointer;
    transition: all 0.2s;
}

.export-tab.active {
    background: var(--primary-accent);
    color: white;
    border-color: var(--primary-accent);
}

.export-code {
    background: var(--surface-hover);
    color: var(--body-text);
    border-radius: 8px;
    padding: 1.25rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
    position: relative;
    border: 1px solid var(--border-color);
}

.export-copy {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: var(--primary-accent);
    border: none;
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.export-copy:hover {
    background: var(--secondary-accent);
}

/* === Interop/Cross-Link Banner === */
.interop-banner {
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.interop-banner-icon {
    font-size: 1.5rem;
}

.interop-banner p {
    font-size: 0.9rem;
    color: var(--secondary-text);
}

.interop-banner a {
    color: var(--primary-accent);
    font-weight: 600;
    text-decoration: none;
}

.interop-banner a:hover {
    text-decoration: underline;
}

/* === Guide/Info Section === */
.guide {
    padding: 2rem 0 3rem;
}

.guide h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.guide h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 1.5rem 0 0.5rem;
}

.guide p {
    color: var(--secondary-text);
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    line-height: 1.8;
}

.guide ul {
    color: var(--secondary-text);
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.guide li {
    margin-bottom: 0.35rem;
}

/* === Footer === */
footer {
    padding: 2.5rem 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
    color: var(--muted-text);
    font-size: 0.85rem;
    font-weight: 300;
}

footer a {
    color: var(--primary-accent);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

footer a:hover {
    color: var(--primary-light);
}

/* === Toast Notification === */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--primary-accent);
    color: white;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 100;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* === Color Input (Harmony/Bridge style) === */
.color-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-color);
    border: 1px solid rgba(167, 139, 250, 0.15);
    border-radius: 6px;
    padding: 0.25rem 0.75rem 0.25rem 0.25rem;
}

.color-input-wrap input[type="color"] {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    background: none;
}

.color-input-wrap input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-input-wrap input[type="color"]::-webkit-color-swatch {
    border-radius: 3px;
    border: none;
}

.color-input-wrap input[type="text"] {
    border: none;
    background: none;
    color: var(--body-text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    width: 80px;
    padding: 0;
}

/* === Editable Text === */
[contenteditable] {
    outline: none;
    border-radius: 4px;
    transition: box-shadow 0.2s;
}

[contenteditable]:focus {
    box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.2);
}

/* === Share Bar === */
.share-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.share-bar input {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-hover);
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--muted-text);
    background: var(--surface-color);
    outline: none;
}

.share-bar button {
    padding: 0.5rem 1rem;
    font-family: 'Instrument Sans', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--primary-accent);
    border-radius: 6px;
    background: var(--primary-accent);
    color: white;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.share-bar button:hover {
    background: var(--secondary-accent);
    border-color: var(--secondary-accent);
}

/* === Responsive === */
@media (max-width: 640px) {
    .hero h1 {
        font-size: 1.5rem;
    }

    .controls-row {
        flex-direction: column;
    }

    .preview-body {
        padding: 1.5rem;
    }

    .interop-banner {
        flex-direction: column;
        text-align: center;
    }

    .control-group {
        min-width: 100%;
    }
}
