/* ============================================================
   Edge TTS Online - Custom Stylesheet
   All styles scoped under .tts-app to avoid AdSense conflicts.
   No global resets, no !important, no body/html/ins/iframe styles.
   ============================================================ */

/* --- CSS Custom Properties --- */
.tts-app {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #eff6ff;
    --color-secondary: #0f766e;
    --color-secondary-hover: #0d9488;
    --color-accent: #7c3aed;
    --color-bg: #ffffff;
    --color-bg-alt: #f8fafc;
    --color-bg-panel: #ffffff;
    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-text-light: #94a3b8;
    --color-border: #e2e8f0;
    --color-border-focus: #2563eb;
    --color-error: #dc2626;
    --color-error-bg: #fef2f2;
    --color-success: #16a34a;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --max-width: 1140px;
}

/* --- Base App Container --- */
.tts-app {
    font-family: var(--font-sans);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.tts-app *,
.tts-app *::before,
.tts-app *::after {
    box-sizing: border-box;
}

.tts-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.25rem;
    width: 100%;
}

/* --- Header --- */
.tts-header {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.tts-header .tts-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.tts-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--color-text);
    font-weight: 700;
    font-size: 1.2rem;
}

.tts-logo-icon {
    font-size: 1.5rem;
}

.tts-nav {
    display: flex;
    gap: 1.5rem;
}

.tts-nav a {
    text-decoration: none;
    color: var(--color-text-secondary);
    font-size: 0.925rem;
    font-weight: 500;
    transition: color 0.2s;
    padding: 0.25rem 0;
}

.tts-nav a:hover {
    color: var(--color-primary);
}

/* --- Hero Section --- */
.tts-hero {
    background: linear-gradient(135deg, var(--color-primary-light) 0%, #f0f9ff 50%, #ecfdf5 100%);
    padding: 3.5rem 0 3rem;
    text-align: center;
}

.tts-hero h1 {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--color-text);
    margin: 0 0 1rem;
    line-height: 1.25;
}

.tts-hero-subtitle {
    font-size: 1.125rem;
    color: var(--color-text-secondary);
    max-width: 680px;
    margin: 0 auto;
    line-height: 1.7;
}

/* --- Sections --- */
.tts-section {
    padding: 3.5rem 0;
}

.tts-section-alt {
    background: var(--color-bg-alt);
}

.tts-section h2 {
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
    margin: 0 0 2.5rem;
    color: var(--color-text);
}

/* --- TTS Tool Grid --- */
.tts-tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

/* --- Panels --- */
.tts-panel {
    background: var(--color-bg-panel);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-md);
}

.tts-output-panel h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 1rem;
    color: var(--color-text);
}

/* --- Label --- */
.tts-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.4rem;
}

/* --- Textarea --- */
.tts-textarea-wrap {
    position: relative;
    margin-bottom: 1.25rem;
}

.tts-textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 160px;
}

.tts-textarea:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.tts-textarea::placeholder {
    color: var(--color-text-light);
}

.tts-char-count {
    position: absolute;
    bottom: 0.6rem;
    right: 0.85rem;
    font-size: 0.78rem;
    color: var(--color-text-light);
    pointer-events: none;
}

/* --- Controls Row --- */
.tts-controls-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.tts-control-group {
    display: flex;
    flex-direction: column;
}

/* --- Select (Dropdown) --- */
.tts-select {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--color-text);
    background: var(--color-bg);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

.tts-select:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* --- Slider --- */
.tts-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--color-border);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin: 0.4rem 0 0.2rem;
    cursor: pointer;
}

.tts-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 3px solid var(--color-bg);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    transition: transform 0.15s;
}

.tts-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.tts-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 3px solid var(--color-bg);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    cursor: pointer;
}

.tts-slider-value {
    font-weight: 700;
    color: var(--color-primary);
    font-size: 0.85rem;
}

.tts-slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--color-text-light);
    margin-top: 0.1rem;
}

/* --- Buttons --- */
.tts-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
    line-height: 1.4;
}

.tts-btn:active {
    transform: scale(0.98);
}

.tts-btn-primary {
    background: var(--color-primary);
    color: #ffffff;
    width: 100%;
    box-shadow: var(--shadow-sm);
}

