/* ============================================================
   Retro File Utilities (Rust/Wasm) — Bench Tool Stylesheet
   Inherits theme tokens from style.css, themes.css & bench-tools.css
   ============================================================ */

/* Allow sticky disc visualizer inside tool-card */
#panel-retrowasm .tool-card { overflow: visible; }

.rw-header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.rw-status-pill {
    display: inline-flex; align-items: center; gap: 0.45rem;
    font-family: var(--font-mono); font-size: 0.74rem; padding: 0.35rem 0.75rem;
    border-radius: 999px; background: var(--bg-secondary); border: 1px solid var(--border);
    color: var(--text-secondary); white-space: nowrap;
}
.rw-status-pill.ready { border-color: var(--border-hover); color: var(--accent); background: var(--accent-glow); }
.rw-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }
.rw-status-pill.ready .rw-status-dot { background: var(--success); box-shadow: 0 0 8px var(--success); }

.rw-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 0.85rem; flex-wrap: wrap; padding-top: 0.85rem; border-top: 1px solid var(--border);
}
.rw-share-group { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.rw-subpanel.tool-card { margin-top: 2rem; }

.rw-drop-zone {
    border: 2px dashed var(--border-hover); border-radius: var(--radius);
    background: var(--bg-secondary); padding: 1.35rem; text-align: center;
    cursor: pointer; transition: all var(--transition); margin-bottom: 1.15rem;
}
.rw-drop-zone:hover, .rw-drop-zone.dragover { background: var(--accent-glow); border-color: var(--accent); }
.rw-drop-title { font-family: var(--font-heading); font-weight: 600; font-size: 0.96rem; color: var(--text-primary); }
.rw-drop-hint { font-family: var(--font-mono); font-size: 0.76rem; color: var(--text-muted); margin-top: 0.3rem; }

.rw-btn-row { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; margin-bottom: 1.15rem; }
.rw-btn {
    font-family: var(--font-heading); font-size: 0.8rem; font-weight: 600;
    padding: 0.48rem 0.9rem; border-radius: 8px; cursor: pointer;
    border: 1px solid var(--border); background: var(--bg-card-solid);
    color: var(--text-primary); transition: all var(--transition); white-space: nowrap;
}
.rw-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.rw-btn-primary { background: var(--accent); color: var(--bg-primary); border-color: var(--accent); }
.rw-btn-primary:hover { background: var(--accent-hover); color: var(--bg-primary); }

.rw-field-grid {
    display: flex; flex-wrap: wrap; gap: 0.85rem; align-items: flex-end;
    margin-bottom: 1.25rem; padding: 1rem;
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius);
}
.rw-field-group { display: flex; flex-direction: column; flex: 1; min-width: 140px; }
.rw-field-label {
    font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.4rem;
}
.rw-field-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.rw-input {
    width: 100%; font-family: var(--font-mono); font-size: 0.88rem; padding: 0.55rem 0.75rem;
    border-radius: 8px; background: var(--bg-card-solid); border: 1px solid var(--border);
    color: var(--text-primary); transition: border-color var(--transition), box-shadow var(--transition);
}
.rw-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.rw-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.85rem; margin-bottom: 1.25rem; }
.rw-stat-box { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.8rem 1rem; }
.rw-stat-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.rw-stat-val { font-family: var(--font-mono); font-size: 0.96rem; font-weight: 600; color: var(--accent); margin-top: 0.2rem; word-break: break-word; }
.rw-subhead { font-family: var(--font-heading); font-size: 0.94rem; font-weight: 600; color: var(--text-primary); margin: 0.5rem 0 0.4rem; }

