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

@font-face {
    font-family: 'ALKATIPAsliye';
    src: url('/fonts/ALKATIPAsliye.woff2') format('woff2'),
         url('/fonts/ALKATIPAsliye.woff') format('woff');
    font-display: swap;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(99, 102, 241, 0.22), transparent 28%),
        radial-gradient(circle at top right, rgba(16, 185, 129, 0.14), transparent 24%),
        radial-gradient(circle at bottom center, rgba(59, 130, 246, 0.18), transparent 26%),
        linear-gradient(160deg, #060816 0%, #0b1020 45%, #111827 100%);
    min-height: 100vh;
    padding: 20px;
    color: #e5e7eb;
}

.container {
    max-width: 980px;
    margin: 0 auto;
}

body.dialog-open {
    overflow: hidden;
}

.confirm-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(2, 6, 23, 0.62);
    backdrop-filter: blur(6px);
    pointer-events: auto;
}

.confirm-dialog-overlay[hidden] {
    display: none;
}


.confirm-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 360px);
    padding: 20px;
    border: 1px solid rgba(129, 140, 248, 0.2);
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.98);
    box-shadow: 0 24px 60px rgba(2, 6, 23, 0.45);
    pointer-events: auto;
}

.confirm-dialog-title {
    font-size: 18px;
    color: #f8fafc;
    margin-bottom: 10px;
}

.confirm-dialog-message {
    font-size: 14px;
    line-height: 1.6;
    color: #cbd5e1;
    margin-bottom: 18px;
}

.confirm-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.confirm-dialog-cancel,
.confirm-dialog-confirm {
    min-width: 88px;
    justify-content: center;
    pointer-events: auto;
}

.confirm-dialog-confirm {
    background: linear-gradient(135deg, #6366f1 0%, #2563eb 100%);
}

.header {
    position: relative;
    background: rgba(15, 23, 42, 0.78);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(148, 163, 184, 0.16);
    box-shadow: 0 20px 50px rgba(2, 6, 23, 0.35);
    backdrop-filter: blur(16px);
}

.logo {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo svg {
    position: absolute;
    top: 50%;
    left: -36px;
    transform: translateY(-50%);
}

.logo h1 {
    font-size: 18px;
    color: #f8fafc;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
    padding-left: 12px;
}

.status {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 4px;
    padding: 8px 16px;
    background: rgba(30, 41, 59, 0.92);
    border-radius: 20px;
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.status-dot {
    width: 8px;
    height: 8px;
    margin-top: 5px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #9ca3af;
    animation: pulse 2s infinite;
}

.status.online .status-dot {
    background: #10b981;
}

.status.offline .status-dot {
    background: #ef4444;
}

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

.status-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.status-text {
    font-size: 14px;
    color: #cbd5e1;
    font-weight: 500;
    text-align: center;
}

.status-subtext {
    font-size: 14px;
    color: #22c55e;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
}

.status-subtext[hidden] {
    display: none;
}

.card {
    background: rgba(15, 23, 42, 0.82);
    border-radius: 16px;
    padding: 32px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    box-shadow: 0 20px 50px rgba(2, 6, 23, 0.32);
    backdrop-filter: blur(18px);
    margin-bottom: 24px;
}

.card-main {
    margin-bottom: 24px;
}

.card h2 {
    font-size: 28px;
    color: #f8fafc;
    margin-bottom: 8px;
}

.description {
    color: #94a3b8;
    margin-bottom: 20px;
    font-size: 15px;
    line-height: 1.7;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 8px;
    font-size: 14px;
}

.tts-input-label {
    text-align: center;
}

.tts-text-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.tts-member-code-btn,
.tts-clear-btn {
    min-width: 168px;
    justify-content: center;
}

.tts-member-code-btn {
    color: #dbeafe;
    border-color: rgba(96, 165, 250, 0.32);
    background: rgba(30, 64, 175, 0.24);
}

.tts-member-code-btn:hover {
    color: #ffffff;
    border-color: #60a5fa;
    background: #2563eb;
}

.tts-member-code-btn[hidden] {
    display: none;
}

.tts-clear-btn {
    color: #dcfce7;
    border-color: rgba(74, 222, 128, 0.34);
    background: rgba(21, 128, 61, 0.36);
}

.tts-clear-btn:hover {
    color: #ffffff;
    border-color: #22c55e;
    background: #16a34a;
}

.tts-clear-btn:disabled,
.tts-clear-btn:disabled:hover {
    color: #86efac;
    border-color: rgba(74, 222, 128, 0.18);
    background: rgba(21, 128, 61, 0.18);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.72;
}

.tts-convert-hint {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.6;
    text-align: center;
    color: #94a3b8;
}

.tts-convert-hint[data-state="loading"] {
    color: #fde68a;
}

.tts-convert-hint[data-state="success"] {
    color: #86efac;
}

.tts-convert-hint[data-state="error"] {
    color: #fca5a5;
}

textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
    background: rgba(15, 23, 42, 0.86);
    color: #f8fafc;
}

textarea.kazakh-arabic-font {
    font-family: 'ALKATIPAsliye', 'Noto Naskh Arabic', 'Amiri', serif;
}

textarea:focus {
    outline: none;
    border-color: #818cf8;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.16);
    background: rgba(15, 23, 42, 0.96);
}

textarea::placeholder {
    color: #64748b;
}

input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
    background: rgba(15, 23, 42, 0.86);
    color: #f8fafc;
}

input[type="text"]:focus {
    outline: none;
    border-color: #818cf8;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.16);
    background: rgba(15, 23, 42, 0.96);
}

input[type="text"]::placeholder {
    color: #64748b;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.9), rgba(59, 130, 246, 0.85));
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #f8fafc;
    border: 3px solid #4f46e5;
    cursor: pointer;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.18);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #f8fafc;
    cursor: pointer;
    border: 3px solid #4f46e5;
}

