html, body {
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    margin: 0;
}

/* ---------------- RichImage web app ---------------- */
:root {
    --ri-bg: #0f172a;
    --ri-panel: #1e293b;
    --ri-panel-2: #273449;
    --ri-line: #334155;
    --ri-text: #e2e8f0;
    --ri-muted: #94a3b8;
    --ri-accent: #6366f1;
    --ri-accent-2: #8b5cf6;
    --ri-danger: #ef4444;
}

.ri-root { height: 100vh; }

/* Loading overlay shown while a file is being read/decrypted/prepared. */
.ri-loading {
    position: fixed; inset: 0; z-index: 60;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
    background: rgba(15, 23, 42, .82); color: #e2e8f0;
}
.ri-spinner {
    width: 52px; height: 52px; border-radius: 50%;
    border: 5px solid rgba(255, 255, 255, .15); border-top-color: #8b5cf6;
    animation: ri-spin .9s linear infinite;
}
@keyframes ri-spin { to { transform: rotate(360deg); } }
.ri-loading-text { font-size: 15px; color: #cbd5e1; }

.ri-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--ri-bg);
    color: var(--ri-text);
}

.ri-header {
    display: flex; align-items: baseline; gap: 16px;
    padding: 14px 20px;
    background: linear-gradient(90deg, var(--ri-accent), var(--ri-accent-2));
    color: #fff;
}
.ri-brand { font-size: 22px; font-weight: 700; letter-spacing: .2px; }
.ri-logo { font-size: 20px; }
.ri-tagline { font-size: 13px; opacity: .9; }

