/* Marketplace window — dark catalogue surface.
   Deliberately close to the Claude Marketplace layout: fixed filter rail,
   dense card grid, quiet chrome. Brand ink/paper/orange come from brand.css. */

.mkt {
    --mkt-bg: #171714;
    --mkt-surface: #1e1e1a;
    --mkt-surface-hover: #242420;
    --mkt-line: rgba(247, 247, 244, 0.09);
    --mkt-line-strong: rgba(247, 247, 244, 0.18);
    --mkt-text: #f2f2ee;
    --mkt-muted: #9c9d95;
    --mkt-dim: #74756e;
    --mkt-accent: var(--brand-orange, #f09024);
    --mkt-radius: 14px;

    margin: 0;
    min-height: 100vh;
    background: var(--mkt-bg);
    color: var(--mkt-text);
    font-family: var(--brand-font, "Inter Tight", system-ui, sans-serif);
    -webkit-font-smoothing: antialiased;
}

.mkt * {
    box-sizing: border-box;
}

/* ── top bar ─────────────────────────────────────────────────────────── */

.mkt-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    height: 60px;
    padding: 0 26px;
    background: rgba(23, 23, 20, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--mkt-line);
}

.mkt-bar-left,
.mkt-bar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.mkt-mark {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: var(--mkt-accent);
    color: #17130c;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
}

.mkt-wordmark {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.mkt-count {
    font-size: 12px;
    color: var(--mkt-dim);
    padding-left: 14px;
    border-left: 1px solid var(--mkt-line);
    white-space: nowrap;
}

.mkt-search {
    display: flex;
    align-items: center;
    gap: 8px;
    width: min(380px, 38vw);
    padding: 0 10px;
    height: 34px;
    border: 1px solid var(--mkt-line);
    border-radius: 9px;
    background: var(--mkt-surface);
    color: var(--mkt-muted);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.mkt-search:focus-within {
    border-color: var(--mkt-line-strong);
    background: var(--mkt-surface-hover);
}

.mkt-search svg {
    width: 15px;
    height: 15px;
    flex: none;
}

.mkt-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--mkt-text);
    font: inherit;
    font-size: 13px;
}

.mkt-search input::placeholder {
    color: var(--mkt-dim);
}

.mkt-search input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.mkt-search kbd {
    font: inherit;
    font-size: 11px;
    color: var(--mkt-dim);
    border: 1px solid var(--mkt-line);
    border-radius: 4px;
    padding: 1px 5px;
}

.mkt-btn {
    height: 34px;
    padding: 0 13px;
    border-radius: 9px;
    border: 1px solid var(--mkt-line);
    background: var(--mkt-surface);
    color: var(--mkt-text);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.mkt-btn:hover {
    background: var(--mkt-surface-hover);
    border-color: var(--mkt-line-strong);
}

.mkt-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.mkt-btn-wide {
    width: 100%;
    height: 38px;
}

/* ── layout ──────────────────────────────────────────────────────────── */

.mkt-layout {
    display: grid;
    grid-template-columns: 268px minmax(0, 1fr);
    gap: 0;
    align-items: start;
}

.mkt-filters {
    position: sticky;
    top: 60px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    padding: 22px 22px 40px;
    border-right: 1px solid var(--mkt-line);
    scrollbar-width: thin;
}

.mkt-filters-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    font-size: 17px;
    font-weight: 500;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--mkt-line);
    margin-bottom: 14px;
}

.mkt-filters-head button {
    border: 0;
    background: none;
    color: var(--mkt-dim);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
}

.mkt-filters-head button:hover {
    color: var(--mkt-text);
}

.mkt-filter-group {
    padding: 12px 0;
    border-bottom: 1px solid var(--mkt-line);
}

.mkt-filter-group:last-child {
    border-bottom: 0;
}

.mkt-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 2px 0;
    border: 0;
    background: none;
    color: var(--mkt-muted);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.mkt-group-toggle svg {
    width: 12px;
    height: 12px;
    transition: transform 0.18s ease;
}

.mkt-group-toggle[aria-expanded="false"] svg {
    transform: rotate(-90deg);
}

.mkt-group-label {
    font-size: 13px;
    color: var(--mkt-muted);
    padding: 2px 0 10px;
}

.mkt-cat-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 10px;
}

.mkt-cat-list.hidden {
    display: none;
}

.mkt-cat {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 4px;
    border-radius: 7px;
    font-size: 13px;
    color: var(--mkt-text);
    cursor: pointer;
    line-height: 1.25;
}

