* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Toolbar (in control panel) */
.toolbar-buttons {
    display: flex;
    gap: 4px;
}

.toolbar-btn {
    flex: 1;
    background: #2a2a2a;
    color: #ccc;
    border: 1px solid #444;
    border-radius: 3px;
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.toolbar-btn:hover {
    background: #3a3a3a;
    color: #fff;
}

.toolbar-btn.active {
    background: #4a9eff;
    color: #fff;
    border-color: #4a9eff;
}

.toolbar-btn.disabled,
.toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#viewer-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 280px;
    bottom: 0;
    background: #000;
}

.preview-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    z-index: 5;
    pointer-events: none;
}

#control-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 280px;
    height: 100vh;
    background: rgba(30, 30, 30, 0.95);
    padding: 16px;
    overflow-y: auto;
    border-left: 1px solid #333;
}

#control-panel h2 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #fff;
}

.control-group {
    margin-bottom: 20px;
}

.control-group label {
    display: block;
    font-size: 13px;
    color: #aaa;
    margin-bottom: 6px;
}

.control-group h3 {
    font-size: 14px;
    color: #ccc;
    margin-bottom: 8px;
}

input[type="range"] {
    width: 100%;
    cursor: pointer;
    accent-color: #4a9eff;
}

#opacity-value,
#window-min-value,
#window-max-value {
    font-size: 12px;
    color: #888;
}

select {
    width: 100%;
    padding: 4px 8px;
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #555;
    border-radius: 3px;
    font-size: 13px;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #4a9eff;
}

#metadata-display {
    font-size: 12px;
    color: #999;
    line-height: 1.6;
}

/* Scale bar styling */
.openseadragon-scalebar {
    font-size: 12px !important;
}

/* Navigator (mini-map) styling */
.navigator {
    border: 1px solid #555 !important;
    background: #000 !important;
}

/* Ruler list */
#ruler-list {
    margin-bottom: 8px;
}

.ruler-empty {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.ruler-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 6px;
    margin-bottom: 2px;
    background: #2a2a2a;
    border-radius: 3px;
    font-size: 12px;
}

.ruler-label {
    color: #00ff88;
}

.ruler-delete {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    line-height: 1;
}

.ruler-delete:hover {
    color: #ff4444;
}

.roi-empty {
    font-size: 12px;
    color: #666;
    font-style: italic;
    margin-bottom: 8px;
}

.roi-empty.pending {
    color: #ffbf47;
    font-style: normal;
}

.roi-empty.error {
    color: #ff6b6b;
    font-style: normal;
}

.roi-stats-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 8px;
    margin-bottom: 8px;
    font-size: 12px;
    background: #232323;
    border: 1px solid #343434;
    border-radius: 4px;
    padding: 8px;
}

.roi-stats-key {
    color: #aaa;
}

.roi-stats-val {
    color: #f0f0f0;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.control-btn {
    width: 100%;
    padding: 4px 8px;
    background: #2a2a2a;
    color: #ccc;
    border: 1px solid #444;
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 4px;
}

.control-btn:hover {
    background: #3a3a3a;
    color: #fff;
}

.note-muted {
    font-size: 12px;
    color: #888;
    line-height: 1.4;
}

/* Prepare progress panel */
.prepare-phases {
    margin-bottom: 8px;
}

.prepare-phase {
    display: flex;
    align-items: center;
    padding: 3px 0;
    font-size: 12px;
    gap: 8px;
}

.phase-icon {
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.prepare-phase.done .phase-icon {
    color: #4caf50;
}

.prepare-phase.running .phase-icon {
    color: #4a9eff;
    animation: spin 1s linear infinite;
}

.prepare-phase.error .phase-icon {
    color: #f44336;
}

.prepare-phase.pending .phase-icon {
    color: #666;
}

.phase-label {
    flex: 1;
    color: #ccc;
}

.phase-detail {
    color: #888;
    font-size: 11px;
    text-align: right;
    min-width: 40px;
}

.prepare-phase.error .phase-detail {
    color: #f44336;
}

.prepare-summary {
    font-size: 12px;
    color: #4caf50;
    margin-bottom: 6px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Preparing overlay on viewer */
#prepare-overlay {
    position: absolute;
    top: 12px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
    padding: 6px 10px;
    border-radius: 6px;
    pointer-events: none;
}

.prepare-overlay-text {
    color: #ccc;
    font-size: 12px;
}

.busy-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(200, 200, 200, 0.3);
    border-top-color: #cfcfcf;
    animation: busy-spin 0.8s linear infinite;
}

