/* Community template marketplace — extends the dark marketplace surface. */

.tplm-main {
    max-width: 1360px;
    margin: 0 auto;
    padding: 26px 26px 80px;
}
.tplm-head { align-items: flex-start; }
.tplm-head-tools { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.tplm-mine { white-space: nowrap; }
.tplm-typebar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 4px 0 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--mkt-line);
}
.tplm-type {
    border: 1px solid var(--mkt-line);
    background: transparent;
    color: var(--mkt-muted);
    border-radius: 999px;
    padding: 7px 13px;
    font-size: 12.5px;
    cursor: pointer;
    font-family: inherit;
}
.tplm-type:hover { border-color: var(--mkt-line-strong); color: var(--mkt-text); }
.tplm-type.is-active { background: var(--mkt-text); color: #171714; border-color: transparent; }

.tplm-grid { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.tplm-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--mkt-line);
    border-radius: var(--mkt-radius);
    background: var(--mkt-surface);
    min-width: 0;
}
.tplm-card:hover { background: var(--mkt-surface-hover); border-color: var(--mkt-line-strong); }
.tplm-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tplm-kind {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--mkt-muted);
}
.tplm-kind::before {
    content: "";
    width: 7px; height: 7px; border-radius: 2px;
    background: currentColor; opacity: .65;
}
.tplm-kind[data-kind="workflow"] { color: #8fb7ff; }
.tplm-kind[data-kind="agent_role"] { color: #b9a0ff; }
.tplm-kind[data-kind="autonomous_team"] { color: #7fd3a6; }
.tplm-status-pill {
    font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
    padding: 2px 7px; border-radius: 999px;
    background: rgba(255,255,255,.07); color: var(--mkt-muted);
}
.tplm-status-pill[data-status="published"] { color: #7fd3a6; }
.tplm-card h3 { margin: 0; font-size: 15.5px; line-height: 1.3; color: var(--mkt-text); font-weight: 600; }
.tplm-card p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--mkt-muted); }
.tplm-meta { font-size: 11.5px; color: var(--mkt-dim); display: flex; flex-wrap: wrap; gap: 6px 10px; }
.tplm-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tplm-tag {
    font-size: 10.5px; padding: 2px 7px; border-radius: 6px;
    background: rgba(255,255,255,.06); color: var(--mkt-muted);
}
.tplm-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 4px; }
.tplm-actions .mkt-btn { padding: 6px 10px; height: 30px; font-size: 12px; }
.tplm-link {
    border: 0; background: transparent; color: var(--mkt-muted);
    text-decoration: underline; text-underline-offset: 2px;
    font: inherit; font-size: 12px; cursor: pointer; padding: 6px 2px;
}
.tplm-link:hover { color: var(--mkt-text); }
.tplm-risk {
    font-size: 11px; color: #f0b45c; background: rgba(190,140,40,.12);
    border: 1px solid rgba(190,140,40,.2); border-radius: 8px; padding: 6px 8px;
}

/* modal */
.tplm-modal { position: fixed; inset: 0; z-index: 2200; display: flex; align-items: center; justify-content: center; padding: 24px; }
.tplm-modal[hidden] { display: none; }
.tplm-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.62); backdrop-filter: blur(4px); }
.tplm-panel {
    position: relative;
    z-index: 1;
    width: min(760px, 96vw);
    max-height: min(88vh, 900px);
    overflow-y: auto;
    background: #1e1e1a;
    border: 1px solid var(--mkt-line-strong);
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(0,0,0,.55);
    color: var(--mkt-text);
}
.tplm-panel-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
    padding: 22px 24px 14px; border-bottom: 1px solid var(--mkt-line);
    position: sticky; top: 0; background: #1e1e1a; z-index: 2;
}
.tplm-eyebrow { margin: 0 0 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--mkt-muted); }
.tplm-panel h2 { margin: 0 0 4px; font-size: 20px; color: var(--mkt-text); }
.tplm-muted { margin: 0; color: var(--mkt-muted); font-size: 12.5px; line-height: 1.5; }
.tplm-close { border: 0; background: transparent; color: var(--mkt-muted); font-size: 24px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 8px; }
.tplm-close:hover { background: rgba(255,255,255,.07); color: var(--mkt-text); }
.tplm-detail-body { padding: 18px 24px 8px; }
.tplm-panel-actions {
    display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
    padding: 14px 24px 20px; border-top: 1px solid var(--mkt-line);
    position: sticky; bottom: 0; background: #1e1e1a;
}
.tplm-section { margin-bottom: 18px; }
.tplm-section h4 { margin: 0 0 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--mkt-muted); }
.tplm-section p, .tplm-section li { font-size: 12.5px; line-height: 1.55; color: var(--mkt-text); }
.tplm-section ul { margin: 0; padding-left: 18px; }
.tplm-pre {
    white-space: pre-wrap; word-break: break-word;
    background: rgba(255,255,255,.04); border: 1px solid var(--mkt-line);
    border-radius: 10px; padding: 12px; font-size: 12px; line-height: 1.55;
    color: var(--mkt-text); max-height: 300px; overflow-y: auto;
    font-family: var(--platform-font-mono, ui-monospace, Menlo, monospace);
}
.tplm-step { border-left: 2px solid var(--mkt-line-strong); padding: 2px 0 2px 10px; margin-bottom: 10px; }
.tplm-step strong { font-size: 12.5px; color: var(--mkt-text); }
.tplm-step small { display: block; color: var(--mkt-muted); font-size: 11px; margin-top: 2px; }
.tplm-team-list { display: flex; flex-direction: column; gap: 8px; }
.tplm-teammate { border: 1px solid var(--mkt-line); border-radius: 10px; padding: 9px 11px; }
.tplm-teammate strong { font-size: 12.5px; }
.tplm-teammate p { margin: 4px 0 0; color: var(--mkt-muted); font-size: 12px; }