/* Sticky Disc Track & Sector Visualizer Layout */
.rw-disc-layout { display: grid; grid-template-columns: 430px minmax(0, 1fr); gap: 1.35rem; align-items: start; }
@media (max-width: 980px) { .rw-disc-layout { grid-template-columns: minmax(0, 1fr); } }
.rw-disc-stage-wrap {
    position: sticky; top: 112px; align-self: start;
    display: flex; flex-direction: column; align-items: center;
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem;
}
@media (max-width: 980px) { .rw-disc-stage-wrap { position: static; } }
.rw-disc-canvas-box { position: relative; width: 100%; max-width: 400px; aspect-ratio: 1 / 1; }
.rw-disc-canvas-box canvas { width: 100%; height: 100%; display: block; border-radius: 8px; cursor: crosshair; }
.rw-disc-tooltip {
    position: absolute; z-index: 40; pointer-events: none; width: 265px;
    background: rgba(10, 10, 20, 0.96); border: 1px solid var(--accent); border-radius: 8px;
    padding: 0.55rem 0.7rem; font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65); line-height: 1.45;
}
.rw-disc-legend { display: flex; flex-wrap: wrap; gap: 0.45rem 0.75rem; justify-content: center; margin-top: 0.65rem; font-family: var(--font-mono); font-size: 0.69rem; color: var(--text-secondary); }
.rw-legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.rw-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.rw-swatch--free { background: rgba(0, 255, 136, 0.22); border: 1px solid #00ff88; }
.rw-swatch--used { background: #00ccff; }
.rw-swatch--sys { background: #ffbb33; }
.rw-swatch--err { background: #ff3355; }
.rw-swatch--trace { background: #00ff88; box-shadow: 0 0 6px #00ff88; }

.rw-disc-side { min-width: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.rw-trace-box, .rw-drive-links-box { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 0.9rem; }
.rw-trace-chain { font-family: var(--font-mono); font-size: 0.73rem; color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: 0.35rem; max-height: 95px; overflow-y: auto; line-height: 1.5; }
.rw-trace-step { padding: 0.12rem 0.45rem; border-radius: 4px; background: var(--bg-card-solid); border: 1px solid var(--border-hover); color: var(--accent); cursor: pointer; }
.rw-trace-step.corrupted { border-color: #ff3355; color: #ff3355; }
.rw-table tr.rw-row-active td { background: var(--accent-glow); }

/* Scrollable Directory Table with Sticky Header & Single-Line Action Buttons */
.rw-table-wrap { max-height: 330px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-secondary); }
.rw-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 0.75rem; }
.rw-table th, .rw-table td { padding: 0.45rem 0.6rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.rw-table th { position: sticky; top: 0; z-index: 2; background: var(--bg-card-solid); color: var(--text-secondary); font-weight: 600; text-transform: uppercase; font-size: 0.68rem; }
.rw-table tbody tr { cursor: pointer; }
.rw-table tbody tr:hover td { background: rgba(0, 255, 136, 0.05); }
.rw-table td:last-child { white-space: nowrap; }
.rw-table td:last-child .rw-btn { padding: 0.3rem 0.55rem; font-size: 0.72rem; }

.rw-split-view { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.25rem; width: 100%; }
.rw-split-col { min-width: 0; max-width: 100%; }
@media (max-width: 900px) { .rw-split-view { grid-template-columns: minmax(0, 1fr); } }

.rw-code-pane {
    width: 100%; max-width: 100%; background: var(--bg-secondary);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 0.85rem; font-family: var(--font-mono); font-size: 0.75rem;
    max-height: 420px; overflow: auto; white-space: pre; line-height: 1.55; margin: 0;
}
.rw-ins-row { display: grid; grid-template-columns: 56px 76px 115px minmax(0, 1fr); gap: 0.45rem; padding: 0.2rem 0.4rem; border-radius: 4px; align-items: center; }
.rw-ins-row:hover { background: var(--accent-glow); }
.rw-chip-tag {
    display: inline-flex; align-items: center; gap: 0.25rem;
    font-family: var(--font-mono); font-size: 0.7rem; padding: 0.15rem 0.55rem;
    border-radius: 999px; background: var(--accent-glow); border: 1px solid var(--border-hover); color: var(--accent);
}

.rw-bam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 0.4rem; }
.rw-bam-track { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 7px; padding: 0.38rem 0.48rem; font-family: var(--font-mono); font-size: 0.7rem; cursor: pointer; transition: border-color var(--transition), background var(--transition); }
.rw-bam-track:hover, .rw-bam-track.active { border-color: var(--accent); background: var(--accent-glow); }
.rw-bam-bits { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 0.25rem; }
.rw-bam-bit { width: 5px; height: 5px; border-radius: 1px; background: var(--accent); }
.rw-bam-bit.used { background: var(--accent-secondary); }

.rw-hw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 0.85rem; margin-top: 0.85rem; }
.rw-hw-card { background: var(--bg-secondary); border: 1px solid var(--border-hover); border-radius: var(--radius); padding: 0.9rem 1rem; }
.rw-hw-links { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; font-size: 0.72rem; }
.rw-hw-pill { padding: 0.18rem 0.55rem; border-radius: 999px; background: var(--bg-card-solid); border: 1px solid var(--border); color: var(--accent); }
.rw-hw-pill:hover { border-color: var(--accent); background: var(--accent-glow); }

.rw-sidebar-list {
    list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.6rem; padding: 0; margin: 0;
}
.rw-sidebar-list a {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.6rem 0.85rem; border-radius: 8px; background: var(--bg-secondary);
    border: 1px solid var(--border); font-size: 0.83rem; font-weight: 500; color: var(--text-primary);
}
.rw-sidebar-list a:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }

.rw-toast {
    position: fixed; bottom: 2.5rem; right: 1.5rem; z-index: 9999;
    background: var(--bg-card-solid); border: 1px solid var(--accent); color: var(--accent);
    font-family: var(--font-mono); font-size: 0.82rem; padding: 0.65rem 1.1rem; border-radius: 8px;
    opacity: 0; pointer-events: none; transition: opacity var(--transition);
}
.rw-toast.visible { opacity: 1; }
.rw-hidden { display: none !important; }