.preset-source-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--primary-action-gap);
    justify-items: center;
    align-items: start;
}

.file-upload {
    position: relative;
}

.file-upload input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.file-label {
    border-radius: 8px;
    cursor: pointer;
}

.file-label:hover {
    transform: translateY(-2px);
}

.file-icon {
    font-size: 24px;
}

.file-text {
    color: #fff;
    font-weight: 600;
    text-align: center;
}

.record-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0;
    color: #64748b;
    font-size: 13px;
}

.record-divider::before,
.record-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(148, 163, 184, 0.14);
}

.recorder-panel {
    width: min(100%, 360px);
    padding: 16px;
    border-radius: 14px;
    border: 1px solid rgba(99, 102, 241, 0.72);
    background: rgba(15, 23, 42, 0.58);
}

.recorder-panel-compact {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.recorder-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.recorder-hold-btn {
    border-radius: 8px;
    font-weight: 600;
}

.recorder-hold-btn:active,
.recorder-panel[data-state="recording"] .recorder-hold-btn {
    transform: translateY(-2px);
}

.recorder-panel[data-state="recording"] .recorder-hold-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-color: rgba(248, 113, 113, 0.95);
    box-shadow: 0 10px 24px rgba(220, 38, 38, 0.28);
    color: #fff;
}

.recorder-panel[data-state="recording"] .recorder-hold-btn:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    border-color: rgba(252, 165, 165, 0.95);
}

.recorder-title {
    font-size: 15px;
    font-weight: 700;
    color: #f8fafc;
}

.recorder-timer {
    min-width: 58px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.12);
    color: #cbd5e1;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.recorder-tip {
    color: #94a3b8;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.recorder-meter {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    align-items: end;
    gap: 6px;
    height: 36px;
    margin: 12px 0 0;
}

.recorder-meter span {
    display: block;
    height: 12px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.95), rgba(56, 189, 248, 0.55));
    opacity: 0.32;
    transform-origin: center bottom;
    animation: equalize 1.1s ease-in-out infinite;
    animation-play-state: paused;
}

.recorder-meter span:nth-child(2n) {
    animation-duration: 0.95s;
}

.recorder-meter span:nth-child(3n) {
    animation-duration: 1.25s;
}

.recorder-meter span:nth-child(4n) {
    animation-duration: 0.8s;
}

.recorder-panel[data-state="recording"] .recorder-meter span {
    animation-play-state: running;
    opacity: 0.95;
}

.recorder-panel[data-state="ready"] .recorder-meter span {
    opacity: 0.7;
}