.mkt-cat:hover {
    background: rgba(247, 247, 244, 0.04);
}

.mkt-cat input {
    appearance: none;
    width: 15px;
    height: 15px;
    flex: none;
    border: 1px solid var(--mkt-line-strong);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.mkt-cat input:checked {
    background: var(--mkt-accent);
    border-color: var(--mkt-accent);
}

.mkt-cat input:checked::after {
    content: "";
    width: 7px;
    height: 4px;
    border-left: 1.7px solid #17130c;
    border-bottom: 1.7px solid #17130c;
    transform: rotate(-45deg) translateY(-1px);
}

.mkt-cat span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mkt-cat em {
    font-style: normal;
    font-size: 11.5px;
    color: var(--mkt-dim);
}

.mkt-chips {
    display: flex;
    gap: 6px;
}

.mkt-chips button {
    flex: 1;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--mkt-line);
    background: transparent;
    color: var(--mkt-muted);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
}

.mkt-chips button.is-active {
    background: rgba(240, 144, 36, 0.14);
    border-color: rgba(240, 144, 36, 0.42);
    color: var(--mkt-text);
}

.mkt-check {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    color: var(--mkt-text);
    padding: 6px 4px;
    cursor: pointer;
    border-radius: 7px;
}

.mkt-check:hover {
    background: rgba(247, 247, 244, 0.04);
}

.mkt-check input {
    appearance: none;
    width: 15px;
    height: 15px;
    flex: none;
    border: 1px solid var(--mkt-line-strong);
    border-radius: 4px;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.mkt-check input:checked {
    background: var(--mkt-accent);
    border-color: var(--mkt-accent);
}

.mkt-check input:checked::after {
    content: "";
    width: 7px;
    height: 4px;
    border-left: 1.7px solid #17130c;
    border-bottom: 1.7px solid #17130c;
    transform: rotate(-45deg) translateY(-1px);
}

/* ── main ────────────────────────────────────────────────────────────── */

.mkt-main {
    padding: 22px 26px 60px;
    min-width: 0;
}

.mkt-main-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.mkt-main-head h2 {
    margin: 0;
    font-size: 21px;
    font-weight: 500;
    letter-spacing: -0.01em;
}

.mkt-sub {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--mkt-dim);
}

.mkt-main-tools {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mkt-result-count {
    font-size: 12px;
    color: var(--mkt-dim);
}

.mkt-main-tools select {
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--mkt-line);
    background: var(--mkt-surface);
    color: var(--mkt-text);
    font: inherit;
    font-size: 12.5px;
    padding: 0 8px;
    cursor: pointer;
}

.mkt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}

/* ── card ────────────────────────────────────────────────────────────── */

.mkt-card {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    padding: 15px 15px 15px 16px;
    background: var(--mkt-surface);
    border: 1px solid var(--mkt-line);
    border-radius: var(--mkt-radius);
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.mkt-card:hover {
    background: var(--mkt-surface-hover);
    border-color: var(--mkt-line-strong);
}

.mkt-card.is-enabled {
    border-color: rgba(240, 144, 36, 0.34);
}

.mkt-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: none;
    border-radius: 10px;
    background: #ffffff;
    color: #171917;
    font-weight: 600;
    font-size: 16px;
    overflow: hidden;
    position: relative;
}

.mkt-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.mkt-icon.is-dark {
    background: #2b2b26;
    color: #d9d9d2;
    font-size: 13px;
    letter-spacing: 0.02em;
}

.mkt-card-body {
    flex: 1;
    min-width: 0;
}

.mkt-card-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14.5px;
    font-weight: 500;
    line-height: 1.25;
}

.mkt-card-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mkt-verified {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--mkt-muted);
    color: var(--mkt-bg);
    font-size: 9px;
    line-height: 1;
}

.mkt-card-desc {
    margin: 4px 0 0;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--mkt-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mkt-card-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 8px;
    font-size: 11.5px;
    color: var(--mkt-dim);
    flex-wrap: wrap;
}

.mkt-tag {
    padding: 1px 7px;
    border-radius: 999px;
    border: 1px solid var(--mkt-line);
    text-transform: capitalize;
}

.mkt-tag.is-live {
    border-color: rgba(240, 144, 36, 0.34);
    color: #e9b57a;
}

