/* Granite Speech WebGPU - Ghibli animation theme */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft JhengHei", sans-serif;
    background-color: #f4f6f0;
    background-image:
        radial-gradient(circle at 12% 18%, rgba(160, 199, 155, 0.35) 0 2px, transparent 3px),
        radial-gradient(circle at 78% 32%, rgba(224, 190, 132, 0.28) 0 2px, transparent 3px),
        radial-gradient(circle at 42% 72%, rgba(160, 199, 155, 0.28) 0 2px, transparent 3px),
        radial-gradient(#dfe8d6 1px, transparent 1px);
    background-size: 260px 260px, 310px 310px, 220px 220px, 20px 20px;
    background-attachment: fixed;
    margin: 0;
    padding: 40px 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    color: #4a5d4e;
    line-height: 1.5;
    position: relative;
    overflow-x: hidden;
}

/* Floating forest decorations */
.forest-decor {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.forest-decor span {
    position: absolute;
    opacity: 0.65;
    animation: drift 16s ease-in-out infinite;
}

.leaf-1 { top: 12%; left: 6%;  font-size: 26px; animation-delay: 0s; }
.leaf-2 { top: 68%; left: 10%; font-size: 20px; animation-delay: -4s; }
.leaf-3 { top: 32%; right: 7%; font-size: 24px; animation-delay: -8s; }
.sparkle-1 { top: 20%; right: 12%; font-size: 16px; animation-delay: -2s; }
.sparkle-2 { top: 78%; right: 8%; font-size: 14px; animation-delay: -10s; }

@keyframes drift {
    0%, 100% { transform: translate(0, 0) rotate(-8deg); }
    25%      { transform: translate(10px, -14px) rotate(6deg); }
    50%      { transform: translate(-6px, 8px) rotate(-4deg); }
    75%      { transform: translate(8px, -6px) rotate(10deg); }
}

.container {
    position: relative;
    z-index: 1;
    background: linear-gradient(180deg, #ffffff 0%, #fdfdf8 100%);
    padding: 35px 40px;
    border-radius: 26px 24px 28px 22px;
    box-shadow: 0 12px 34px rgba(74, 93, 78, 0.14), inset 0 0 0 1px rgba(255, 255, 255, 0.7);
    max-width: 600px;
    width: 100%;
    border: 2px solid #e0e8db;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
    animation: settle 0.8s ease-out;
}

@keyframes settle {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ghibli-badge {
    display: inline-block;
    align-self: center;
    background-color: #eaf1e6;
    color: #52795f;
    padding: 7px 18px;
    border-radius: 20px 22px 18px 21px;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 4px;
    border: 1px dashed #b7c4b1;
    animation: bob 4s ease-in-out infinite;
}

@keyframes bob {
    0%, 100% { transform: translateY(0) rotate(-1deg); }
    50%      { transform: translateY(-5px) rotate(1deg); }
}

h1 {
    color: #354f52;
    font-size: 26px;
    text-align: center;
    margin: 0 0 6px;
    text-shadow: 0 2px 0 rgba(255, 255, 255, 0.9);
    position: relative;
}

h1::after {
    content: '';
    display: block;
    width: 88px;
    height: 7px;
    margin: 9px auto 0;
    border-bottom: 3px solid #a8c6a2;
    border-radius: 50%;
    transform: rotate(-2deg);
}

h2 {
    font-size: 14px;
    font-weight: normal;
    color: #6c757d;
    text-align: center;
    margin: 0;
}

.privacy-note {
    font-size: 12px;
    color: #8d99ae;
    text-align: center;
}

/* Input Card */
.input-card {
    width: 100%;
    background: #fcfdfa;
    border: 2px solid #d8e2dc;
    border-radius: 18px 20px 16px 19px;
    overflow: hidden;
    transition: border-color 0.3s, background 0.3s, transform 0.3s;
}

.input-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(74, 93, 78, 0.08);
}

.input-options {
    display: flex;
    align-items: stretch;
    padding: 9px;
    gap: 9px;
}

.input-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 14px;
    background: transparent;
    border: 2px dashed transparent;
    border-radius: 14px;
    color: #52795f;
    font-size: 14px;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s;
    flex: 1;
    position: relative;
    overflow: hidden;
}

.input-tile::after {
    content: '✨';
    position: absolute;
    font-size: 12px;
    opacity: 0;
    top: 2px;
    right: 6px;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateY(4px) rotate(-20deg);
}

.input-tile:hover:not(:disabled) {
    color: #354f52;
    background: #eaf1e6;
    border-color: #b7c4b1;
}

.input-tile:hover:not(:disabled)::after {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
}

.input-tile.recording {
    color: #c65d5d;
    background: #fbeaea;
    border-color: #e7b9b9;
    animation: pulseWarm 1.4s ease-in-out infinite;
}

@keyframes pulseWarm {
    0%, 100% { box-shadow: 0 0 0 0 rgba(198, 93, 93, 0.25); }
    50%      { box-shadow: 0 0 0 8px rgba(198, 93, 93, 0); }
}

.input-tile.recording:hover {
    color: #a94444;
    background: #f6dada;
}

.input-tile:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-tile svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.file-label {
    cursor: pointer;
}

.file-label.drag-over {
    color: #354f52;
    background: #eaf1e6;
    border-color: #52795f;
}

.input-card.drag-over {
    border: 2px dashed #52795f;
    background: #eaf1e6;
}

.divider {
    width: 2px;
    background: #d8e2dc;
    margin: 6px 0;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 5px;
    background: #e8eee4;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8bb390, #52795f);
    width: 0%;
    transition: width 0.2s;
    border-radius: 0 4px 4px 0;
}

/* Status Section */
.status-section {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
    color: #6c757d;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #8d99ae;
    box-shadow: 0 0 0 4px rgba(141, 153, 174, 0.15);
}

.status-dot.ready {
    background: #52795f;
    box-shadow: 0 0 0 4px rgba(82, 121, 95, 0.15);
}

.status-dot.loading,
.status-dot.processing {
    background: #d4a373;
    box-shadow: 0 0 0 4px rgba(212, 163, 115, 0.2);
    animation: pulse 1.5s infinite;
}

.status-dot.recording {
    background: #c65d5d;
    box-shadow: 0 0 0 4px rgba(198, 93, 93, 0.2);
    animation: pulse 0.8s infinite;
}

.status-dot.error {
    background: #c65d5d;
    box-shadow: 0 0 0 4px rgba(198, 93, 93, 0.2);
}

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

/* Audio Player */
.audio-player {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 11px;
    background: #fcfdfa;
    border: 2px solid #d8e2dc;
    border-radius: 16px;
}

.play-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: #52795f;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.3s, background 0.3s;
}