.recorder-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.recorder-status {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(30, 41, 59, 0.64);
    border: 1px solid rgba(148, 163, 184, 0.1);
    color: #cbd5e1;
    font-size: 14px;
}

.recorder-guidance {
    margin-top: 10px;
    color: #94a3b8;
    font-size: 13px;
    line-height: 1.6;
}

.recorder-panel[data-state="recording"] .recorder-status {
    color: #fde68a;
    border-color: rgba(250, 204, 21, 0.22);
    background: rgba(113, 63, 18, 0.18);
}

.recorder-panel[data-state="ready"] .recorder-status {
    color: #bbf7d0;
    border-color: rgba(74, 222, 128, 0.2);
    background: rgba(20, 83, 45, 0.22);
}

.recorder-panel[data-state="error"] .recorder-status {
    color: #dcfce7;
    border-color: rgba(248, 113, 113, 0.24);
    background: rgba(127, 29, 29, 0.22);
}

.recorder-preview {
    margin-top: 14px;
}

.recorder-preview audio {
    width: 100%;
}

.recorder-reset-btn {
    width: 100%;
    justify-content: center;
    margin-top: 10px;
}

#tts-generate {
    margin: var(--primary-action-gap) auto 0;
}

.preset-form-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--primary-action-gap);
    width: min(100%, calc(var(--primary-action-width) * 2 + var(--primary-action-gap)));
    margin: var(--primary-action-gap) auto 0;
}

#preset-save,
#preset-back-home {
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
}

@keyframes equalize {
    0%, 100% {
        transform: scaleY(0.35);
    }
    50% {
        transform: scaleY(1);
    }
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 8px;
}

.section-tip {
    color: #94a3b8;
    font-size: 13px;
}

.voice-mode-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.82), rgba(15, 23, 42, 0.64));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.voice-mode-btn {
    min-height: 72px;
    padding: 14px 16px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.18);
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 4px;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.voice-mode-btn::after {
    content: "";
    position: absolute;
    inset: auto auto 0 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0), rgba(99, 102, 241, 0.9), rgba(56, 189, 248, 0));
    opacity: 0;
    transition: opacity 0.25s ease;
}

.voice-mode-label {
    font-size: 15px;
    font-weight: 700;
    color: inherit;
}

.voice-mode-meta {
    font-size: 12px;
    line-height: 1.5;
    color: #94a3b8;
    transition: color 0.25s ease;
}

.voice-mode-btn:hover {
    border-color: transparent;
    transform: translateY(-1px);
    background: rgba(30, 41, 59, 0.32);
}