/* form */
.tplm-form { padding: 18px 24px 0; }
.tplm-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tplm-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 12px; color: var(--mkt-muted); }
.tplm-field-full { grid-column: 1 / -1; }
.tplm-field small { color: var(--mkt-dim); font-size: 11px; }
.tplm-field input, .tplm-field select, .tplm-field textarea {
    width: 100%; box-sizing: border-box;
    background: rgba(255,255,255,.05); color: var(--mkt-text);
    border: 1px solid var(--mkt-line-strong); border-radius: 9px;
    padding: 9px 10px; font: inherit; font-size: 13px; outline: none;
}
.tplm-field textarea { resize: vertical; line-height: 1.5; }
.tplm-field input:focus, .tplm-field select:focus, .tplm-field textarea:focus { border-color: var(--mkt-text); }
.tplm-role-fields { border-top: 1px dashed var(--mkt-line-strong); padding-top: 12px; margin-top: 4px; }
.tplm-status { margin: 4px 0 0; font-size: 12.5px; color: #f0b45c; }
.tplm-status[data-kind="error"] { color: #ff9b9b; }
.tplm-status[data-kind="ok"] { color: #7fd3a6; }

@media (max-width: 760px) {
    .tplm-main { padding: 18px 16px 70px; }
    .tplm-head-tools { width: 100%; justify-content: space-between; }
    .tplm-form-grid { grid-template-columns: 1fr; }
    .tplm-panel { width: 96vw; max-height: 92vh; }
    .tplm-panel-head, .tplm-detail-body, .tplm-form, .tplm-panel-actions { padding-left: 16px; padding-right: 16px; }
    .mkt-bar { flex-wrap: wrap; height: auto; padding: 12px 16px; gap: 10px; }
    .mkt-bar-right { width: 100%; flex-wrap: wrap; }
    .mkt-search { flex: 1 1 100%; }
}

.tplm-inline-select {
    padding: 7px 10px;
    min-width: 130px;
    border-radius: 8px;
    border: 1px solid var(--mkt-line-strong);
    background: rgba(255,255,255,.05);
    color: var(--mkt-text);
    font: inherit;
    font-size: 12px;
}
.tplm-danger { color: #ff9b9b !important; }