.play-btn:hover {
    background: #354f52;
    transform: scale(1.08) rotate(-5deg);
}

.play-btn svg {
    width: 14px;
    height: 14px;
}

.waveform-container {
    flex: 1;
    height: 30px;
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
}

#waveformCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.waveform-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: rgba(82, 121, 95, 0.25);
    pointer-events: none;
}

.audio-time {
    font-size: 13px;
    color: #6c757d;
    font-variant-numeric: tabular-nums;
    min-width: 4.5rem;
    text-align: right;
}

.clear-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #8d99ae;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: all 0.3s;
}

.clear-btn:hover {
    color: #c65d5d;
    background: #fbeaea;
    transform: rotate(90deg);
}

.clear-btn svg {
    width: 16px;
    height: 16px;
}

/* Transcribe Section */
.transcribe-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.task-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #354f52;
    font-weight: bold;
}

.task-row select {
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    background: #fcfdfa;
    color: #354f52;
    border: 2px solid #d8e2dc;
    border-radius: 12px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.3s;
}

.task-row select:focus {
    border-color: #52795f;
}

.checkbox-group {
    display: flex;
    gap: 16px;
    justify-content: center;
    width: 100%;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #4a5d4e;
    cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #52795f;
}

.transcribe-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: bold;
    font-family: inherit;
    background: #52795f;
    color: white;
    border: 2px solid #466b50;
    border-radius: 30px 32px 28px 31px;
    cursor: pointer;
    box-shadow: 0 5px 14px rgba(82, 121, 95, 0.32);
    transition: all 0.3s ease;
}

.transcribe-btn:hover:not(:disabled) {
    background: #354f52;
    border-color: #354f52;
    transform: translateY(-3px) rotate(-0.5deg);
    box-shadow: 0 9px 20px rgba(53, 79, 82, 0.4);
}

.transcribe-btn:active:not(:disabled) {
    transform: translateY(0);
}

.transcribe-btn:disabled {
    background: #a9b9ae;
    border-color: #a9b9ae;
    cursor: not-allowed;
    box-shadow: none;
}

/* Model Progress */
.model-progress {
    font-size: 13px;
    color: #8d99ae;
    text-align: center;
}

/* Transcript Card */
.transcript-card {
    width: 100%;
    background: #fffef9;
    border: 2px solid #e0e8db;
    border-radius: 16px 19px 15px 18px;
    overflow: hidden;
    box-shadow: 0 6px 16px rgba(74, 93, 78, 0.07);
    animation: settle 0.5s ease-out;
}

.transcript-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 2px dashed #cfddc7;
    background: #eaf1e6;
    font-size: 14px;
    font-weight: bold;
    color: #52795f;
}

.transcript-actions {
    display: flex;
    gap: 5px;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 9px;
    color: #52795f;
    cursor: pointer;
    transition: all 0.3s;
}

