/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
    --sidebar-w:      220px;
    --sidebar-bg:     #1a1a2e;
    --sidebar-hover:  #16213e;
    --sidebar-active: #0f3460;
    --sidebar-text:   #c8cdd5;
    --sidebar-dim:    #6b7280;

    --topbar-h:       52px;
    --topbar-bg:      #ffffff;
    --topbar-border:  #e5e7eb;

    --content-bg:     #f3f4f6;
    --card-bg:        #ffffff;
    --card-shadow:    0 1px 3px rgba(0,0,0,.08);
    --card-radius:    8px;

    --color-run:      #16a34a;
    --color-run-bg:   #dcfce7;
    --color-stop:     #dc2626;
    --color-stop-bg:  #fee2e2;
    --color-warn:     #d97706;
    --color-warn-bg:  #fef3c7;

    --log-bg:   #0d1117;
    --log-text: #c9d1d9;
    --log-ts:   #6e7681;
}

/* ── Reset / base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--content-bg); color: #111827; }
a    { color: inherit; }

/* ── Admin layout grid ─────────────────────────────────────────────────────── */
.admin-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
    background:    var(--sidebar-bg);
    color:         var(--sidebar-text);
    display:       flex;
    flex-direction: column;
    position:      sticky;
    top:           0;
    height:        100vh;
    overflow-y:    auto;
    overflow-x:    hidden;
}

.sidebar-logo {
    display:     flex;
    align-items: center;
    gap:         .6rem;
    padding:     1.25rem 1rem;
    font-weight: 700;
    font-size:   1rem;
    border-bottom: 1px solid #2d2d4e;
    white-space: nowrap;
}

.logo-icon { font-size: 1.2rem; }

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: .5rem 0;
}

.sidebar-nav ul {
    list-style: none;
    margin:  0;
    padding: 0;
}

.sidebar-nav ul li a {
    display:      flex;
    align-items:  center;
    gap:          .65rem;
    padding:      .55rem 1rem;
    font-size:    .875rem;
    color:        var(--sidebar-text);
    text-decoration: none;
    border-left:  3px solid transparent;
    transition:   background .1s, border-color .1s;
    white-space:  nowrap;
}

.sidebar-nav ul li a:hover {
    background:   var(--sidebar-hover);
}

.sidebar-nav ul li a.active {
    background:    var(--sidebar-active);
    border-color:  #4a9eff;
    color:         #fff;
}

.nav-section-label {
    margin:      1rem 1rem .25rem;
    font-size:   .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color:       var(--sidebar-dim);
}

.sidebar-footer {
    padding:     1rem;
    border-top:  1px solid #2d2d4e;
    font-size:   .75rem;
    color:       var(--sidebar-dim);
}

/* ── Main area ─────────────────────────────────────────────────────────────── */
.main-wrap {
    display:        flex;
    flex-direction: column;
    min-height:     100vh;
}

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    height:          var(--topbar-h);
    padding:         0 1.5rem;
    background:      var(--topbar-bg);
    border-bottom:   1px solid var(--topbar-border);
    position:        sticky;
    top:             0;
    z-index:         10;
}

.topbar-title {
    font-weight: 600;
    font-size:   1.05rem;
}

/* ── Server pill (topbar) ──────────────────────────────────────────────────── */
.server-pill {
    display:      inline-flex;
    align-items:  center;
    gap:          .4rem;
    padding:      .25rem .75rem;
    border-radius: 999px;
    font-size:    .8rem;
    font-weight:  600;
}

.server-pill.running  { background: var(--color-run-bg);  color: var(--color-run);  }
.server-pill.stopped  { background: var(--color-stop-bg); color: var(--color-stop); }

/* ── Page content ──────────────────────────────────────────────────────────── */
.page-content {
    flex:    1;
    padding: 1.5rem;
    max-width: 1200px;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
    background:    var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow:    var(--card-shadow);
    padding:       1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.card h2 {
    margin:      0 0 1rem;
    font-size:   1rem;
    font-weight: 600;
    color:       #374151;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: .5rem;
}

/* ── Stat grid (dashboard) ─────────────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap:     1rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background:    var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow:    var(--card-shadow);
    padding:       1.1rem 1.25rem;
}

.stat-label {
    font-size:   .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color:       #6b7280;
    margin-bottom: .35rem;
}

.stat-value {
    font-size:   1.65rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: .25rem;
}

.stat-sub {
    font-size: .8rem;
    color:     #9ca3af;
}

.disk-bar {
    height:        6px;
    border-radius: 3px;
    background:    #e5e7eb;
    margin-top:    .6rem;
    overflow:      hidden;
}

.disk-fill {
    height:        100%;
    border-radius: 3px;
    background:    #3b82f6;
    transition:    width .4s;
}

.disk-fill.disk-warn { background: var(--color-warn); }

/* ── Status badge ──────────────────────────────────────────────────────────── */
.status-badge {
    display:      inline-flex;
    align-items:  center;
    gap:          .45rem;
    padding:      .3rem .85rem;
    border-radius: 999px;
    font-size:    .85rem;
    font-weight:  600;
}

.status-badge.running { background: var(--color-run-bg);  color: var(--color-run);  }
.status-badge.stopped { background: var(--color-stop-bg); color: var(--color-stop); }

/* Pulsing dot */
.dot {
    display:       inline-block;
    width:         8px;
    height:        8px;
    border-radius: 50%;
    background:    currentColor;
}

.running .dot { animation: pulse 2s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .35; }
}