.voice-mode-btn.active {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.86), rgba(37, 99, 235, 0.88));
    box-shadow: 0 14px 30px rgba(79, 70, 229, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.voice-mode-btn.active::after {
    opacity: 1;
}

.voice-mode-btn.active .voice-mode-meta {
    color: rgba(224, 231, 255, 0.88);
}

.clone-preset-panel {
    margin-top: 16px;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(15, 23, 42, 0.5);
}

.clone-preset-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.clone-preset-title {
    color: #e2e8f0;
    font-size: 14px;
    font-weight: 700;
}

.preset-card-create {
    border-style: dashed;
}

.preset-card-create .preset-name {
    color: #22c55e;
}

.preset-create-entry {
    min-height: 100%;
    justify-content: center;
}

.preset-create-icon {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    color: #e0e7ff;
    background: rgba(79, 70, 229, 0.28);
    border: 1px solid rgba(129, 140, 248, 0.28);
}

.preset-create-entry[aria-expanded="true"] .preset-create-icon,
.preset-card-create.active .preset-create-icon {
    background: rgba(99, 102, 241, 0.38);
    border-color: rgba(165, 180, 252, 0.36);
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.preset-card {
    position: relative;
    border: 1px solid rgba(99, 102, 241, 0.72);
    border-radius: 14px;
    padding: 12px;
    background: rgba(15, 23, 42, 0.74);
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.preset-card:hover {
    border-color: rgba(99, 102, 241, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 18px 35px rgba(2, 6, 23, 0.34);
}

.preset-card.active {
    border-color: rgba(34, 197, 94, 0.96);
    background: linear-gradient(180deg, rgba(49, 46, 129, 0.34), rgba(15, 23, 42, 0.92));
    box-shadow: 0 18px 38px rgba(79, 70, 229, 0.18);
}

.preset-card-user {
    border-color: rgba(99, 102, 241, 0.72);
    background: linear-gradient(180deg, rgba(6, 95, 70, 0.18), rgba(15, 23, 42, 0.88));
}

.preset-card-user:hover {
    border-color: rgba(99, 102, 241, 0.9);
    box-shadow: 0 18px 35px rgba(16, 185, 129, 0.18);
}

.preset-card-user.active {
    border-color: rgba(34, 197, 94, 0.96);
    background: linear-gradient(180deg, rgba(6, 95, 70, 0.34), rgba(15, 23, 42, 0.94));
    box-shadow: 0 18px 38px rgba(16, 185, 129, 0.24);
}

.preset-card-deletable {
    padding-top: 12px;
}

.preset-card-delete-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid rgba(129, 140, 248, 0.45);
    border-radius: 999px;
    background: rgba(79, 70, 229, 0.5);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.preset-card-delete-btn:hover {
    background: rgba(79, 70, 229, 0.78);
    border-color: #a5b4fc;
    transform: scale(1.05);
}

.preset-card-delete-btn:active {
    transform: scale(0.94);
}

.preset-select {
    border: none;
    background: transparent;
    text-align: center;
    padding: 0;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.preset-name {
    font-size: 14px;
    font-weight: 700;
    color: #f8fafc;
}

.preset-mode {
    font-size: 11px;
    font-weight: 600;
    color: #a5b4fc;
    letter-spacing: 0.04em;
    text-align: center;
}

.preset-desc {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.5;
}

.preset-preview {
    width: 100%;
    filter: saturate(0.92) brightness(0.94);
}

.audio-preview-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.audio-preview-wrap-inline {
    gap: 12px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(129, 140, 248, 0.16);
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.72), rgba(15, 23, 42, 0.92));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.audio-preview-wrap-compact {
    gap: 6px;
}

.audio-preview-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.audio-preview-summary {
    min-width: 0;
}

.audio-preview-summary-label {
    font-size: 14px;
    font-weight: 700;
    color: #f8fafc;
}

.audio-preview-summary-meta {
    margin-top: 2px;
    font-size: 12px;
    color: #94a3b8;
}

.audio-preview-element {
    width: 100%;
    filter: saturate(0.92) brightness(0.94);
}

.audio-preview-element-hidden {
    display: none;
}

.audio-preview-toggle {
    width: 32px;
    height: 32px;
    padding: 0;
    position: relative;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 999px;
    align-self: center;
    flex-shrink: 0;
    color: #f8fafc;
    border: 1px solid rgba(129, 140, 248, 0.42);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.94), rgba(37, 99, 235, 0.9));
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.14);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.audio-preview-toggle-inline {
    width: auto;
    min-width: 124px;
    height: 42px;
    padding: 0 16px;
    gap: 10px;
    border-radius: 999px;
    align-self: flex-start;
}

.audio-preview-toggle::before {
    content: "";
    position: absolute;
    inset: 1px;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.02));
    opacity: 0.9;
    pointer-events: none;
}