.tts-btn-primary:hover {
    background: var(--color-primary-hover);
    box-shadow: var(--shadow-md);
}

.tts-btn-primary:disabled {
    background: var(--color-text-light);
    cursor: not-allowed;
    transform: none;
}

.tts-btn-secondary {
    background: var(--color-secondary);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}

.tts-btn-secondary:hover {
    background: var(--color-secondary-hover);
}

/* --- Spinner --- */
.tts-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: tts-spin 0.7s linear infinite;
}

@keyframes tts-spin {
    to { transform: rotate(360deg); }
}

/* --- Error Message --- */
.tts-error {
    background: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    margin-top: 1rem;
}

/* --- Output Area --- */
.tts-output-area {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.tts-output-placeholder {
    text-align: center;
    color: var(--color-text-light);
    padding: 2rem 1rem;
}

.tts-placeholder-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.tts-placeholder-hint {
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.tts-player-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 1.5rem 0;
}

.tts-audio {
    width: 100%;
    border-radius: var(--radius-sm);
}

/* --- Features Grid --- */
.tts-features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.tts-feature-card {
    background: var(--color-bg-panel);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.75rem;
    text-align: center;
    transition: box-shadow 0.25s, transform 0.25s;
    box-shadow: var(--shadow-sm);
}

.tts-feature-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

.tts-feature-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    line-height: 1;
}

.tts-feature-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: var(--color-text);
}

.tts-feature-card p {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin: 0;
    line-height: 1.6;
}

/* --- Steps --- */
.tts-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.tts-step {
    text-align: center;
    position: relative;
}

.tts-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.tts-step h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: var(--color-text);
}

.tts-step p {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin: 0;
    line-height: 1.6;
}

/* --- FAQ --- */
.tts-faq-list {
    max-width: 800px;
    margin: 0 auto;
}

.tts-faq-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    background: var(--color-bg-panel);
    overflow: hidden;
}

.tts-faq-item summary {
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s;
    color: var(--color-text);
}

.tts-faq-item summary::-webkit-details-marker {
    display: none;
}

.tts-faq-item summary::after {
    content: "+";
    font-size: 1.4rem;
    font-weight: 400;
    color: var(--color-text-light);
    transition: transform 0.2s;
    flex-shrink: 0;
    margin-left: 1rem;
}

.tts-faq-item[open] summary::after {
    content: "\2212";
}

.tts-faq-item summary:hover {
    background: var(--color-bg-alt);
}

.tts-faq-answer {
    padding: 0 1.25rem 1rem;
    font-size: 0.925rem;
    color: var(--color-text-secondary);
    line-height: 1.7;
}

.tts-faq-answer p {
    margin: 0;
}

/* --- Use Cases --- */
.tts-usecases-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.tts-usecase {
    background: var(--color-bg-panel);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.tts-usecase h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: var(--color-text);
}

.tts-usecase p {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin: 0;
    line-height: 1.6;
}

/* --- Footer --- */
.tts-footer {
    margin-top: auto;
    background: var(--color-text);
    color: var(--color-text-light);
    padding: 1.5rem 0;
    text-align: center;
    font-size: 0.85rem;
}

.tts-footer p {
    margin: 0;
}

/* ============================================================
   Responsive Design
   ============================================================ */

@media (max-width: 960px) {
    .tts-tool-grid {
        grid-template-columns: 1fr;
    }

    .tts-features-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tts-steps {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .tts-hero {
        padding: 2.5rem 0 2rem;
    }

    .tts-hero h1 {
        font-size: 1.6rem;
    }

    .tts-hero-subtitle {
        font-size: 1rem;
    }

    .tts-section {
        padding: 2.5rem 0;
    }

    .tts-section h2 {
        font-size: 1.4rem;
        margin-bottom: 1.75rem;
    }

    .tts-header .tts-container {
        height: 56px;
    }

    .tts-nav {
        gap: 1rem;
    }

    .tts-nav a {
        font-size: 0.85rem;
    }

    .tts-controls-row {
        grid-template-columns: 1fr;
    }

    .tts-features-grid {
        grid-template-columns: 1fr;
    }

    .tts-steps {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .tts-usecases-grid {
        grid-template-columns: 1fr;
    }

    .tts-panel {
        padding: 1.25rem;
    }
}
