@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

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

:root {
    --primary: #f4f4f5;
    --primary-dark: #d7d7da;
    --secondary: #212126;
    --success: #1faa59;
    --danger: #ff3b30;
    --bg-dark: #09090b;
    --bg-card: #111114;
    --bg-input: #141419;
    --bg-elevated: #17171d;
    --text: #f5f5f7;
    --text-muted: #a7a7b0;
    --border-radius: 16px;
}

body {
    font-family: 'IBM Plex Sans', 'Segoe UI', sans-serif;
    background:
        radial-gradient(1400px 600px at 20% -20%, rgba(255, 255, 255, 0.06), transparent 60%),
        radial-gradient(900px 600px at 100% 0%, rgba(255, 59, 48, 0.08), transparent 45%),
        var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overscroll-behavior: none;
}

.hidden {
    display: none !important;
}

.startup-splash {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    background: rgba(9, 9, 11, 0.96);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.startup-splash.show {
    opacity: 1;
}

.startup-splash.hide {
    opacity: 0;
}

.startup-splash-card {
    width: min(86vw, 360px);
    border-radius: 24px;
    padding: 28px 24px;
    background: linear-gradient(160deg, #16161b, #0f0f12);
    border: 1px solid rgba(255, 255, 255, 0.16);
    text-align: center;
}

.startup-logo {
    width: 54px;
    height: 54px;
    border-radius: 999px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.8rem;
    background: radial-gradient(circle, #ff584f 30%, #c11d1d 100%);
    box-shadow: 0 0 0 8px rgba(255, 59, 48, 0.12);
}

.startup-splash-card h2 {
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: 0.14em;
    font-size: 1rem;
    margin-bottom: 8px;
}

.startup-splash-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.startup-pills {
    margin-top: 14px;
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.startup-pills span {
    font-size: 0.75rem;
    color: #f2f2f2;
    border: 1px solid rgba(255, 255, 255, 0.18);
    padding: 4px 10px;
    border-radius: 999px;
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

header {
    text-align: center;
    padding: 16px 0;
}

header h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.34rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.header-mark {
    display: inline-block;
    color: #ff4f46;
    margin-right: 4px;
    text-shadow: 0 0 16px rgba(255, 79, 70, 0.45);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-height: 100%;
}

.hero-card {
    background: linear-gradient(165deg, #15151a, #111116);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--border-radius);
    padding: 16px 18px;
    box-shadow: 0 22px 40px rgba(0, 0, 0, 0.22);
}

.hero-card h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.05rem;
    margin-bottom: 8px;
}

.hero-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.hero-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.hero-tags span {
    font-size: 0.78rem;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.09);
    color: #ebebef;
}

/* Panels */
.panel {
    background: linear-gradient(180deg, #15151a, #111114);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--border-radius);
    padding: 24px;
}

.panel.hidden {
    display: none;
}

.panel h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
}

/* Form */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.field-hint {
    display: block;
    margin-top: 6px;
    color: #8f8f98;
    font-size: 0.8rem;
}

.settings-note {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.settings-note small {
    color: #aaa;
}

.settings-note strong {
    color: #f2f2f5;
}

.danger-zone {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #333;
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-inline input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.danger-btn {
    margin-top: 10px;
}

.backup-zone {
    margin-top: 12px;
    padding: 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.backup-actions {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hidden-file-input {
    display: none;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 11px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: #101013;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--secondary);
    color: #f4f4f7;
}

.btn-icon {
    background: #17171d;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-icon:hover {
    opacity: 1;
    transform: translateY(-1px);
}

/* Record Button */
.record-container {
    order: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-top: auto;
    padding: 12px 0 calc(8px + env(safe-area-inset-bottom));
}

.record-btn {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(150deg, #f5f5f6, #dcdcdf);
    color: #111114;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.3s;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.record-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.55);
}

.record-btn.recording {
    background: radial-gradient(circle at 30% 20%, #ff5a52, #d12522 70%);
    box-shadow:
        0 0 0 0 rgba(255, 59, 48, 0.4),
        0 16px 30px rgba(209, 37, 34, 0.35);
    color: #fff;
    animation: pulse-red 1.15s infinite, wobble 0.8s infinite;
}

.record-btn .icon {
    font-size: 2.5rem;
}

.record-btn .text {
    font-size: 0.75rem;
    font-weight: 500;
}

@keyframes pulse-red {
    0%, 100% {
        transform: scale(1);
        box-shadow:
            0 0 0 0 rgba(255, 59, 48, 0.35),
            0 16px 30px rgba(209, 37, 34, 0.35);
    }
    50% {
        transform: scale(1.08);
        box-shadow:
            0 0 0 12px rgba(255, 59, 48, 0),
            0 16px 36px rgba(209, 37, 34, 0.4);
    }
}

@keyframes wobble {
    0%, 100% { transform: rotate(0deg) scale(1.02); }
    25% { transform: rotate(-1deg) scale(1.04); }
    75% { transform: rotate(1deg) scale(1.04); }
}

/* Timer */
.timer {
    font-size: 1.5rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    color: var(--danger);
}

.timer.hidden {
    display: none;
}

/* Status */
.status {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    min-height: 24px;
}

/* Progress */
.progress-container {
    background: linear-gradient(180deg, #141419, #121217);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: 16px;
}

.progress-container.hidden {
    display: none;
}

.progress-bar {
    height: 4px;
    background: #2a2a30;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar::after {
    content: '';
    display: block;
    width: 30%;
    height: 100%;
    background: linear-gradient(90deg, #f6f6f8, #d8d8dc);
    animation: progress 1.5s ease-in-out infinite;
}

@keyframes progress {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(400%);
    }
}

.progress-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
    display: block;
}

.progress-actions {
    display: flex;
    justify-content: center;
    margin-top: 12px;
}

.failed-audio-panel {
    background: rgba(255, 143, 107, 0.12);
    border: 1px solid rgba(255, 128, 89, 0.45);
    border-radius: var(--border-radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.failed-audio-panel.hidden {
    display: none;
}

.failed-audio-info {
    font-size: 0.84rem;
    color: #ffd4c5;
    line-height: 1.4;
}

.failed-audio-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Result */
.result-container {
    background: linear-gradient(180deg, #141419, #111115);
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: var(--border-radius);
    padding: 24px;
}

.result-container.hidden {
    display: none;
}

.result-container h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.result-text {
    width: 100%;
    min-height: 42vh;
    max-height: 72vh;
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 16px;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.2s;
}

.result-text:focus {
    outline: none;
    border-color: var(--primary);
}

.result-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.result-chip {
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.09);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.mode-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.mode-btn {
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:hover {
    border-color: rgba(255, 255, 255, 0.32);
    color: var(--text);
}

.mode-btn.active {
    background: #f3f3f6;
    border-color: #f3f3f6;
    color: #111114;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.result-actions .btn {
    flex: 1 1 calc(50% - 8px);
}

/* Footer */
footer {
    display: flex;
    justify-content: center;
    padding: 16px 0;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #f2f2f5;
    color: #0f0f12;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Responsive */
@media (max-width: 400px) {
    header h1 {
        font-size: 1.25rem;
    }
    
    .record-btn {
        width: 100px;
        height: 100px;
    }
    
    .record-btn .icon {
        font-size: 2rem;
    }
    
    .result-actions {
        flex-direction: column;
    }
}

/* History */
.history-container {
    background: linear-gradient(180deg, #141419, #111115);
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.history-toggle {
    width: 100%;
    padding: 16px 20px;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
}

.history-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
}

.history-count {
    background: #f2f2f6;
    color: #0e0e11;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 500;
}

.history-arrow {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.history-panel {
    max-height: 400px;
    overflow-y: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.history-panel.hidden {
    display: none;
}

.history-list {
    padding: 8px;
}

.history-search-wrap {
    padding: 10px 12px 0;
}

#history-search {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--bg-input);
    color: var(--text);
}

#history-search:focus {
    outline: none;
    border-color: var(--primary);
}

.history-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}

.history-actions.hidden {
    display: none;
}

.history-selection-info {
    margin-right: auto;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.history-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.history-item {
    padding: 12px;
    background: var(--bg-input);
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: border-color 0.2s, background 0.2s;
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-item-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-item-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.history-tag {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.09);
    color: #e8e8ec;
    font-size: 0.75rem;
}

.history-item-copy {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.6;
    transition: opacity 0.2s;
    padding: 4px;
}

.history-item-copy:hover {
    opacity: 1;
}

.history-item-preview {
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    line-height: 1.4;
}

.history-item-preview:hover {
    color: #ffffff;
}

.history-item.selection-mode {
    cursor: pointer;
}

.history-item.selection-mode .history-item-preview:hover {
    color: var(--text);
}

.history-item.selected {
    border-color: var(--danger);
    background: rgba(220, 53, 69, 0.18);
}

.history-item-full {
    font-size: 0.9rem;
    color: var(--text);
    white-space: pre-wrap;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    line-height: 1.5;
}

.history-item-full.hidden {
    display: none;
}

.btn-danger {
    background: var(--danger) !important;
    color: white;
    border-color: rgba(255, 59, 48, 0.6);
}