.audio-preview-toggle:hover {
    transform: translateY(-1px) scale(1.03);
    border-color: rgba(167, 180, 255, 0.7);
    box-shadow: 0 12px 22px rgba(37, 99, 235, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.audio-preview-toggle:active {
    transform: scale(0.96);
}

.audio-preview-toggle[data-state="playing"] {
    border-color: rgba(34, 197, 94, 0.55);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.96), rgba(14, 165, 233, 0.88));
    box-shadow: 0 10px 20px rgba(16, 185, 129, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.audio-preview-icon {
    position: relative;
    width: 12px;
    height: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    filter: drop-shadow(0 1px 1px rgba(15, 23, 42, 0.16));
}
.audio-preview-toggle-inline .audio-preview-icon {
    width: 14px;
    height: 14px;
}

.audio-preview-toggle-text {
    position: relative;
    z-index: 1;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.01em;
}


.audio-preview-icon-play,
.audio-preview-icon-pause {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.audio-preview-icon-play::before {
    content: "";
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 9px solid currentColor;
    margin-left: 2px;
}

.audio-preview-icon-pause {
    gap: 3px;
    opacity: 0;
    transform: scale(0.85);
}

.audio-preview-icon-pause span {
    width: 3px;
    height: 12px;
    border-radius: 999px;
    background: currentColor;
}

.audio-preview-toggle[data-state="playing"] .audio-preview-icon-play {
    opacity: 0;
    transform: scale(0.85);
}

.audio-preview-toggle[data-state="playing"] .audio-preview-icon-pause {
    opacity: 1;
    transform: scale(1);
}

.audio-preview-hint {
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.5;
    text-align: center;
}

.preset-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
    margin-top: auto;
}

.preset-action-btn {
    padding: 8px 12px;
    border: 1px solid rgba(129, 140, 248, 0.42);
    border-radius: 8px;
    background: rgba(49, 46, 129, 0.26);
    color: #c7d2fe;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

.preset-action-btn:hover {
    background: #4f46e5;
    border-color: #6366f1;
    color: #fff;
}

.preset-action-btn.danger {
    border-color: rgba(248, 113, 113, 0.34);
    background: rgba(127, 29, 29, 0.18);
    color: #fca5a5;
}

.preset-action-btn.danger:hover {
    border-color: #dc2626;
    background: #16a34a;
    color: #fff;
}

.preset-action-btn.success {
    border-color: rgba(16, 185, 129, 0.44);
    background: rgba(6, 95, 70, 0.26);
    color: #a7f3d0;
}

.preset-action-btn.success:hover {
    border-color: #10b981;
    background: #10b981;
    color: #fff;
}

.preset-action-label {
    display: block;
    line-height: 1.2;
}

.preset-action-hint {
    display: block;
    font-size: 10px;
    font-weight: 500;
    line-height: 1.3;
    opacity: 0.88;
}

.preset-action-btn.selected,
.preset-action-btn.selected:hover {
    border-color: #22c55e;
    background: #16a34a;
    color: #fff;
}

.preset-action-btn.is-pressing,
.preset-action-btn.is-pressing:hover {
    border-color: #4ade80;
    background: rgba(21, 128, 61, 0.92);
    color: #f0fdf4;
}

.preset-action-btn.is-pressing .preset-action-hint {
    color: #dcfce7;
}

.clone-preset-panel .preset-card,
.clone-preset-panel .preset-card-user,
.clone-preset-panel .preset-card.active,
.clone-preset-panel .preset-card-user.active {
    background: rgba(15, 23, 42, 0.9);
    box-shadow: none;
    transition: none;
}

.clone-preset-panel .preset-card:hover,
.clone-preset-panel .preset-card-user:hover {
    transform: none;
    box-shadow: none;
}

.clone-preset-panel .preset-card.active {
    border-color: rgba(34, 197, 94, 0.96);
}

.clone-preset-panel .preset-card-user {
    border-color: rgba(99, 102, 241, 0.72);
}

.clone-preset-panel .preset-card-user.active {
    border-color: rgba(34, 197, 94, 0.96);
}

.clone-preset-panel .preset-create-icon,
.clone-preset-panel .preset-create-entry[aria-expanded="true"] .preset-create-icon,
.clone-preset-panel .preset-card-create.active .preset-create-icon {
    background: rgba(79, 70, 229, 0.18);
    border-color: rgba(129, 140, 248, 0.22);
}

.clone-preset-panel .audio-preview-toggle,
.clone-preset-panel .audio-preview-toggle:hover,
.clone-preset-panel .audio-preview-toggle:active,
.clone-preset-panel .audio-preview-toggle[data-state="playing"] {
    background: rgba(30, 41, 59, 0.96);
    box-shadow: none;
    transform: none;
    transition: none;
}

.clone-preset-panel .audio-preview-toggle::before {
    display: none;
}

.clone-preset-panel .preset-action-btn,
.clone-preset-panel .preset-action-btn:hover,
.clone-preset-panel .preset-action-btn.success,
.clone-preset-panel .preset-action-btn.success:hover,
.clone-preset-panel .preset-action-btn.selected,
.clone-preset-panel .preset-action-btn.selected:hover,
.clone-preset-panel .preset-action-btn.is-pressing,
.clone-preset-panel .preset-action-btn.is-pressing:hover,
.clone-preset-panel .preset-action-btn.danger,
.clone-preset-panel .preset-action-btn.danger:hover {
    box-shadow: none;
    transition: none;
}

.selected-preset {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 14px;
    background: rgba(30, 41, 59, 0.88);
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 10px;
    color: #e2e8f0;
    font-weight: 600;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 12px 30px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #1d4ed8 100%);
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(79, 70, 229, 0.32);
}

.btn-primary:disabled {
    background: linear-gradient(135deg, #475569 0%, #64748b 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-icon {
    font-size: 18px;
}

:root {
    --primary-action-width: 168px;
    --primary-action-height: 48px;
    --primary-action-gap: 14px;
    --primary-action-font-size: 13px;
    --primary-action-line-height: 1.35;
}

#tts-generate,
#preset-save,
#preset-back-home,
.file-upload,
.file-label,
.recorder-hold-btn {
    box-sizing: border-box;
    width: var(--primary-action-width);
}

#tts-generate,
#preset-save,
#preset-back-home,
.file-label,
.recorder-hold-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--primary-action-height);
    padding: 0 28px;
    font-size: var(--primary-action-font-size);
    line-height: var(--primary-action-line-height);
}

.file-upload {
    max-width: 100%;
}

.recorder-hold-btn {
    margin-left: 0;
    align-self: center;
}

.result {
    margin-top: 24px;
}

.audio-player {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.88), rgba(15, 23, 42, 0.96));
    border: 1px solid rgba(129, 140, 248, 0.18);
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 18px 40px rgba(2, 6, 23, 0.28);
}