.ri-toolbar {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    padding: 10px 16px;
    background: var(--ri-panel);
    border-bottom: 1px solid var(--ri-line);
}
.ri-btn {
    background: var(--ri-panel-2); color: var(--ri-text);
    border: 1px solid var(--ri-line); border-radius: 8px;
    padding: 7px 12px; font-size: 13px; cursor: pointer; line-height: 1;
    transition: background .12s, border-color .12s;
}
.ri-btn:hover:not(:disabled) { background: #33445e; border-color: #4b5f7d; }
.ri-btn:disabled, .ri-disabled { opacity: .45; cursor: not-allowed; }
.ri-btn.ri-accent { background: var(--ri-accent); border-color: var(--ri-accent); color: #fff; }
.ri-btn.ri-accent:hover:not(:disabled) { background: #5457e0; }
.ri-btn.ri-recording { background: var(--ri-danger); border-color: var(--ri-danger); color: #fff; animation: ri-pulse 1s infinite; }
@keyframes ri-pulse { 0%,100% { opacity: 1; } 50% { opacity: .6; } }
.ri-file { display: inline-flex; align-items: center; }
.ri-file input { display: none; }
.ri-sep { width: 1px; align-self: stretch; background: var(--ri-line); margin: 0 4px; }
.ri-check { font-size: 13px; color: var(--ri-muted); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

.ri-stage {
    position: relative; flex: 1; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background-color: #0e1526;
    background-image:
        linear-gradient(45deg, #0b1220 25%, transparent 25%, transparent 75%, #0b1220 75%),
        linear-gradient(45deg, #0b1220 25%, transparent 25%, transparent 75%, #0b1220 75%);
    background-size: 28px 28px;
    background-position: 0 0, 14px 14px;
    user-select: none;
}
.ri-empty { text-align: center; color: var(--ri-muted); }
.ri-empty-icon { font-size: 46px; margin-bottom: 10px; }

.ri-canvas {
    position: relative; transform-origin: center center; box-shadow: 0 10px 40px rgba(0,0,0,.5);
    /* Let our tap / long-press handlers own touch input (no native callout, scroll, or double-tap zoom). */
    touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.ri-img { width: 100%; height: 100%; display: block; pointer-events: none; }

.ri-marker { position: absolute; transform: translate(-50%, -50%); pointer-events: none; }
/* All marker icons and badges hidden by default. */
.ri-marker svg { display: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.7)); }

/* Sequence number badge on each speaker. */
.ri-marker-seq {
    display: none;
    position: absolute; top: -6px; right: -8px;
    min-width: 14px; height: 15px; padding: 0 3px;
    background: #38bdf8; color: #071018; font-size: 10px; font-weight: 700;
    line-height: 15px; text-align: center; border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,.6);
}

.ri-pending {
    position: absolute; width: 20px; height: 20px; border-radius: 50%;
    transform: translate(-50%, -50%); pointer-events: none;
    border: 2px dashed #38bdf8; box-shadow: 0 0 0 1px rgba(0,0,0,.4);
}

/* "Show icons" toggle: reveal all icons and badges. */
.ri-show-icons .ri-marker svg { display: block; opacity: .62; }
.ri-show-icons .ri-marker .ri-marker-seq { display: block; }
/* Highlight the active marker's icon when visible. */
.ri-show-icons .ri-marker.playing svg { opacity: 1; }

/* The clip currently playing pulses with an expanding ring so you can see where
   the sound is coming from — visible regardless of the show-icons toggle. */

.ri-marker.playing::after {
    content: ""; position: absolute; left: 50%; top: 50%;
    border-radius: 50%; border: 2px solid #38bdf8; pointer-events: none;
    animation: ri-ring 1.1s ease-out infinite;
}

@keyframes ri-ring {
    0%   { width: 18px; height: 18px; transform: translate(-50%, -50%); opacity: .9; }
    100% { width: 64px; height: 64px; transform: translate(-50%, -50%); opacity: 0; }
}

/* Sequential playback bar. */
.ri-player {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; background: var(--ri-panel); border-top: 1px solid var(--ri-line);
}

.ri-play-btn {
    width: 40px; height: 40px; border-radius: 50%; border: none; flex: none;
    background: #38bdf8; color: #071018; font-size: 16px; cursor: pointer;
}

.ri-play-btn:hover { background: #7dd3fc; }

.ri-progress {
    position: relative; flex: 1; height: 10px; border-radius: 5px;
    background: rgba(255,255,255,.12); cursor: pointer; touch-action: none;
}

.ri-progress-fill {
    position: absolute; left: 0; top: 0; height: 100%; width: 0%;
    background: #38bdf8; border-radius: 5px; pointer-events: none;
}

.ri-tick {
    position: absolute; top: 0; height: 100%; width: 2px;
    background: #0b1220; opacity: .85; pointer-events: none; transform: translateX(-1px);
}

.ri-progress-thumb {
    position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%;
    background: #e2e8f0; border: 2px solid #38bdf8; pointer-events: none;
    transform: translate(-50%, -50%); box-shadow: 0 1px 3px rgba(0,0,0,.5); z-index: 2;
}

.ri-scrub-label {
    position: absolute; bottom: 20px; transform: translateX(-50%); pointer-events: none;
    background: #0b1220; color: #e2e8f0; border: 1px solid #38bdf8;
    font-size: 12px; font-variant-numeric: tabular-nums; padding: 2px 6px; border-radius: 4px;
    white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,.5);
}

.ri-time { font-variant-numeric: tabular-nums; font-size: 13px; color: #cbd5e1; flex: none; }

.ri-clipcount { font-size: 12px; color: #94a3b8; flex: none; }

/* Right-click / long-press context menu. */
.ri-menu-backdrop { position: fixed; inset: 0; z-index: 40; }

.ri-menu {
    position: fixed; z-index: 41; min-width: 190px;
    background: var(--ri-panel, #0f172a); border: 1px solid var(--ri-line, #24314a);
    border-radius: 8px; padding: 6px; box-shadow: 0 12px 32px rgba(0,0,0,.55);
}

.ri-menu-title {
    font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
    color: #94a3b8; padding: 4px 8px 6px;
}

.ri-menu-item {
    display: block; width: 100%; text-align: left; cursor: pointer;
    background: none; border: none; color: #e2e8f0; font-size: 14px;
    padding: 8px 10px; border-radius: 6px;
}

.ri-menu-item:hover { background: rgba(56,189,248,.16); }

/* Open-by-code input on the empty state. */
.ri-openbycode { display: flex; gap: 8px; margin-top: 18px; justify-content: center; flex-wrap: wrap; }
.ri-code-input {
    background: var(--ri-panel-2); color: var(--ri-text);
    border: 1px solid var(--ri-line); border-radius: 8px;
    padding: 8px 12px; font-size: 14px; min-width: 240px;
    letter-spacing: 1px; text-transform: uppercase;
}
.ri-code-input::placeholder { text-transform: none; letter-spacing: normal; color: var(--ri-muted); }

/* Share-code result panel. */
.ri-share-panel {
    position: fixed; z-index: 41; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(92vw, 380px); background: var(--ri-panel); color: var(--ri-text);
    border: 1px solid var(--ri-line); border-radius: 12px; padding: 20px;
    box-shadow: 0 16px 48px rgba(0,0,0,.6); text-align: center;
}
.ri-share-title { font-size: 15px; color: var(--ri-muted); margin-bottom: 10px; }
.ri-share-code {
    font-size: 32px; font-weight: 700; letter-spacing: 3px; font-variant-numeric: tabular-nums;
    color: #c4b5fd; margin-bottom: 16px; user-select: all;
}
.ri-share-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.ri-share-hint { font-size: 12px; color: var(--ri-muted); line-height: 1.5; margin-bottom: 16px; }
.ri-share-close {
    background: var(--ri-panel-2); color: var(--ri-text); border: 1px solid var(--ri-line);
    border-radius: 8px; padding: 8px 20px; font-size: 14px; cursor: pointer;
}
.ri-share-close:hover { background: #33445e; }

/* -------- Mobile / narrow screens -------- */
@media (max-width: 640px) {
    .ri-header { padding: 10px 14px; }
    .ri-tagline { display: none; }              /* save vertical room */

    /* One compact, horizontally-scrollable row instead of many wrapped rows. */
    .ri-toolbar {
        flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
        padding: 8px 10px; gap: 6px; scrollbar-width: none;
    }
    .ri-toolbar::-webkit-scrollbar { display: none; }
    .ri-btn { padding: 8px 11px; font-size: 13px; white-space: nowrap; flex: 0 0 auto; }
    .ri-check { white-space: nowrap; flex: 0 0 auto; font-size: 13px; }
    .ri-sep { display: none; }

    /* Roomier controls for fingers. */
    .ri-player { padding: 12px 14px; }
    .ri-play-btn { width: 44px; height: 44px; }
    .ri-menu-item { padding: 12px 12px; font-size: 15px; }
    .ri-code-input { min-width: 0; width: 100%; }
    .ri-openbycode { width: 100%; }
    .ri-note { font-size: 11px; }
}

.ri-status {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 16px; background: var(--ri-panel); border-top: 1px solid var(--ri-line);
    font-size: 13px;
}
.ri-counts { color: var(--ri-muted); font-variant-numeric: tabular-nums; }
.ri-note {
    margin: 0; padding: 8px 16px 12px; font-size: 11.5px; line-height: 1.5;
    color: var(--ri-muted); background: var(--ri-bg);
}
.ri-note a { color: #818cf8; margin-left: 6px; }

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #0071c1;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: #1e293b;
    color: #e2e8f0;
    border-top: 2px solid #ef4444;
    bottom: 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: 14px;
}

    #blazor-error-ui a { color: #93c5fd; margin-left: 8px; }

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.9rem;
        top: 0.55rem;
    }

/* Branded loading splash (shown while the app downloads). */
.ri-splash {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 6px;
    background: #0f172a; color: #e2e8f0; font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
}
.ri-splash-logo { font-size: 56px; animation: ri-splash-pulse 1.6s ease-in-out infinite; }
.ri-splash-name { font-size: 30px; font-weight: 700; letter-spacing: .3px;
    background: linear-gradient(90deg, #818cf8, #c4b5fd); -webkit-background-clip: text;
    background-clip: text; color: transparent; }
.ri-splash-tag { font-size: 14px; color: #94a3b8; margin-bottom: 14px; }
.ri-splash-bar { width: 220px; max-width: 60vw; height: 6px; border-radius: 3px;
    background: rgba(255,255,255,.12); overflow: hidden; }
.ri-splash-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, #6366f1, #8b5cf6);
    width: var(--blazor-load-percentage, 0%); transition: width .2s ease; }

@keyframes ri-splash-pulse { 0%,100% { transform: scale(1); opacity: .95; } 50% { transform: scale(1.12); opacity: 1; } }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHht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zk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}