:root {
    --gap: 8px;
    --radius: 8px;
    --bg: #0b0c10;
    --panel: #12141a;
    --text: #e8eaed;
    --muted: #97a0af;
    --primary: #4f7cff;
    --border: #222734
}

/* Light theme overrides */
:root[data-theme="light"] {
    --bg: #f8f9fb;
    --panel: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #3b82f6;
    --border: #e5e7eb
}

* {
    box-sizing: border-box
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--border)
}

.app-header h1 {
    margin: 0;
    font-size: 18px;
    flex: 1;
}

.header-info {
    flex: 1;
    display: flex;
    justify-content: center;
}

.stage-info {
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    opacity: 0.5;
    transition: all 0.2s;
}

.stage-info.current {
    background: rgba(79, 124, 255, 0.15);
    border-color: var(--primary);
    opacity: 1;
    transform: scale(1.05);
}

.stage-info.current .stage-num {
    color: var(--primary);
}

.stage-num {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

.stage-date {
    font-size: 10px;
    color: var(--muted);
}

.app-header nav {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.link {
    color: var(--primary);
    text-decoration: none
}

.container {
    padding: 16px
}

.status {
    margin-left: 12px;
    color: var(--muted);
    font-size: 14px
}

.btn {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background: #1a1f2b;
    color: var(--text);
    border-radius: 6px;
    cursor: pointer
}

.btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white
}

:root[data-theme="light"] .btn {
    background: #f3f4f6;
    color: #111827
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px
}

.controls label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px
}

.controls input {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #0f121a;
    color: var(--text);
    width: 96px
}

/* Display grid */
.grid {
    display: grid;
    gap: var(--gap);
    grid-template-columns: repeat(var(--cols, 4), minmax(80px, 1fr));
    grid-auto-rows: minmax(64px, auto)
}

.seat {
    border: 1px solid var(--border);
    background: #111522;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 10px 12px;
    text-align: left;
    cursor: pointer
}

.seat.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 124, 255, .35)
}

.seat-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text)
}

.seat.empty {
    align-items: center;
    justify-content: center;
    text-align: center
}

.seat.empty .seat-name {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500
}

.screen {
    margin-top: 16px;
    padding: 10px 0;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    text-align: center;
    color: var(--muted);
    background: transparent
}

.seat-meta {
    color: var(--muted);
    font-weight: 500
}

.seat-purpose {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted)
}

.seat-desc {
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted)
}

.teacher-seat {
    background: var(--panel) !important;
    color: var(--muted) !important;
    border: 1px dashed var(--border) !important;
    font-weight: normal;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    opacity: 0.8;
}

.teacher-seat .seat-name {
    color: var(--muted);
    font-size: 13px;
}

.teacher-area {
    margin-top: 20px;
    padding: 10px 0;
    margin-bottom: 10px;
}

/* Editor grid */
.grid-editor {
    display: grid;
    gap: var(--gap);
    grid-template-columns: repeat(var(--cols, 4), minmax(180px, 1fr))
}

.editor-cell {
    border: 1px solid var(--border);
    background: #0f121a;
    border-radius: var(--radius);
    padding: 8px
}

.editor-cell.swap-selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 124, 255, .35)
}

.editor-cell-inner {
    display: flex;
    flex-direction: column;
    gap: 6px
}

.editor-label {
    font-size: 12px;
    color: var(--muted)
}

.editor-name {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #0b0e14;
    color: var(--text)
}

.editor-desc {
    min-height: 54px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #0b0e14;
    color: var(--text);
    resize: vertical
}

.editor-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap
}

.editor-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 150px;
    flex: 1
}

.editor-field-label {
    font-size: 12px;
    color: var(--muted)
}

.editor-select {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #0b0e14;
    color: var(--text)
}