@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap');

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

body {
    font-family: 'Space Mono', monospace;
    background: #0a0a0a;
    color: #e0e0e0;
    min-height: 100vh;
    min-height: 100dvh; /* iOS dynamic viewport — accounts for Safari's UI bars */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.container {
    max-width: 480px;
    width: 100%;
    padding: 2rem;
    text-align: center;
    animation: reveal 0.4s ease-out forwards;
}

h1 {
    font-size: 2.4rem;
    font-weight: 400;
    letter-spacing: 0.35em;
    text-transform: lowercase;
    margin-bottom: 0.75rem;
    color: #ccc;
    text-shadow:
        -1.5px 0 1.5px rgba(255, 0, 170, 0.7),
        1.5px 0 1.5px rgba(0, 220, 255, 0.7);
    animation: chroma-drift 6s ease-in-out infinite;
}

@keyframes chroma-drift {
    0%, 100% {
        text-shadow:
            -1.5px 0 1.5px rgba(255, 0, 170, 0.7),
            1.5px 0 1.5px rgba(0, 220, 255, 0.7);
    }
    50% {
        text-shadow:
            -2px 0.5px 2px rgba(255, 0, 170, 0.75),
            2px -0.5px 2px rgba(0, 220, 255, 0.75);
    }
}

.subtitle {
    color: #666;
    margin-bottom: 2rem;
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.subtitle a {
    color: #666;
    text-decoration: none;
    border-bottom: 1px solid #666;
    transition: color 0.2s, border-color 0.2s;
}

.subtitle a:hover {
    color: #aaa;
    border-color: #666;
}

/* Input toggle tabs */
.input-toggle {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.tab {
    background: none;
    border: none;
    color: #555;
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 0.5rem 0;
    border-bottom: 1px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.tab:hover {
    color: #aaa;
}

.tab.active {
    color: #ccc;
    border-bottom-color: #ccc;
}

/* Record area */
.record-area {
    border: 1px solid transparent;
    border-radius: 2px;
    min-height: 220px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

/* Upload tab wrapper — same height as record area to prevent layout shift */
.upload-tab {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.record-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.record-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 1px solid #444;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s;
}

.record-btn:hover {
    border-color: #888;
}

.record-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #cc3333;
    transition: border-radius 0.2s, background 0.2s;
}

.record-btn.recording .record-icon {
    border-radius: 3px;
    background: #fff;
}

.record-status {
    color: #888;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.record-time {
    color: #cc3333;
    font-size: 1.2rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.1em;
    transform: scale(1);
    transform-origin: center;
    transition: transform 0.8s ease-out;
}

[hidden] {
    display: none !important;
}

/* Fade/unblur transition */
.fade-in {
    animation: reveal 0.3s ease-out forwards;
}

@keyframes reveal {
    from {
        opacity: 0;
        filter: blur(8px);
    }
    to {
        opacity: 1;
        filter: blur(0);
    }
}

.tab-content {
    min-height: 220px;
    display: flex;
    align-items: stretch;
}

.tab-content > * {
    width: 100%;
}

/* Upload area — horizontal golden ratio box (1.618 : 1) */
.upload-area {
    width: 17rem;
    max-width: 100%;
    aspect-ratio: 1.618 / 1;
    margin: 0 auto;
    padding: 1rem;
    border: 1px solid #444;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #777;
    background: rgba(255, 255, 255, 0.02);
}

.upload-prompt {
    text-align: center;
}

.upload-prompt p {
    color: #888;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    line-height: 1.6;
}

.upload-sub {
    color: #555 !important;
    font-size: 0.65rem !important;
    letter-spacing: 0.15em !important;
    text-transform: uppercase;
    margin-top: 0.4rem;
}

.hint {
    font-size: 0.7rem;
    color: #666 !important;
    margin-top: 0.75rem;
    letter-spacing: 0.05em;
}

.upload-hint {
    text-align: center;
    margin-top: 0;
    margin-bottom: 0.75rem;
}

.hint a {
    color: #888;
    text-decoration: none;
    border-bottom: 1px solid #555;
    transition: color 0.2s, border-color 0.2s;
}

.hint a:hover {
    color: #aaa;
    border-color: #888;
}

/* Progress */
.upload-progress p {
    margin-bottom: 1rem;
    color: #888;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.progress-bar {
    width: 100%;
    height: 1px;
    background: #222;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #fff;
    width: 0%;
    transition: width 0.3s;
}

/* Result */
.result {
    margin-top: 2.5rem;
}

.result p {
    color: #888;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.link-box {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.link-box input {
    flex: 1 0 100%;
    min-width: 0;
    background: transparent;
    border: 1px solid #444;
    border-radius: 2px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    color: #fff;
    font-size: 0.8rem;
    font-family: 'Space Mono', monospace;
    letter-spacing: 0.05em;
    text-align: center;
}

.link-actions {
    flex: 1 0 100%;
    display: flex;
    gap: 0.75rem;
    padding: 0 1.5rem;
}

.link-actions button {
    flex: 1;
}

.link-box button {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #b8b8b8;
    color: #0a0a0a;
    border: none;
    border-radius: 2px;
    padding: 0.75rem 1.5rem;
    min-height: 44px;
    cursor: pointer;
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: opacity 0.2s;
}

.link-box button:hover {
    opacity: 0.8;
}

.warning {
    color: #666 !important;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
}

/* Slug field */
.slug-field {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.slug-prefix {
    color: #555;
    font-size: 0.75rem;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.slug-field input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 1px solid #444;
    border-radius: 2px;
    padding: 0.5rem;
    color: #fff;
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.slug-field input:focus {
    outline: none;
    border-color: #777;
}

.slug-error {
    color: #ff4444;
    font-size: 0.7rem;
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

/* Note (upload) */
.note-area {
    text-align: left;
    padding: 1rem 0;
}

.slug-field {
    margin-bottom: 1.25rem !important;
}

.note-area textarea {
    width: 100%;
    background: transparent;
    border: 1px solid #444;
    border-radius: 2px;
    padding: 0.75rem;
    margin-top: 0.5rem;
    color: #fff;
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    resize: none;
    letter-spacing: 0.02em;
}

.note-area textarea:focus {
    outline: none;
    border-color: #777;
}

.note-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.note-meta span {
    font-size: 0.65rem;
    color: #444;
    letter-spacing: 0.05em;
    align-self: flex-end;
}

.send-btn {
    width: 100%;
    background: #b8b8b8;
    color: #0a0a0a;
    border: none;
    border-radius: 2px;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    transition: opacity 0.2s;
}

.send-btn:hover:not(:disabled) {
    opacity: 0.8;
}

.send-btn:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
}

/* Note (player) */
.note-display {
    color: #888;
    font-size: 0.85rem;
    font-style: italic;
    max-width: 400px;
    word-wrap: break-word;
    letter-spacing: 0.05em;
    line-height: 1.6;
}

/* How page */
.how {
    text-align: left;
}

.how h2 {
    font-size: 0.8rem;
    font-weight: 400;
    color: #888;
    margin-bottom: 2rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.step {
    margin-bottom: 2rem;
}

.step h3 {
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    letter-spacing: 0.1em;
}

.step p {
    color: #888;
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    letter-spacing: 0.03em;
    line-height: 1.6;
}

.step pre {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #444;
    border-radius: 2px;
    padding: 0.75rem;
    color: #aaa;
    font-size: 0.75rem;
    overflow-x: auto;
    margin-bottom: 0.5rem;
    letter-spacing: 0.02em;
}

.how a {
    color: #888;
    text-decoration: none;
    border-bottom: 1px solid #666;
    transition: color 0.2s;
}

.how a:hover {
    color: #aaa;
}

.how-footer {
    margin-top: 2.5rem;
    text-align: center;
}

/* Player */
.player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
    width: 100%;
}

.player-msg {
    color: #777;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    line-height: 1.6;
}


.pill-btn {
    position: relative;
    width: 100%;
    max-width: 320px;
    height: 72px;
    border-radius: 18px;
    border: 1px solid #888;
    background: transparent;
    color: #ccc;
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.3s;
}

.pill-btn:hover {
    border-color: #aaa;
}

.pill-btn:active {
    transform: scale(0.98);
}

.waveform-svg {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    pointer-events: none;
}

/* Width matches the parent pill-btn, not the fill */
.pill-fill .waveform-svg {
    width: 320px; /* matches pill-btn max-width */
}

.pill-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: rgba(255, 255, 255, 0.1);
    transition: width 0.1s linear;
    overflow: hidden;
    border-radius: 18px 0 0 18px;
}

.pill-label {
    position: relative;
    z-index: 1;
}

.share-btn {
    background: #b8b8b8;
    color: #0a0a0a;
    border: none;
    border-radius: 2px;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: opacity 0.2s;
}

.share-btn:hover {
    opacity: 0.8;
}

/* Breathing animation during playback */
@keyframes breathe {
    0%, 100% { background-color: #0a0a0a; }
    50% { background-color: #0f0f0f; }
}

body.breathing {
    animation: breathe 4s ease-in-out infinite;
}

body.breath-held {
    animation-play-state: paused;
}

.save-btn {
    background: none;
    border: none;
    color: #666;
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s;
}

.save-btn:hover {
    color: #aaa;
}

.time-display {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 300px;
    font-size: 0.65rem;
    color: #777;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.1em;
}

/* Countdown */
.countdown-btn {
    width: 120px;
    height: 120px;
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.countdown-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.countdown-bg {
    fill: none;
    stroke: #1a1a1a;
    stroke-width: 2;
}

.countdown-arc {
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke 0.5s;
}

.countdown-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-45%, -50%);
    font-size: 2rem;
    color: #fff;
}

.countdown-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.8rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.1em;
}

/* Countdown urgency colors */
.countdown-btn.urgent .countdown-arc {
    stroke: #ff4444;
}

.countdown-btn.urgent .countdown-number {
    color: #ff4444;
}

.countdown-btn.warning .countdown-arc {
    stroke: #ff8800;
}

.countdown-btn.warning .countdown-number {
    color: #ff8800;
}

/* Gone state */
.gone-msg {
    color: #777;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.gone-cta {
    color: #fff;
    text-decoration: none;
    border: 1px solid #444;
    border-radius: 2px;
    padding: 0.6rem 1.5rem;
    font-size: 0.7rem;
    font-family: 'Space Mono', monospace;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    transition: border-color 0.3s, background 0.3s, color 0.3s, box-shadow 0.3s;
}

.gone-cta:hover {
    border-color: #888;
}

/* Post-listen volley CTA — filled, warmer, glowing */
.gone-cta-primary {
    background: #b8b8b8;
    color: #0a0a0a;
    border-color: #b8b8b8;
    padding: 0.9rem 2rem;
    font-size: 0.75rem;
    box-shadow: 0 0 24px rgba(255, 0, 170, 0.25), 0 0 48px rgba(0, 220, 255, 0.15);
}

.gone-cta-primary:hover {
    background: #fff;
    border-color: #fff;
    box-shadow: 0 0 32px rgba(255, 0, 170, 0.35), 0 0 64px rgba(0, 220, 255, 0.2);
}

/* Mobile */
@media (max-width: 480px) {
    .container {
        padding: 1.25rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    /* Prevent iOS zoom on input focus — must override the more-specific class rules */
    .slug-field input,
    .note-area textarea,
    .link-box input,
    input, textarea, select {
        font-size: 16px;
    }

    /* Larger tap targets for tabs */
    .tab {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }

    .input-toggle {
        gap: 1.5rem;
    }

    /* Tighter player on small screens */
    .player {
        gap: 1.5rem;
    }

    .state {
        gap: 2rem;
    }

    /* How page steps tighter */
    .step {
        margin-bottom: 1.5rem;
    }
}

/* Very narrow phones (iPhone SE, small Androids) */
@media (max-width: 360px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.6rem;
        letter-spacing: 0.25em;
    }

    .subtitle {
        font-size: 0.7rem;
    }

    .slug-prefix {
        font-size: 0.7rem;
    }
}

/* Landscape phones — don't waste vertical space */
@media (max-height: 480px) and (orientation: landscape) {
    body {
        align-items: flex-start;
    }

    .container {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    h1 {
        margin-bottom: 0.5rem;
    }

    .subtitle {
        margin-bottom: 1rem;
    }

    .tab-content {
        min-height: 120px;
    }
}
