:root {
    --primary-color: #4a90e2;
    --primary-hover: #357abd;
    --background-color: #121212;
    --container-bg: #1e1e1e;
    --text-color: #e0e0e0;
    --light-text: #888888;
    --border-color: #333333;
    --border-hover: #555555;
    --success-color: #28a745;
}

html, body {
    overscroll-behavior-y: contain; /* Prevents pull-to-refresh */
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 100vh;
    box-sizing: border-box;
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* IE 10+ and Edge */
    user-select: none; /* Standard syntax */
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

#main-container {
    background-color: var(--container-bg);
    padding: 15px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: calc(100vw - 20px);
    text-align: center;
    border: 1px solid var(--border-color);
    margin: auto;
    box-sizing: border-box;
}

header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.header-icon {
    width: 32px;
    height: 32px;
}

h1 {
    color: var(--primary-color);
    font-weight: 700;
    margin: 0;
    font-size: 1.5em;
}

.subtitle {
    color: var(--light-text);
    margin-bottom: 20px;
    font-weight: 300;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
    font-size: 0.95em;
}

.controls {
    display: none;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

button:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.2);
}

button:active:not(:disabled) {
    transform: scale(0.98) translateY(0);
    box-shadow: none;
}

button:disabled {
    background-color: #444;
    color: #888;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#upload-depth-btn {
    background-color: #6c757d;
}

#upload-depth-btn:hover {
    background-color: #5a6268;
}

.generate-wrapper {
    margin: 25px 0;
}

#preview-area {
    display: none;
}

#upload-container {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.upload-box {
    flex: 1 1 280px;
    max-width: 340px;
    height: 200px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    position: relative;
    overflow: hidden;
    background-color: rgba(0,0,0,0.1);
}

.upload-box:hover, .upload-box.dragging {
    border-color: var(--primary-color);
    background-color: rgba(74, 144, 226, 0.1);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--light-text);
    padding: 20px;
    text-align: center;
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 12px;
    opacity: 0.8;
    width: 40px;
    height: 40px;
}

.upload-text {
    margin: 0 0 4px 0;
    font-size: 0.9em;
    color: var(--text-color);
}

.upload-text strong {
    font-weight: 500;
}

.upload-hint {
    margin: 0;
    font-size: 0.8em;
    color: var(--light-text);
}

.info-text {
    font-size: 0.8em;
    color: var(--light-text);
    margin-top: 8px;
}

.info-text a {
    color: var(--primary-color);
    text-decoration: none;
}

.info-text a:hover {
    text-decoration: underline;
}

.depth-map-hint {
    font-size: 0.85em;
    color: var(--light-text);
    margin: -10px auto 20px auto;
    font-style: italic;
    line-height: 1.4;
    max-width: 500px;
    background: rgba(255,255,255,0.03);
    padding: 8px;
    border-radius: 6px;
}

.preview-media {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

#viewer-container {
    width: 100%;
    height: 40vh;
    min-height: 300px;
    max-height: 450px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    background-color: var(--background-color);
    margin: 20px 0;
}

#placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--light-text);
    font-size: 1em;
}

#loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(30, 30, 30, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.spinner {
    border: 5px solid #444;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

#settings-container {
    margin: 0 auto 20px auto;
    padding: 10px 20px;
    background: rgba(0,0,0,0.1);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    max-width: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

#settings-container label {
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.9em;
}

#intensity-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 150px;
    height: 6px;
    background: #333;
    outline: none;
    border-radius: 3px;
    transition: opacity .2s;
    cursor: pointer;
}

#intensity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid var(--container-bg);
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

#intensity-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid var(--container-bg);
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

#slider-value {
    font-weight: 500;
    color: var(--primary-color);
    min-width: 40px; /* To prevent layout shift */
    text-align: center;
    background-color: rgba(74, 144, 226, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.85em;
}

footer {
    text-align: center;
    padding: 20px 0 5px 0;
    color: var(--light-text);
    font-size: 0.8em;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

#export-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

#export-controls button, #update-notification button {
    background-color: #333;
    border: 1px solid #444;
}
#export-controls button:hover, #update-notification button:hover {
    background-color: #444;
    border-color: #555;
}

#stop-record-btn {
    background-color: #c82333; /* Red color for stop */
}
#stop-record-btn:hover {
    background-color: #a51d2a;
}

#update-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--success-color);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 15px;
}

#update-notification button {
    background-color: rgba(255,255,255,0.2);
    border: none;
}
#update-notification button:hover {
    background-color: rgba(255,255,255,0.3);
}

/* Hide obsolete elements */
#preview-area, .controls {
    display: none;
}