.audio-player::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0), rgba(129, 140, 248, 0.72), rgba(56, 189, 248, 0));
    opacity: 0.9;
}

.audio-player-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 14px;
    text-align: center;
}

.audio-player-title {
    color: #22c55e;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.audio-meta {
    color: #a5b4fc;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 0;
}

.audio-player audio {
    width: 100%;
}

.result-audio {
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(15, 23, 42, 0.92);
}

.audio-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.audio-action-btn {
    display: flex;
    width: 100%;
    min-height: 42px;
    justify-content: center;
    align-items: center;
    padding: 0 18px;
    border-radius: 10px;
}

.audio-delete-btn {
    border-color: rgba(248, 113, 113, 0.38);
    color: #fecaca;
    background: rgba(69, 10, 10, 0.72);
}

.audio-delete-btn:hover {
    background: rgba(127, 29, 29, 0.9);
    border-color: rgba(252, 165, 165, 0.5);
    color: #fff;
}

.btn-secondary {
    padding: 10px 20px;
    background: rgba(30, 41, 59, 0.92);
    color: #c7d2fe;
    border: 1px solid rgba(129, 140, 248, 0.4);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: #4f46e5;
    color: white;
    border-color: #6366f1;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #cbd5e1;
}

.spinner {
    border: 3px solid rgba(148, 163, 184, 0.16);
    border-top: 3px solid #818cf8;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error {
    background: rgba(127, 29, 29, 0.34);
    color: #fecaca;
    border: 1px solid rgba(248, 113, 113, 0.28);
    padding: 16px;
    border-radius: 8px;
    margin-top: 16px;
}

.success {
    background: rgba(20, 83, 45, 0.36);
    color: #bbf7d0;
    border: 1px solid rgba(74, 222, 128, 0.24);
    padding: 16px;
    border-radius: 8px;
    margin-top: 16px;
}

.empty-state,
.loading-inline {
    padding: 20px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.72);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.12);
    text-align: center;
}