.mkt-add {
    flex: none;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    border: 1px solid var(--mkt-line-strong);
    background: transparent;
    color: var(--mkt-text);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.mkt-add:hover {
    background: rgba(247, 247, 244, 0.07);
}

.mkt-add.is-on {
    background: var(--mkt-accent);
    border-color: var(--mkt-accent);
    color: #17130c;
}

.mkt-add:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mkt-empty {
    padding: 48px 0;
    text-align: center;
    color: var(--mkt-dim);
    font-size: 13.5px;
}

.mkt-more-wrap {
    margin-top: 16px;
}

.hidden {
    display: none !important;
}

/* ── toast ───────────────────────────────────────────────────────────── */

.mkt-toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translate(-50%, 12px);
    padding: 9px 15px;
    border-radius: 9px;
    background: #2a2a25;
    border: 1px solid var(--mkt-line-strong);
    color: var(--mkt-text);
    font-size: 12.5px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 40;
}

.mkt-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ── narrow / popout-friendly ────────────────────────────────────────── */

@media (max-width: 960px) {
    .mkt-layout {
        grid-template-columns: 1fr;
    }

    .mkt-filters {
        position: static;
        max-height: none;
        border-right: 0;
        border-bottom: 1px solid var(--mkt-line);
        padding-bottom: 18px;
    }

    .mkt-search {
        width: 100%;
    }

    .mkt-bar {
        height: auto;
        flex-wrap: wrap;
        padding: 12px 16px;
        gap: 10px;
    }

    .mkt-bar-right {
        width: 100%;
    }

    .mkt-main {
        padding: 18px 16px 48px;
    }
}

/* Workspace navigation is rendered by _workspace_rail.html. */

/* ── enabled-card configuration ─────────────────────────────────────── */
.mkt-configure {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--mkt-muted);
    font: inherit;
    font-size: 11.5px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.mkt-configure:hover { color: var(--mkt-text); }

.mkt-config-modal { position: fixed; inset: 0; z-index: 12000; display: grid; place-items: center; padding: 20px; }
.mkt-config-modal[hidden] { display: none !important; }
.mkt-config-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.62); backdrop-filter: blur(4px); }
.mkt-config-panel {
    position: relative; z-index: 1; width: min(560px, 100%); max-height: min(88vh, 760px); overflow-y: auto;
    padding: 22px 22px 18px; border: 1px solid var(--mkt-line-strong); border-radius: 18px;
    background: #1c1c18; color: var(--mkt-text); box-shadow: 0 28px 90px rgba(0,0,0,.55);
}
.mkt-config-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.mkt-config-eyebrow { margin: 0 0 5px; color: var(--mkt-dim); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; }
.mkt-config-head h2 { margin: 0 0 6px; font-size: 22px; font-weight: 500; letter-spacing: -.03em; line-height: 1.15; }
.mkt-config-copy { margin: 0; color: var(--mkt-muted); font-size: 12.5px; line-height: 1.45; }
.mkt-config-close {
    flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--mkt-line);
    background: transparent; color: var(--mkt-muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.mkt-config-close:hover { color: var(--mkt-text); border-color: var(--mkt-line-strong); }
.mkt-config-form { display: grid; gap: 12px; }
.mkt-config-field { display: grid; gap: 5px; color: var(--mkt-muted); font-size: 11.5px; }
.mkt-config-field small { color: var(--mkt-dim); font-size: 10.5px; }
.mkt-config-field input,
.mkt-config-field textarea {
    width: 100%; padding: 10px 11px; border-radius: 9px; border: 1px solid var(--mkt-line);
    background: #151511; color: var(--mkt-text); font: inherit; font-size: 13px; outline: none; resize: vertical;
}
.mkt-config-field input:focus,
.mkt-config-field textarea:focus { border-color: rgba(240,144,36,.55); box-shadow: 0 0 0 3px rgba(240,144,36,.09); }
.mkt-config-hint { margin: 2px 0 0; color: var(--mkt-dim); font-size: 11px; line-height: 1.45; }
.mkt-config-status { margin: 0; padding: 9px 11px; border-radius: 8px; font-size: 12px; line-height: 1.4; }
.mkt-config-status.is-ok { color: #a9f3c4; background: rgba(169,243,196,.09); }
.mkt-config-status.is-error { color: #ffb4c1; background: rgba(255,154,181,.09); }
.mkt-config-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.mkt-btn-primary { background: #f2f2ee; color: #151511; border-color: transparent; font-weight: 600; }
.mkt-btn-primary:hover { background: #fff; color: #151511; }
.mkt-btn-ghost { background: transparent; }
@media (max-width: 620px) {
    .mkt-config-modal { padding: 10px; align-items: end; }
    .mkt-config-panel { max-height: 92vh; padding: 18px 16px 16px; border-radius: 16px; }
}