/* ── Status row (server page) ──────────────────────────────────────────────── */
.status-row {
    display:     flex;
    align-items: center;
    gap:         1.25rem;
    flex-wrap:   wrap;
}

.status-meta {
    display:   flex;
    gap:       1.25rem;
    font-size: .875rem;
    color:     #4b5563;
}

.status-meta span strong {
    color: #111827;
}

.badge-external {
    background:    #fef3c7;
    color:         #92400e;
    border-radius: 4px;
    padding:       .1rem .4rem;
    font-size:     .75rem;
    font-weight:   600;
}

/* ── Action buttons ────────────────────────────────────────────────────────── */
.action-row {
    display:   flex;
    gap:       .75rem;
    flex-wrap: wrap;
    align-items: center;
}

.btn {
    display:       inline-flex;
    align-items:   center;
    gap:           .35rem;
    padding:       .5rem 1.1rem;
    border:        none;
    border-radius: 6px;
    font-size:     .875rem;
    font-weight:   600;
    cursor:        pointer;
    text-decoration: none;
    transition:    opacity .15s, filter .15s;
    white-space:   nowrap;
}

.btn:disabled {
    opacity: .45;
    cursor:  not-allowed;
}

.btn:not(:disabled):hover { filter: brightness(.92); }

.btn-primary  { background: #2563eb; color: #fff; }
.btn-warn     { background: var(--color-warn); color: #fff; }
.btn-danger   { background: var(--color-stop); color: #fff; }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-sm       { padding: .3rem .7rem; font-size: .8rem; }

/* ── Command display ───────────────────────────────────────────────────────── */
.cmd-display {
    margin:     .75rem 0 .25rem;
    padding:    .5rem .75rem;
    background: #f3f4f6;
    border-radius: 6px;
    font-size:  .8rem;
    overflow-x: auto;
}

/* ── Log terminal ──────────────────────────────────────────────────────────── */
.log-header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    margin-bottom:   .75rem;
}

.log-header h2 { margin: 0; border: none; padding: 0; }

.log-controls {
    display:     flex;
    align-items: center;
    gap:         .75rem;
}

.log-toggle {
    display:     flex;
    align-items: center;
    gap:         .35rem;
    font-size:   .8rem;
    cursor:      pointer;
    user-select: none;
}

.log-status {
    font-size:    .75rem;
    font-weight:  600;
    margin-bottom: .5rem;
    padding:      .2rem .6rem;
    border-radius: 4px;
    display:      inline-block;
}

.log-status.connecting   { background: #fef3c7; color: #92400e; }
.log-status.live         { background: var(--color-run-bg); color: var(--color-run); }
.log-status.disconnected { background: var(--color-stop-bg); color: var(--color-stop); }

.log-viewer {
    background:    var(--log-bg);
    color:         var(--log-text);
    border-radius: 6px;
    padding:       .75rem 1rem;
    font-family:   'Consolas', 'Monaco', 'Fira Mono', monospace;
    font-size:     .78rem;
    line-height:   1.55;
    height:        480px;
    overflow-y:    auto;
    white-space:   pre-wrap;
    word-break:    break-all;
    scroll-behavior: smooth;
}

.log-line        { padding: 1px 0; }
.log-line.log-error { color: #ff7b72; }
.log-line.log-warn  { color: #e3b341; }
.log-line.log-info  { color: var(--log-text); }

.log-ts { color: var(--log-ts); }

/* ── Table ─────────────────────────────────────────────────────────────────── */
table {
    width:          100%;
    border-collapse: collapse;
    font-size:      .875rem;
}

th, td {
    padding:     .6rem .75rem;
    text-align:  left;
    border-bottom: 1px solid #f0f0f0;
}

th {
    font-weight: 600;
    color:       #6b7280;
    font-size:   .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

tr:last-child td { border-bottom: none; }
tr:hover td      { background: #fafafa; }

/* ── Utilities ─────────────────────────────────────────────────────────────── */
.muted { color: #9ca3af; font-size: .875rem; }

/* Override Pico padding on main so our layout isn't broken */
main { padding: 0 !important; }

/* ── Flash / alert messages ────────────────────────────────────────────────── */
.flash {
    padding:       .65rem 1rem;
    border-radius: 6px;
    font-size:     .875rem;
    margin-bottom: 1rem;
}

.flash-success { background: var(--color-run-bg);  color: var(--color-run);  }
.flash-error   { background: var(--color-stop-bg); color: var(--color-stop); }
.flash-warn    { background: var(--color-warn-bg); color: var(--color-warn); }

/* ── Online / offline pills ────────────────────────────────────────────────── */
.online-pill {
    display:      inline-flex;
    align-items:  center;
    gap:          .35rem;
    font-size:    .75rem;
    font-weight:  600;
    color:        var(--color-run);
    background:   var(--color-run-bg);
    padding:      .2rem .55rem;
    border-radius: 999px;
}

.offline-pill {
    font-size:    .75rem;
    color:        #9ca3af;
}

/* ── Users two-column layout ───────────────────────────────────────────────── */
.users-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap:     1.25rem;
    align-items: start;
}

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

/* List panel */
.users-list-panel { overflow: hidden; }

.users-list-header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    gap:             1rem;
    margin-bottom:   .75rem;
    flex-wrap:       wrap;
}

.users-list-header h2 {
    margin:  0;
    border:  none;
    padding: 0;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.user-count-badge {
    background:    #e5e7eb;
    color:         #374151;
    font-size:     .75rem;
    font-weight:   600;
    padding:       .1rem .5rem;
    border-radius: 999px;
}

.user-search {
    padding:       .45rem .75rem;
    border:        1px solid #d1d5db;
    border-radius: 6px;
    font-size:     .875rem;
    width:         180px;
    transition:    border-color .15s;
}

.user-search:focus {
    outline:      none;
    border-color: #2563eb;
    box-shadow:   0 0 0 3px rgba(37,99,235,.12);
}

.users-table { font-size: .85rem; }

.user-row {
    cursor: pointer;
    transition: background .1s;
}

.user-row:hover td { background: #eff6ff; }

.uid   { color: #9ca3af; width: 3rem; }
.uname { font-weight: 600; }
.udate { color: #9ca3af; }

.empty-row { text-align: center; color: #9ca3af; padding: 1.5rem !important; }

/* Detail panel */
.users-detail-panel { min-height: 300px; }

.detail-empty {
    display:        flex;
    flex-direction: column;
    align-items:    center;
    justify-content: center;
    min-height:     240px;
    color:          #9ca3af;
    text-align:     center;
    gap:            .5rem;
}

.detail-empty-icon { font-size: 2.5rem; }

/* Detail inner layout */
.detail-header {
    display:     flex;
    align-items: center;
    gap:         1rem;
    margin-bottom: 1rem;
    flex-wrap:   wrap;
}

.detail-avatar {
    width:          52px;
    height:         52px;
    border-radius:  50%;
    background:     #2563eb;
    color:          #fff;
    display:        flex;
    align-items:    center;
    justify-content: center;
    font-size:      1.4rem;
    font-weight:    700;
    flex-shrink:    0;
}

.detail-name {
    margin:     0;
    font-size:  1.15rem;
    border:     none;
    padding:    0;
}

.detail-id {
    font-size: .8rem;
    color:     #9ca3af;
}

.detail-status-pill { margin-left: auto; }

.detail-table {
    font-size: .85rem;
    margin-bottom: 0;
}

.detail-table th {
    width:       130px;
    font-size:   .75rem;
    color:       #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.detail-divider {
    border:     none;
    border-top: 1px solid #f0f0f0;
    margin:     1rem 0;
}

/* Accordion sections */
.detail-section {
    margin-bottom: .5rem;
}

.detail-section-title {
    font-size:   .875rem;
    font-weight: 600;
    cursor:      pointer;
    color:       #374151;
    user-select: none;
    padding:     .35rem 0;
}

.detail-section-title:hover { color: #2563eb; }

.danger-summary:hover { color: var(--color-stop) !important; }

.detail-form {
    padding:    .75rem 0 0;
    display:    flex;
    flex-direction: column;
    gap:        .6rem;
}

.detail-form label {
    display:     flex;
    flex-direction: column;
    gap:         .3rem;
    font-size:   .8rem;
    font-weight: 600;
    color:       #4b5563;
}

.detail-form input {
    padding:       .45rem .7rem;
    border:        1px solid #d1d5db;
    border-radius: 6px;
    font-size:     .875rem;
    transition:    border-color .15s;
}

.detail-form input:focus {
    outline:      none;
    border-color: #2563eb;
    box-shadow:   0 0 0 3px rgba(37,99,235,.12);
}

.detail-warn {
    font-size:    .825rem;
    color:        #92400e;
    background:   #fef3c7;
    padding:      .6rem .8rem;
    border-radius: 6px;
    margin:       .5rem 0;
}

/* ── File browser ──────────────────────────────────────────────────────────── */
.file-root-tabs {
    display:  flex;
    gap:      .5rem;
    margin-bottom: 1rem;
}

.file-root-tab {
    padding:       .35rem .9rem;
    border-radius: 6px;
    font-size:     .85rem;
    font-weight:   600;
    text-decoration: none;
    background:    #f3f4f6;
    color:         #374151;
    transition:    background .1s;
}

.file-root-tab:hover  { background: #e5e7eb; }
.file-root-tab.active { background: #2563eb; color: #fff; }

.file-breadcrumb {
    display:     flex;
    align-items: center;
    flex-wrap:   wrap;
    gap:         .3rem;
    font-size:   .875rem;
    margin-bottom: 1rem;
    padding:     .5rem .75rem;
    background:  #f9fafb;
    border-radius: 6px;
}

.file-breadcrumb a { color: #2563eb; text-decoration: none; }
.file-breadcrumb a:hover { text-decoration: underline; }

.crumb-sep     { color: #9ca3af; }
.crumb-current { font-weight: 600; color: #111827; }

.file-table { font-size: .875rem; }

.dir-row td { background: #fafafa; }
.dir-row:hover td { background: #eff6ff !important; }

.dir-link {
    text-decoration: none;
    color:     #2563eb;
    font-weight: 600;
}

.dir-link:hover { text-decoration: underline; }

.file-icon { color: #9ca3af; }

.col-size   { width: 90px;  text-align: right; }
.col-mtime  { width: 145px; }
.col-action { width: 110px; text-align: right; }

/* ── Games page ────────────────────────────────────────────────────────────── */
.games-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

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

.games-list-panel {
    flex: 0 1 50%;
    min-width: 450px;
    max-width: 750px;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid var(--border-color);
}
.games-detail-panel {
    flex: 1 1 auto;
    min-width: 300px;
    overflow-y: auto;
    padding: 1rem;
}

.games-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .75rem;
    flex-wrap: wrap;
}

.games-list-header h2 {
    margin: 0; border: none; padding: 0;
    display: flex; align-items: center; gap: .5rem;
}

.games-list-actions {
    display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
}

.run-all-row {
    margin-bottom: .65rem;
}

.games-table { font-size: .85rem; }

.game-row {
    cursor: pointer;
    transition: background .1s;
}
.game-row:hover td { background: #eff6ff; }

.game-row-name { font-weight: 600; }
.game-row-id   { font-size: .75rem; }

/* Platform badges */
.platform-badge {
    display:      inline-block;
    padding:      .15rem .5rem;
    border-radius: 4px;
    font-size:    .72rem;
    font-weight:  700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.plat-windows { background: #dbeafe; color: #1e40af; }
.plat-linux   { background: #fef9c3; color: #854d0e; }
.plat-xbox360 { background: #dcfce7; color: #166534; }
.plat-wiiu    { background: #ede9fe; color: #5b21b6; }
.plat-  { background: #f3f4f6; color: #6b7280; }

/* Status dots */
.game-status-badges { display: flex; gap: .3rem; align-items: center; }
.status-dot { font-size: .85rem; }
.status-dot.indexed   { color: var(--color-run); }
.status-dot.unindexed { color: #9ca3af; }
.status-dot.warn      { color: var(--color-warn); }
.status-dot.error     { color: var(--color-stop); }
.status-dot.running   { color: #2563eb; animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); display: inline-block; } }

/* Game detail panel */
.game-detail-inner { padding: 0; }

.game-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.game-detail-name { margin: 0; font-size: 1.15rem; border: none; padding: 0; }
.game-detail-id   { font-size: .8rem; color: #9ca3af; }
.game-detail-badges { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.detail-meta-row {
    display:       flex;
    align-items:   baseline;
    gap:           .75rem;
    font-size:     .85rem;
    margin-bottom: .5rem;
}
.detail-meta-label {
    font-size:   .75rem;
    font-weight: 700;
    text-transform: uppercase;
    color:       #6b7280;
    min-width:   110px;
}

.version-chip {
    display:       inline-block;
    background:    #f3f4f6;
    border-radius: 4px;
    padding:       .1rem .45rem;
    font-size:     .78rem;
    font-family:   monospace;
    margin-right:  .25rem;
}
.version-latest { background: #dcfce7; color: #166534; }

.detail-actions {
    display:   flex;
    flex-wrap: wrap;
    gap:       .5rem;
    margin:    .75rem 0;
}

/* Task panel */
.task-panel { margin-top: .75rem; }

.task-panel-header {
    display:         flex;
    justify-content: space-between;
    align-items:     center;
    margin-bottom:   .5rem;
    font-size:       .875rem;
}

.task-status-badge {
    font-size:    .78rem;
    font-weight:  700;
    padding:      .2rem .55rem;
    border-radius: 4px;
    background:   #dbeafe;
    color:        #1e40af;
}
.task-ok  { background: var(--color-run-bg);  color: var(--color-run);  }
.task-err { background: var(--color-stop-bg); color: var(--color-stop); }

.task-log { height: 280px; }

.task-busy { color: var(--color-warn); font-size: .875rem; margin: .5rem 0; }

.task-done-bar {
    padding:       .5rem .75rem;
    border-radius: 6px;
    font-size:     .85rem;
    margin-top:    .5rem;
}
.task-done-done  { background: var(--color-run-bg);  color: var(--color-run);  }
.task-done-error { background: var(--color-stop-bg); color: var(--color-stop); }

/* SteamGridDB ID prompt */
.sgdb-id-prompt { padding: .5rem 0; }
.inline-id-row  { display: flex; gap: .5rem; align-items: center; margin: .5rem 0; }
.sgdb-id-input  {
    padding: .45rem .7rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: .875rem;
    width: 160px;
}

/* ── Game form ──────────────────────────────────────────────────────────────── */
.form-layout { max-width: 900px; }

.form-card { margin-bottom: 1.25rem; }
.form-card h2 { font-size: 1rem; }

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: .75rem;
}
@media (max-width: 720px) { .form-grid-2 { grid-template-columns: 1fr; } }

.form-label {
    display:       flex;
    flex-direction: column;
    gap:           .35rem;
    font-size:     .85rem;
    font-weight:   600;
    color:         #374151;
    margin-bottom: .75rem;
}

.form-label input,
.form-label select,
.form-label textarea {
    padding:       .5rem .75rem;
    border:        1px solid #d1d5db;
    border-radius: 6px;
    font-size:     .875rem;
    font-family:   inherit;
    transition:    border-color .15s;
}
.form-label input:focus,
.form-label select:focus,
.form-label textarea:focus {
    outline:      none;
    border-color: #2563eb;
    box-shadow:   0 0 0 3px rgba(37,99,235,.1);
}

.input-readonly {
    background: #f9fafb !important;
    color:      #6b7280 !important;
    cursor:     not-allowed;
}

.code-textarea {
    font-family: 'Consolas', 'Monaco', 'Fira Mono', monospace !important;
    font-size:   .8rem !important;
    background:  #f9fafb;
    resize:      vertical;
}

.field-hint { font-size: .78rem; font-weight: 400; color: #9ca3af; }
.required   { color: var(--color-stop); }

.field-doc summary { cursor: pointer; color: #2563eb; font-size: .8rem; font-weight: 600; margin-bottom: .35rem; }
.code-block {
    background: #1e1e2e;
    color:      #cdd6f4;
    padding:    .65rem .9rem;
    border-radius: 6px;
    font-size:  .8rem;
    overflow-x: auto;
    margin:     .35rem 0 0;
}

.auto-fields {
    display:       flex;
    flex-direction: column;
    gap:           .3rem;
    margin-top:    .5rem;
    padding:       .5rem .75rem;
    background:    #f9fafb;
    border-radius: 6px;
    font-size:     .8rem;
}
.auto-field { display: flex; gap: .75rem; align-items: center; }
.auto-label { font-weight: 600; color: #6b7280; min-width: 110px; }

.conditional-row { margin-bottom: .75rem; }

.versions-hint {
    margin-bottom: .75rem;
    font-size: .82rem;
    color: #6b7280;
}

/* Soundtrack helper */
.soundtrack-helper {
    margin-top: .75rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}
.soundtrack-helper summary {
    padding: .5rem .75rem;
    cursor: pointer;
    font-size: .85rem;
    font-weight: 600;
    color: #374151;
    background: #f9fafb;
    border-radius: 6px;
}
.soundtrack-helper[open] summary { border-radius: 6px 6px 0 0; }
.soundtrack-helper-body { padding: .75rem; }

/* Metadata fetch draft */
.metadata-fetch-draft summary { cursor: pointer; }
.metadata-fetch-draft h2 { margin-bottom: 0; border: none; padding: 0; display: inline; }

.badge-draft {
    background:    #fef3c7;
    color:         #92400e;
    font-size:     .7rem;
    padding:       .15rem .45rem;
    border-radius: 4px;
    font-weight:   600;
    vertical-align: middle;
    margin-left:   .35rem;
}

.fetch-sources { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: .75rem; }
@media (max-width: 720px) { .fetch-sources { grid-template-columns: 1fr; } }

.fetch-source-card {
    border:        1px solid #e5e7eb;
    border-radius: 8px;
    padding:       1rem;
    background:    #fafafa;
}
.fetch-source-header {
    display:         flex;
    justify-content: space-between;
    align-items:     baseline;
    margin-bottom:   .3rem;
}
.fetch-fields {
    display: flex; gap: .75rem; flex-wrap: wrap;
    font-size: .8rem; margin: .5rem 0;
}
.fetch-diff-placeholder {
    margin-top:    .5rem;
    padding:       .5rem;
    border:        1px dashed #d1d5db;
    border-radius: 4px;
    font-size:     .78rem;
    text-align:    center;
}

/* Submit row */
.form-submit-row {
    display:     flex;
    align-items: center;
    gap:         .75rem;
    flex-wrap:   wrap;
    margin-bottom: 2rem;
}
.form-submit-hint { font-size: .8rem; }

/* ── Mods ──────────────────────────────────────────────────────────────────── */

.section-header-row { margin-bottom: 1rem; }

/* Games grid on /mods landing */
.mods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.mod-game-card {
    display:       block;
    background:    var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow:    var(--card-shadow);
    padding:       1.1rem 1.25rem;
    text-decoration: none;
    color:         inherit;
    transition:    box-shadow .15s, transform .15s;
    border:        2px solid transparent;
}
.mod-game-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    transform:  translateY(-2px);
    border-color: #2563eb;
}
.mod-game-card-name {
    font-weight:   700;
    font-size:     .95rem;
    margin-bottom: .35rem;
}
.mod-game-card-sub {
    display:     flex;
    align-items: center;
    gap:         .5rem;
    font-size:   .78rem;
}
.mod-count-chip {
    background:    #dbeafe;
    color:         #1e40af;
    padding:       .1rem .45rem;
    border-radius: 999px;
    font-weight:   600;
    font-size:     .72rem;
}
.mod-game-card-warn {
    margin-top: .4rem;
    font-size:  .75rem;
    color:      var(--color-warn);
}

/* Mods game page layout */
.mods-page-layout {
    display: grid;
    grid-template-columns: 5fr 4fr;
    gap:     1.25rem;
    align-items: start;
    margin-bottom: 1.25rem;
}
@media (max-width: 1050px) { .mods-page-layout { grid-template-columns: 1fr; } }

.mods-list-panel  { overflow: hidden; }
.mods-detail-panel { min-height: 300px; }

.mods-list-header {
    display:         flex;
    align-items:     flex-start;
    justify-content: space-between;
    gap:             .75rem;
    margin-bottom:   .75rem;
    flex-wrap:       wrap;
}
.mods-list-header h2 {
    margin: 0; border: none; padding: 0;
    display: flex; align-items: center; gap: .5rem;
}

.mod-list-scroll {
    max-height: 580px;
    overflow-y: auto;
    overflow-x: hidden;
}

.mods-table { font-size: .82rem; width: 100%; }

.mod-row {
    cursor: pointer;
    transition: background .1s;
}
.mod-row:hover td { background: #eff6ff; }

.col-thumb { width: 52px; padding: .35rem .5rem !important; }
.mod-thumb {
    width:         44px;
    height:        44px;
    object-fit:    cover;
    border-radius: 4px;
    display:       block;
}
.mod-thumb-placeholder {
    width:       44px;
    height:      44px;
    display:     flex;
    align-items: center;
    justify-content: center;
    background:  #f3f4f6;
    border-radius: 4px;
    font-size:   1.4rem;
}

.mod-row-title { font-weight: 600; }
.mod-row-warn  { font-size: .75rem; }

.mod-tag {
    display:       inline-block;
    background:    #f3f4f6;
    color:         #374151;
    border-radius: 4px;
    padding:       .1rem .4rem;
    font-size:     .72rem;
    margin-right:  .2rem;
}

/* Mod detail panel */
.mod-detail-inner { }

.mod-detail-preview {
    margin-bottom: 1rem;
    text-align: center;
}
.mod-detail-preview img {
    max-width:     100%;
    max-height:    220px;
    object-fit:    contain;
    border-radius: 6px;
    box-shadow:    0 1px 6px rgba(0,0,0,.1);
}

.mod-detail-header { margin-bottom: .6rem; }
.mod-detail-title  { margin: 0 0 .2rem; font-size: 1rem; }
.mod-detail-id     { font-size: .78rem; }

.mod-detail-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .75rem; }

.mod-meta-table th { width: 80px; }

.mod-description {
    font-size:   .82rem;
    line-height: 1.5;
    white-space: pre-wrap;
    margin-top:  .5rem;
    max-height:  200px;
    overflow-y:  auto;
}

.required-mods-list {
    font-size:   .82rem;
    padding:     .5rem 0 0 1rem;
    margin:      0;
}
.required-mods-list li { margin-bottom: .25rem; }

/* Actions panel */
.mods-actions-panel h2 { font-size: 1rem; }

.mods-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
}

.action-card {
    border:        1px solid #e5e7eb;
    border-radius: 8px;
    padding:       1rem 1.1rem;
    background:    #fafafa;
}
.action-card h3 {
    margin:      0 0 .5rem;
    font-size:   .95rem;
    font-weight: 700;
}
.action-card .form-label { margin-bottom: .5rem; }
.action-card .btn { margin-top: .25rem; }

.mod-checkbox-label {
    display:     flex;
    align-items: center;
    gap:         .5rem;
    font-size:   .85rem;
    margin:      .5rem 0;
    cursor:      pointer;
}

.game-row-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.game-row-icon {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.game-row-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

/* ── Image upload widget (game form) ───────────────────────────────────────── */
.img-upload-widget {
    display:        flex;
    flex-direction: column;
    gap:            .5rem;
}

.img-upload-preview {
    width:         100%;
    max-height:    180px;
    object-fit:    contain;
    border-radius: 6px;
    border:        1px solid #e5e7eb;
    background:    #f9fafb;
    display:       block;
}

.img-upload-placeholder {
    width:           100%;
    height:          120px;
    display:         flex;
    align-items:     center;
    justify-content: center;
    border:          2px dashed #d1d5db;
    border-radius:   6px;
    background:      #f9fafb;
    color:           #9ca3af;
    font-size:       .85rem;
}

.img-upload-controls {
    display:     flex;
    align-items: center;
    gap:         .6rem;
    flex-wrap:   wrap;
}

/* The label acts as the button; file input is hidden inside */
.img-file-btn {
    cursor:    pointer;
    font-size: .8rem !important;
}

.img-pending-badge {
    font-size:     .78rem;
    color:         #1e40af;
    background:    #dbeafe;
    padding:       .2rem .55rem;
    border-radius: 4px;
    font-weight:   600;
}

.img-missing-warn {
    color:       var(--color-warn);
    font-size:   .78rem;
    font-weight: 600;
    margin-left: .3rem;
}

/* ── Game form (rules-driven) ───────────────────────────────────────────────── */

.form-topbar {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    flex-wrap:       wrap;
    gap:             .6rem;
    margin-bottom:   1rem;
    padding:         .6rem .9rem;
    background:      var(--card-bg);
    border-radius:   var(--card-radius);
    box-shadow:      var(--card-shadow);
}
.form-topbar-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* Version-dict */
.vdict-label-row { display: flex; align-items: center; gap: .6rem; font-weight: 600; margin-bottom: .5rem; }
.vdict-mode-btn  { font-size: .75rem !important; padding: .2rem .6rem !important; }
.vdict-body      { display: flex; flex-direction: column; gap: .4rem; }
.vdict-row       { display: flex; align-items: center; gap: .5rem; }
.vdict-ver-label { font-size: .75rem; min-width: 90px; }
.vdict-input     { flex: 1; padding: .4rem .65rem; border: 1px solid #d1d5db; border-radius: 6px; font-size: .875rem; }
.vdict-raw       { margin-top: .5rem; font-size: .78rem; color: #6b7280; }
.vdict-raw summary { cursor: pointer; }

/* List-of-dict */
.lod-label-row   { display: flex; align-items: center; gap: .6rem; font-weight: 600; margin-bottom: .5rem; }
.lod-list        { display: flex; flex-direction: column; gap: .75rem; }
.lod-entry       { border: 1px solid #e5e7eb; border-radius: 6px; padding: .75rem; background: #fafafa; }
.lod-entry-header{ display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.lod-entry-num   { font-size: .8rem; font-weight: 700; color: #6b7280; }
.lod-field-row   { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.lod-field-label { font-size: .78rem; font-weight: 600; color: #4b5563; min-width: 110px; flex-shrink: 0; }
.lod-field-input { flex: 1; padding: .35rem .6rem; border: 1px solid #d1d5db; border-radius: 5px; font-size: .82rem; }

/* List-of-string */
.los-wrap   { display: flex; flex-direction: column; gap: .35rem; }
.los-items  { display: flex; flex-direction: column; gap: .3rem; }
.los-row    { display: flex; gap: .35rem; align-items: center; }
.los-input  { flex: 1; padding: .3rem .55rem; border: 1px solid #d1d5db; border-radius: 5px; font-size: .82rem; }
.los-add    { margin-top: .2rem; }

/* Extras */
.extras-add-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .75rem; }
.extras-key-input, .extras-val-input { padding: .4rem .65rem; border: 1px solid #d1d5db; border-radius: 6px; font-size: .82rem; }
.extras-key-input { width: 150px; }
.extras-val-input { flex: 1; min-width: 180px; }
.extras-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; flex-wrap: wrap; }
.extras-key { font-size: .8rem; font-weight: 700; color: #374151; min-width: 120px; font-family: monospace; }

/* ── Settings page ──────────────────────────────────────────────────────────── */

.settings-tabs {
    display:       flex;
    gap:           .5rem;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: .5rem;
}
.settings-tab {
    padding:         .4rem 1rem;
    border-radius:   6px 6px 0 0;
    font-weight:     600;
    font-size:       .875rem;
    text-decoration: none;
    color:           #6b7280;
    background:      transparent;
    transition:      background .1s;
}
.settings-tab.active { background: #2563eb; color: #fff; }
.settings-tab:hover:not(.active) { background: #f3f4f6; }

.settings-actions-row {
    display:       flex;
    align-items:   center;
    gap:           .75rem;
    flex-wrap:     wrap;
    margin-bottom: 1rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap:     1.25rem;
    align-items: start;
}
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }

.settings-panel { }
.settings-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: .75rem;
}
.settings-panel-header h2 { margin: 0; border: none; padding: 0; }

.settings-row {
    display:       flex;
    align-items:   center;
    justify-content: space-between;
    gap:           .5rem;
    padding:       .5rem .25rem;
    border-bottom: 1px solid #f0f0f0;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-main  { flex: 1; font-size: .85rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.settings-row-actions { display: flex; gap: .35rem; flex-shrink: 0; }

.settings-input {
    padding:       .4rem .65rem;
    border:        1px solid #d1d5db;
    border-radius: 6px;
    font-size:     .82rem;
    font-family:   inherit;
}
.settings-inline-form {
    display:    flex;
    gap:        .5rem;
    flex-wrap:  wrap;
    align-items: center;
    padding:    .65rem;
    background: #f9fafb;
    border:     1px solid #e5e7eb;
    border-radius: 6px;
}
.settings-inline-form-grid { display: grid; grid-template-columns: 1fr 1fr; }

.badge-official {
    background: #fef3c7; color: #92400e;
    border-radius: 4px; padding: .1rem .4rem;
    font-size: .7rem; font-weight: 700;
}
.badge-belongs {
    background: #e0e7ff; color: #3730a3;
    border-radius: 4px; padding: .1rem .4rem;
    font-size: .7rem;
}

/* Modal */
.settings-modal-overlay {
    display:         flex;
    align-items:     center;
    justify-content: center;
    position:        fixed;
    inset:           0;
    background:      rgba(0,0,0,.45);
    z-index:         1000;
}
.settings-modal {
    background:    var(--card-bg);
    border-radius: 10px;
    box-shadow:    0 8px 32px rgba(0,0,0,.25);
    padding:       1.5rem;
    width:         min(640px, 96vw);
    max-height:    88vh;
    overflow-y:    auto;
}
.settings-modal h3 { margin: 0 0 1rem; }
.edit-modal-footer { display: flex; gap: .75rem; margin-top: 1rem; }

/* form-label-text for image widget labels outside <label> element */
.form-label-text {
    font-size: .85rem; font-weight: 600; color: #374151;
    margin-bottom: .35rem; display: block;
}

/* ── Metadata Fetcher panel ──────────────────────────────────────────────────── */

.fetcher-panel {
    border: 2px dashed #c4b5fd;
    border-radius: var(--card-radius);
}
.fetcher-panel[open] { border-style: solid; border-color: #7c3aed; }

.fetcher-summary {
    cursor:          pointer;
    display:         flex;
    align-items:     center;
    gap:             .75rem;
    padding:         .85rem 1rem;
    list-style:      none;
    user-select:     none;
}
.fetcher-summary::-webkit-details-marker { display: none; }
.fetcher-title   { font-weight: 700; font-size: 1rem; }
.fetcher-subtitle { font-size: .8rem; }

.fetcher-body    { padding: 1rem 1rem 1.25rem; }

.fetcher-step    { }
.fetcher-select-row {
    display:     flex;
    gap:         .5rem;
    align-items: center;
    margin-top:  .4rem;
}
.fetcher-select {
    flex:          1;
    padding:       .45rem .65rem;
    border:        1px solid #d1d5db;
    border-radius: 6px;
    font-size:     .875rem;
}

.fetcher-script-header {
    display:       flex;
    gap:           .75rem;
    align-items:   baseline;
    padding:       .5rem 0 .75rem;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: .85rem;
}

.fetcher-section-label {
    font-weight:   700;
    font-size:     .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color:         #6b7280;
    margin:        .75rem 0 .4rem;
}

.fetcher-arg-input {
    padding:       .4rem .65rem;
    border:        1px solid #d1d5db;
    border-radius: 6px;
    font-size:     .875rem;
    width:         100%;
}

/* Mapping table */
.fetcher-mapping-table {
    width:           100%;
    border-collapse: collapse;
    font-size:       .85rem;
    margin-top:      .5rem;
}
.fetcher-mapping-table th {
    text-align:    left;
    padding:       .4rem .5rem;
    border-bottom: 2px solid #e5e7eb;
    font-size:     .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color:         #6b7280;
}
.fetcher-mapping-table td { padding: .5rem .5rem; border-bottom: 1px solid #f3f4f6; }
.fetcher-meta-key-sel {
    padding:       .3rem .5rem;
    border:        1px solid #d1d5db;
    border-radius: 5px;
    font-size:     .82rem;
    width:         100%;
}

.fetcher-run-row {
    display:    flex;
    gap:        .5rem;
    margin-top: 1rem;
    align-items: center;
}

/* Log */
.fetcher-log-header {
    display:       flex;
    align-items:   center;
    gap:           .75rem;
    margin-bottom: .5rem;
}
.fetcher-log {
    min-height:    140px;
    max-height:    300px;
    overflow-y:    auto;
    background:    #0f172a;
    border-radius: 6px;
    padding:       .5rem .75rem;
    font-family:   monospace;
    font-size:     .78rem;
    color:         #94a3b8;
}
.fetcher-log-status {
    font-size:  .78rem;
    font-weight: 700;
    padding:    .15rem .5rem;
    border-radius: 4px;
    background: #e5e7eb;
    color:      #374151;
}
.fetcher-log-status.running { background: #dbeafe; color: #1d4ed8; }
.fetcher-log-status.done    { background: #dcfce7; color: #166534; }
.fetcher-log-status.error   { background: #fee2e2; color: #991b1b; }

/* Diff table */
.fetcher-diff-header    { margin-bottom: .75rem; }
.fetcher-diff-select-all {
    display:       flex;
    gap:           .5rem;
    margin-bottom: .5rem;
}

.fetcher-diff-table {
    width:           100%;
    border-collapse: collapse;
    font-size:       .82rem;
}
.fetcher-diff-table th {
    text-align:    left;
    padding:       .4rem .6rem;
    border-bottom: 2px solid #e5e7eb;
    font-size:     .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color:         #6b7280;
}
.fetcher-diff-table tr.fetcher-diff-row:nth-child(even) { background: #f9fafb; }
.fetcher-diff-table td { padding: .55rem .6rem; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
.fetcher-diff-cell  { max-width: 260px; }
.fetcher-diff-img   { max-width: 180px; max-height: 90px; border-radius: 4px; object-fit: cover; }
.fetcher-diff-text  { font-size: .8rem; display: block; white-space: pre-wrap; word-break: break-word; max-height: 80px; overflow: hidden; }
.fetcher-diff-use   { vertical-align: middle; }
.fetcher-radio-lbl  { display: block; font-size: .8rem; margin-bottom: .2rem; cursor: pointer; }
.fetcher-radio-lbl input { margin-right: .3rem; }

.fetcher-diff-actions {
    display:    flex;
    gap:        .75rem;
    align-items: center;
    margin-top: .85rem;
    flex-wrap:  wrap;
}
