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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #e4e4e7;
    font-size: 14px;
    line-height: 1.4;
    padding-bottom: 60px;
}

header {
    background: #0f0f1e;
    padding: 12px 20px;
    border-bottom: 2px solid #27272a;
    position: sticky;
    top: 0;
    z-index: 10;
}

header h1 {
    font-size: 18px;
    margin-bottom: 4px;
    color: #fbbf24;
}

#session-info {
    font-size: 12px;
    color: #a1a1aa;
}

#session-info span {
    font-weight: 600;
    color: #e4e4e7;
}

#recording-state.recording {
    color: #ef4444;
    font-weight: 700;
    animation: pulse 1s infinite;
}

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

main {
    padding: 16px 20px;
    max-width: 1400px;
    margin: 0 auto;
}

section {
    background: #27272a;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #3f3f46;
}

section h2 {
    font-size: 14px;
    color: #fbbf24;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.device-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}

.device-btn {
    padding: 14px 12px;
    border: 2px solid #3f3f46;
    background: #18181b;
    color: #e4e4e7;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.1s ease;
    touch-action: manipulation;
}

.device-btn:hover, .device-btn:active {
    background: #3f3f46;
    border-color: #fbbf24;
}

.device-btn.active {
    background: #fbbf24;
    color: #18181b;
    border-color: #fbbf24;
    font-weight: 700;
}

.control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

button.btn-primary, button.btn-secondary {
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    border: none;
    transition: opacity 0.1s;
    touch-action: manipulation;
}

button.btn-primary {
    background: #3b82f6;
    color: white;
}

button.btn-primary:hover {
    background: #2563eb;
}

button.btn-primary:disabled {
    background: #52525b;
    cursor: not-allowed;
}

button.btn-secondary {
    background: #52525b;
    color: #e4e4e7;
}

button.btn-secondary:hover {
    background: #71717a;
}

#conflict-countdown {
    background: #7f1d1d;
    color: #fecaca;
    padding: 12px;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    margin-top: 8px;
    border: 2px solid #ef4444;
    animation: pulse 0.5s infinite;
}

.hidden {
    display: none !important;
}

#send-status {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    min-height: 0;
}

#send-status:empty {
    display: none;
}

#send-status.sending {
    background: #1e3a8a;
    color: #dbeafe;
}

#send-status.success {
    background: #14532d;
    color: #bbf7d0;
}

#send-status.error {
    background: #7f1d1d;
    color: #fecaca;
    word-break: break-all;
}

#instructions ol {
    padding-left: 24px;
    color: #a1a1aa;
}

#instructions li {
    margin-bottom: 8px;
}

#instructions strong {
    color: #fbbf24;
}

.hint {
    color: #a1a1aa;
    font-size: 12px;
    margin-bottom: 8px;
}

#capture-input {
    width: 100%;
    padding: 12px;
    background: #18181b;
    border: 2px solid #3f3f46;
    border-radius: 6px;
    color: #e4e4e7;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

#capture-input:focus {
    outline: none;
    border-color: #fbbf24;
}

#log-container {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #3f3f46;
    border-radius: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

thead {
    position: sticky;
    top: 0;
    background: #18181b;
    z-index: 1;
}

th, td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid #3f3f46;
    white-space: nowrap;
}

th {
    color: #fbbf24;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
}

tr.kd td {
    background: rgba(59, 130, 246, 0.05);
}

tr.kp td {
    background: rgba(34, 197, 94, 0.05);
}

tr.ku td {
    background: rgba(168, 85, 247, 0.05);
}

tr.conflict td {
    background: rgba(239, 68, 68, 0.15) !important;
    border-left: 3px solid #ef4444;
}

tr.api-event td {
    background: rgba(34, 197, 94, 0.12) !important;
    border-left: 3px solid #22c55e;
}

.api-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.api-row label {
    min-width: 160px;
    font-weight: 600;
    color: #a1a1aa;
}

.api-status {
    padding: 6px 10px;
    border-radius: 4px;
    background: #18181b;
    color: #a1a1aa;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    flex: 1;
    min-width: 200px;
    word-break: break-all;
}

.api-status.running {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.api-status.error {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

#camera-video {
    width: 100%;
    max-width: 400px;
    margin-top: 12px;
    border-radius: 6px;
    border: 2px solid #3f3f46;
    display: block;
}

#camera-video.hidden {
    display: none;
}

code {
    background: #0f0f1e;
    padding: 2px 6px;
    border-radius: 3px;
    color: #fbbf24;
    font-size: 11px;
}

.summary-table {
    margin-top: 12px;
    width: 100%;
}

.summary-table td, .summary-table th {
    font-size: 12px;
}

footer {
    padding: 16px 20px;
    text-align: center;
    color: #52525b;
    font-size: 11px;
    border-top: 1px solid #27272a;
    margin-top: 20px;
}

footer code {
    background: transparent;
    color: #71717a;
    padding: 0;
}

@media (max-width: 640px) {
    main { padding: 12px; }
    section { padding: 12px; }
    .device-buttons { grid-template-columns: repeat(2, 1fr); }
    .control-row button { flex: 1 1 calc(50% - 4px); }
    th, td { padding: 4px 6px; font-size: 11px; }
}