.icon-btn:hover {
    background: #dcead5;
    color: #354f52;
    transform: scale(1.1) rotate(-6deg);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.transcript-output {
    padding: 16px;
    min-height: 100px;
    max-height: 300px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.7;
    color: #4a5d4e;
    word-wrap: break-word;
}

.transcript-row {
    display: flex;
    gap: 12px;
    padding: 3px 0;
}

.transcript-row .timestamp {
    font-size: 13px;
    color: #8d99ae;
    flex-shrink: 0;
    min-width: 3rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.transcript-row .transcript-text {
    flex: 1;
}

/* Footer */
.footer {
    text-align: center;
    font-size: 13px;
    color: #8d99ae;
    border-top: 1px dashed #d8e2dc;
    padding-top: 16px;
}

.footer a {
    color: #52795f;
    text-decoration: none;
}

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

.gpu-info {
    font-size: 11px;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    color: #8d99ae;
    text-align: center;
}

/* Browser Error */
.browser-error {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f6f0;
    z-index: 100;
    padding: 2rem;
}

.browser-error-content {
    text-align: center;
    max-width: 440px;
    background: #ffffff;
    padding: 35px 40px;
    border-radius: 26px 24px 28px 22px;
    box-shadow: 0 12px 34px rgba(74, 93, 78, 0.14);
    border: 2px solid #e0e8db;
}

.browser-error-content h2 {
    font-size: 20px;
    font-weight: bold;
    color: #354f52;
    margin-bottom: 12px;
}

.browser-error-content p {
    font-size: 14px;
    color: #6c757d;
}

/* Responsive */
@media (max-width: 640px) {
    body {
        padding: 20px 12px;
    }

    .container {
        padding: 24px 20px;
        border-radius: 20px;
    }

    h1 {
        font-size: 22px;
    }

    h2 {
        font-size: 13px;
    }

    .input-tile {
        padding: 9px;
        font-size: 13px;
    }

    .input-tile svg {
        width: 20px;
        height: 20px;
    }

    .forest-decor span {
        display: none;
    }
}

/* Scrollbar */
.transcript-output::-webkit-scrollbar {
    width: 6px;
}

.transcript-output::-webkit-scrollbar-track {
    background: #f1f5f2;
}

.transcript-output::-webkit-scrollbar-thumb {
    background: #b7c4b1;
    border-radius: 3px;
}

.transcript-output::-webkit-scrollbar-thumb:hover {
    background: #8d99ae;
}

/* Dark Mode - forest night */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1b2620;
        background-image: radial-gradient(#2b3a31 1px, transparent 1px);
        background-attachment: fixed;
        color: #dce6dc;
    }

    h1 {
        color: #eaf1e6;
        text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
    }

    h1::after {
        border-bottom-color: #6b8f70;
    }

    h2,
    .status-section,
    .task-row,
    .checkbox-row,
    .model-progress,
    .audio-time,
    .footer,
    .privacy-note,
    .gpu-info {
        color: #9caf9e;
    }

    .container,
    .browser-error-content {
        background: linear-gradient(180deg, #243129 0%, #1f2b23 100%);
        border-color: #3a4d40;
        box-shadow: 0 12px 34px rgba(0, 0, 0, 0.3);
    }

    .input-card,
    .audio-player,
    .transcript-card {
        background: #1e2b23;
        border-color: #3a4d40;
    }

    .input-card:hover {
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    }

    .input-card.drag-over,
    .file-label.drag-over {
        background: #2f4636;
    }

    .input-tile {
        color: #9ec4a8;
    }

    .input-tile:hover:not(:disabled) {
        color: #eaf1e6;
        background: #2f4636;
    }

    .divider,
    .progress-bar,
    .transcript-header {
        background: #3a4d40;
        border-color: #3a4d40;
    }

    .progress-fill {
        background: linear-gradient(90deg, #6b8f70, #8bb390);
    }

    .task-row select {
        background: #1e2b23;
        color: #eaf1e6;
        border-color: #3a4d40;
    }

    .task-row select:focus {
        border-color: #8bb390;
    }

    .icon-btn {
        color: #9ec4a8;
    }

    .icon-btn:hover {
        background: #2f4636;
        color: #eaf1e6;
    }

    .transcript-header {
        color: #b9d2bf;
        border-bottom-color: #3a4d40;
    }

    .transcript-output {
        color: #dce6dc;
    }

    .transcript-row .timestamp {
        color: #7f9484;
    }

    .play-btn {
        background: #52795f;
    }

    .play-btn:hover {
        background: #6d9778;
    }

    .footer {
        border-top-color: #3a4d40;
    }

    .footer a {
        color: #9ec4a8;
    }

    .browser-error {
        background: #1b2620;
    }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