@keyframes busy-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Zoom warning toast (during progressive tile generation) */
.zoom-warning-toast {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 30, 0.85);
    color: #f5c542;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    z-index: 90;
    pointer-events: none;
    white-space: nowrap;
    border: 1px solid rgba(245, 197, 66, 0.3);
}

/* Slice progress bar (z-stack) */
.slice-progress-bar {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    background: #2a2a2a;
    margin-top: 6px;
    cursor: pointer;
}

.slice-queued {
    font-size: 11px;
    color: #f5c542;
    margin-top: 4px;
}

.slice-progress-empty {
    width: 100%;
    height: 6px;
    background: #444;
}

.slice-progress-bar .slice-seg {
    flex: 1;
    min-width: 2px;
    transition: background-color 0.3s;
}

.slice-seg.done {
    background-color: #4caf50;
}

.slice-seg.running {
    background-color: #4a9eff;
    animation: pulse-bg 1s ease-in-out infinite alternate;
}

.slice-seg.pending {
    background-color: #444;
}

.slice-seg.error {
    background-color: #f44336;
}

.slice-seg.active {
    outline: 1px solid #fff;
    outline-offset: 0;
}

.slice-seg.requested {
    box-shadow: inset 0 0 0 1px rgba(255, 140, 0, 0.95);
    position: relative;
}

.slice-seg.requested::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 110, 0, 0.28);
    animation: pulse-requested 0.9s ease-in-out infinite alternate;
}

.slice-seg.active.requested {
    outline-color: #ffd27a;
}

@keyframes pulse-bg {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

@keyframes pulse-requested {
    from { opacity: 0.35; }
    to { opacity: 0.95; }
}

/* Pixel value tooltip */
.pixel-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: #e0e0e0;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    z-index: 100;
    pointer-events: none;
    white-space: nowrap;
}

.view-status {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(20, 20, 20, 0.8);
    color: #ddd;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 95;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.view-status.is-ready {
    border-color: rgba(80, 200, 120, 0.35);
    color: #dff7e5;
}

.view-status.is-loading {
    border-color: rgba(74, 158, 255, 0.4);
    color: #d9ebff;
}

.view-status.is-queued,
.view-status.is-preview {
    border-color: rgba(245, 197, 66, 0.45);
    color: #fff1bf;
}

.view-status.is-error {
    border-color: rgba(244, 67, 54, 0.45);
    color: #ffd9d6;
}

/* Perf panel */
.perf-panel {
    position: absolute;
    left: 10px;
    bottom: 10px;
    background: rgba(20, 20, 20, 0.85);
    border: 1px solid #333;
    border-radius: 6px;
    padding: 8px 10px;
    z-index: 110;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 11px;
    color: #cfcfcf;
    min-width: 160px;
    pointer-events: none;
}

.perf-title {
    font-size: 10px;
    color: #8ab4ff;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.perf-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    line-height: 1.4;
}

.perf-row .perf-name {
    color: #b9b9b9;
}

.perf-row .perf-time {
    color: #7ee787;
}

.slice-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.slice-row input[type="range"] {
    flex: 1;
    min-width: 0;
}

.slice-step-btn {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid #555;
    border-radius: 4px;
    background: #333;
    color: #e0e0e0;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.slice-step-btn:hover {
    background: #444;
}

.slice-step-btn:active {
    background: #555;
}

#slice-value {
    font-size: 12px;
    color: #888;
    flex-shrink: 0;
    min-width: 55px;
    text-align: right;
}

/* (removed) format selector in prepare panel */
