/* TOOLS module — shared styles: picker grid (mirrors modules/labs/css/labs.css)
   plus common per-tool-page chrome reused by every tool page. Global tokens only. */

.tool-intro {
    color: var(--text-secondary);
    font-size: 1rem;
    margin: 0 0 1.5rem;
}

/* ── Picker grid ──────────────────────────────────────────── */

.tool-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 260px));
    justify-content: center;
    gap: 20px;
    padding: 24px 40px 40px;
    max-width: 1100px;
    margin: 0 auto;
}

.tool-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1rem;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    color: inherit;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    max-width: 260px;
}

.tool-tile[hidden] { display: none; }

.tool-tile:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.tool-tile-icon {
    width: 96px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, var(--color-primary-soft), var(--bg-surface));
    color: var(--color-primary);
    box-shadow: inset 0 0 0 1px var(--border-soft);
    transition: transform 0.15s ease, color 0.15s ease;
}

.tool-tile:hover .tool-tile-icon {
    transform: rotate(-3deg) scale(1.04);
    color: var(--color-primary-hover);
}

.tool-tile-icon svg {
    width: 60px;
    height: 60px;
    display: block;
}

.tool-tile h3 {
    margin: 0;
}

.tool-tile p {
    font-size: 0.9rem;
    opacity: 0.85;
    margin: 0;
}

/* NEW pill + favorite star, both server-rendered inert / JS-enhanced */

.tool-tile-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0.25rem 0;
}

.tool-tile-new {
    display: inline-block;
    padding: 1px 7px;
    border-radius: var(--radius-pill);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--status-fresh-text);
    background: var(--status-fresh-bg);
    border: 1px solid var(--status-fresh-border);
    white-space: nowrap;
}

.tool-tile-fav {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    padding: 0 0 3px; /* optical nudge — the star glyph's ink sits low in its em box */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}

/* Explicit background — the global button:hover (0,1,1) otherwise fills the circle dark blue. */
.tool-tile-fav:hover {
    background: var(--bg-surface);
    border-color: var(--border-strong);
}

.tool-tile-fav[aria-pressed="true"] {
    color: var(--color-warning-strong);
    border-color: var(--color-warning);
    background: var(--color-warning-soft);
}

.tool-tile-fav[aria-pressed="true"]:hover {
    background: var(--color-warning-soft);
}

/* Recently-used chip row — JS-populated, hidden until tools.recent has entries */

.tool-recent-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 0 0 1rem;
}

.tool-recent-row[hidden] { display: none; }

.tool-recent-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.tool-recent-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tool-recent-chip {
    display: inline-block;
    padding: 3px 10px;
    font-size: 0.8rem;
    border-radius: var(--radius-pill);
    background: var(--color-primary-soft);
    color: var(--text-link);
    text-decoration: none;
    border: 1px solid var(--border-soft);
}

.tool-recent-chip:hover {
    background: var(--border-soft);
    text-decoration: underline;
}

/* Filter input — plain input, no <form> wrapper, so no width/form traps apply. */

.tool-filter-row {
    display: flex;
    justify-content: center;
    margin: 0 0 1.25rem;
}

.tool-filter-input {
    width: 100%;
    max-width: 320px;
    padding: 8px 12px;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-primary);
}

.tool-empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 20px 0 8px;
}

/* ── Per-tool page chrome (shared by every tool) ─────────────── */

.tool-wrap {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px;
}

.tool-wrap-wide {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px;
}

.tool-note {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin: 0 0 16px;
}

.tool-note-warn {
    color: var(--color-warning-strong);
    background: var(--color-warning-soft);
    border-color: var(--color-warning);
}

.tool-section {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 20px;
    margin-bottom: 16px;
}

.tool-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.tool-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.tool-field-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.tool-field-row .tool-field {
    flex: 1 1 160px;
    min-width: 140px;
}

.tool-field-check {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.tool-field-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.tool-textarea {
    font-family: var(--font-family-mono);
    font-size: 0.9rem;
    min-height: 140px;
}

.tool-input-mono {
    font-family: var(--font-family-mono);
    font-size: 0.9rem;
}

.tool-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 0;
}

.tool-btn {
    /* overrides global button{width:100%} — tool buttons sit compact, not full-width */
    width: auto;
    padding: 8px 16px;
    font-size: 0.9rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-primary);
    background: var(--color-primary);
    color: var(--text-inverse);
    cursor: pointer;
}

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

.tool-btn-secondary {
    background: transparent;
    color: var(--color-primary);
}

.tool-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Active state must survive hover (idle hover uses the same shade) — ring + weight, not color-only. */
.tool-btn.is-active {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    box-shadow: inset 0 0 0 2px var(--text-inverse);
    font-weight: 600;
}

.tool-output {
    min-height: 48px;
    padding: 12px;
    background: var(--bg-surface-alt);
    border-radius: var(--radius-md);
    font-family: var(--font-family-mono);
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
    margin-top: 12px;
}

.tool-output:empty {
    display: none;
}

.tool-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 8px;
}

@media (max-width: 720px) {
    .tool-list {
        grid-template-columns: 1fr;
        padding: 16px;
        gap: 12px;
    }

    .tool-tile {
        max-width: 100%;
    }

    .tool-filter-input {
        max-width: 100%;
    }

    .tool-wrap,
    .tool-wrap-wide {
        padding: 12px 8px;
    }

    .tool-section {
        padding: 14px;
    }

    /* Compact action buttons — text matches .tool-field label size. */
    .tool-btn { padding: 5px 10px; font-size: var(--font-size-sm); }
    .tool-actions { gap: 6px; }
}