@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .header {
        flex-direction: column;
        gap: 16px;
        align-items: center;
    }

    .status {
        position: static;
        left: auto;
        transform: none;
        align-self: center;
        margin: 0 auto;
    }

    .card {
        padding: 20px;
    }

    .section-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .voice-mode-switch {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        padding: 8px;
    }

    .voice-mode-btn {
        min-height: 64px;
        padding: 12px;
    }

    .voice-mode-label {
        font-size: 14px;
    }

    .voice-mode-meta {
        font-size: 11px;
        line-height: 1.4;
    }

    .clone-preset-panel {
        margin-top: 12px;
        padding: 12px;
    }

    #clone-preset-section {
        padding-top: 18px;
        padding-bottom: 18px;
    }

    #clone-preset-section h2 {
        text-align: center;
        margin-bottom: 4px;
        font-size: 20px;
    }

    #clone-preset-section .form-group {
        margin-bottom: 16px;
    }

    #clone-preset-section .form-group:last-of-type {
        margin-bottom: 14px;
    }

    .clone-preset-head {
        align-items: flex-start;
        gap: 10px;
    }

    .preset-source-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
        justify-items: center;
        align-items: start;
    }

    .recorder-panel {
        width: 100%;
        padding: 14px;
        border-radius: 12px;
    }

    .file-upload,
    .recorder-panel {
        width: min(100%, 320px);
        align-self: center;
    }

    .file-upload {
        display: flex;
        justify-content: center;
    }

    .file-label {
        display: flex;
        width: var(--primary-action-width);
        margin: 0 auto;
        gap: 0;
        border-radius: 8px;
    }

    .file-icon {
        display: none;
    }

    .recorder-panel-compact {
        justify-content: flex-start;
    }

    .recorder-hold-btn {
        order: 1;
    }

    .recorder-head {
        order: 2;
    }

    .recorder-meter {
        order: 3;
    }

    .recorder-status {
        order: 4;
    }

    .recorder-guidance {
        order: 5;
    }

    .recorder-preview {
        order: 6;
    }

    .file-icon {
        font-size: 20px;
    }

    .file-text {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        min-height: 0;
        font-size: inherit;
        line-height: inherit;
        font-weight: 600;
        text-align: center;
        overflow-wrap: anywhere;
    }

    .recorder-head {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 8px;
        margin-bottom: 12px;
        text-align: center;
    }

    .recorder-title,
    .recorder-status,
    .recorder-guidance {
        text-align: center;
    }

    .preset-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
    }

    .preset-card {
        padding: 10px;
    }

    .preset-name {
        font-size: 12px;
    }

    .preset-mode {
        font-size: 10px;
    }

    .preset-desc {
        font-size: 11px;
    }

    .audio-preview-toggle {
        width: 28px;
        height: 28px;
    }

    .audio-preview-toggle-inline {
        width: 100%;
        min-width: 0;
        height: 44px;
        justify-content: center;
    }

    .audio-preview-head {
        flex-direction: column;
        align-items: stretch;
    }

    .audio-preview-summary {
        text-align: center;
    }

    .audio-preview-icon {
        width: 10px;
        height: 10px;
    }

    .audio-preview-icon-play::before {
        border-top-width: 5px;
        border-bottom-width: 5px;
        border-left-width: 8px;
        margin-left: 2px;
    }

    .audio-preview-icon-pause span {
        width: 3px;
        height: 10px;
    }

    .audio-preview-hint {
        font-size: 10px;
    }

    .confirm-dialog {
        width: min(100%, 320px);
        padding: 18px;
    }

    .confirm-dialog-actions {
        gap: 8px;
    }

    .confirm-dialog-cancel,
    .confirm-dialog-confirm {
        min-width: 80px;
        padding: 10px 16px;
    }

    .preset-card-delete-btn {
        top: -7px;
        right: -7px;
        width: 22px;
        height: 22px;
        font-size: 13px;
    }

    .preset-actions {
        gap: 8px;
    }

    .preset-action-btn {
        width: 100%;
        justify-content: center;
        padding: 8px 10px;
        font-size: 12px;
    }

    .selected-preset {
        display: flex;
        justify-content: center;
        width: 100%;
        margin: 0 auto;
        text-align: center;
    }

    #tts-generate {
        display: flex;
        width: var(--primary-action-width);
        margin: var(--primary-action-gap) auto 0;
    }

    .preset-form-actions {
        width: 100%;
        gap: 10px;
    }

    #preset-save,
    #preset-back-home {
        display: flex;
        width: auto;
        margin: 0;
        padding: 0 12px;
    }

    #clone-preset-section .form-group label {
        text-align: center;
    }

    .audio-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .audio-action-btn {
        width: 100%;
        justify-content: center;
    }

    #preset-ref-text {
        min-height: 96px;
        padding: 12px 14px;
    }

    #preset-result {
        margin-top: 16px;
    }

    #preset-result .success,
    #preset-result .error,
    #preset-result .loading {
        text-align: center;
    }

}
