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

:root {
    --primary-color: #dc2626;
    --secondary-color: #991b1b;
    --accent-color: #dc2626;
    --bg-color: #fafafa;
    --card-bg: #ffffff;
    --text-color: #1a1a1a;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --success-color: #10b981;
    --gold-accent: #d4af37;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Noto Sans JP', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    padding: 20px;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(180deg, rgba(220, 38, 38, 0.03) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 60px;
    padding: 60px 0 40px;
    position: relative;
}

header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
}

.header-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.main-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.japanese-title {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 8px;
    line-height: 1;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.english-title {
    font-size: 1.8rem;
    font-weight: 300;
    color: var(--text-color);
    letter-spacing: 12px;
    text-transform: uppercase;
    font-family: 'Georgia', serif;
}

.tagline {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 2px;
    text-transform: uppercase;
    position: relative;
    padding: 0 40px;
}

.tagline::before,
.tagline::after {
    content: '◆';
    position: absolute;
    color: var(--primary-color);
    font-size: 0.8rem;
}

.tagline::before {
    left: 0;
}

.tagline::after {
    right: 0;
}

/* Sections */
.section {
    background: var(--card-bg);
    border-radius: 4px;
    padding: 40px;
    box-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.12),
        0 1px 2px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    position: relative;
}

.hidden {
    display: none !important;
}

/* Upload Section */
.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 15px;
    padding: 60px 40px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 30px;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    width: 80px;
    height: 80px;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.upload-area h2 {
    margin-bottom: 10px;
    font-size: 1.8rem;
}

.upload-area p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.paste-area {
    margin-top: 30px;
}

.paste-area h3 {
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.paste-area textarea {
    width: 100%;
    min-height: 200px;
    background: #ffffff;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    color: var(--text-color);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 15px;
}

.paste-area textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(220, 38, 38, 0.3);
    background: var(--secondary-color);
}

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

.btn-secondary:hover {
    background: #cbd5e1;
}

/* Controls */
.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
    padding: 30px;
    background: #ffffff;
    border-radius: 15px;
    border: 1px solid var(--border-color);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-group label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.control-group input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.5);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

.speed-markers {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.control-group select {
    padding: 10px;
    background: #ffffff;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
}

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

.control-group input[type="color"] {
    height: 50px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    background: #ffffff;
}

/* Reader Display */
.reader-display {
    margin-bottom: 40px;
}

.word-container {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 15px;
    margin-bottom: 20px;
    padding: 40px;
    border: 1px solid var(--border-color);
}


.focal-letter {
    font-weight: 800;
    opacity: 1;
    text-shadow: 0 0 1px rgba(255, 255, 255, 0.3);
}

/* Color customization will be applied inline */
.current-word {
    font-size: 48px;
    font-weight: 500;
    letter-spacing: 2px;
    text-align: center;
    user-select: none;
    line-height: 1.5;
    color: #0f172a;
}

/* Progress Bar */
.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    transition: width 0.3s ease;
}

.stats {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
}

/* Playback Controls */
.playback-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.btn-icon {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: #e2e8f0;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: #cbd5e1;
    transform: scale(1.1);
}

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

.btn-play {
    width: 70px;
    height: 70px;
    background: var(--primary-color);
    position: relative;
}

.btn-play::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
    opacity: 0;
    transition: all 0.3s;
}

.btn-play:hover::after {
    inset: -6px;
    opacity: 0.5;
}

.btn-play:hover {
    box-shadow: 0 8px 24px rgba(220, 38, 38, 0.4);
}

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

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2.5rem;
    }

    .section {
        padding: 25px;
    }

    .controls {
        grid-template-columns: 1fr;
        padding: 20px;
    }

    .current-word {
        font-size: 32px;
    }

    .word-container {
        min-height: 200px;
        padding: 20px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.current-word {
    animation: fadeIn 0.1s ease;
}

/* Email Signup Section */
.email-signup-section {
    text-align: center;
    margin-top: 40px;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.03) 0%, var(--card-bg) 100%);
    border-top: 3px solid var(--primary-color);
}

.email-signup-content h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 15px;
    font-weight: 600;
    letter-spacing: 1px;
}

.email-signup-content p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 25px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.email-form {
    display: flex;
    gap: 10px;
    max-width: 500px;
    margin: 0 auto 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.email-input {
    flex: 1;
    min-width: 250px;
    padding: 15px 20px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
}

.email-input:focus {
    outline: none;
    border-color: #ff0000;
}

.email-submit {
    padding: 15px 35px;
    white-space: nowrap;
}

.email-privacy {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 10px;
}

.email-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 8px;
    font-weight: 500;
}

.email-message.success {
    background: #d1fae5;
    color: #065f46;
}

.email-message.error {
    background: #fee2e2;
    color: #991b1b;
}

@media (max-width: 600px) {
    .email-form {
        flex-direction: column;
    }
    
    .email-input {
        width: 100%;
    }
}

/* Auth Pages */
.auth-section {
    max-width: 500px;
    margin: 40px auto;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
}

.auth-tab {
    flex: 1;
    padding: 15px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.3s;
}

.auth-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form h2 {
    margin-bottom: 25px;
    text-align: center;
    color: var(--text-color);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

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

.btn-full {
    width: 100%;
    margin-top: 10px;
}

.auth-message {
    margin-top: 20px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    display: none;
}

.auth-message.success {
    background: #d1fae5;
    color: #065f46;
}

.auth-message.error {
    background: #fee2e2;
    color: #991b1b;
}

.auth-message.info {
    background: #dbeafe;
    color: #1e40af;
}

.auth-footer {
    margin-top: 30px;
    text-align: center;
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.3s;
}

.back-link:hover {
    color: var(--primary-color);
}

/* Library Page */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px 30px;
}

.user-info {
    font-weight: 500;
}

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

.library-section h2 {
    margin-bottom: 25px;
    color: var(--primary-color);
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.book-card {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    transition: all 0.3s;
}

.book-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.1);
}

.book-card h3 {
    margin-bottom: 10px;
    color: var(--text-color);
}

.book-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.book-words {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

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

.book-actions .btn {
    flex: 1;
    padding: 10px;
    font-size: 0.9rem;
}

.loading-message,
.empty-message,
.error-message {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.upload-section h3 {
    margin-bottom: 20px;
}

.drop-zone {
    border: 3px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
    background: var(--bg-color);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(220, 38, 38, 0.02);
}

.drop-zone-text {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 8px;
}

.drop-zone-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.selected-file {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(220, 38, 38, 0.1);
    color: var(--primary-color);
    border-radius: 6px;
    font-size: 0.9rem;
    display: none;
}

.upload-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.form-input {
    flex: 1;
    min-width: 200px;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
}

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

.upload-status {
    margin-top: 10px;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.upload-status.success {
    background: #d1fae5;
    color: #065f46;
}

.upload-status.error {
    background: #fee2e2;
    color: #991b1b;
}

.upload-status.info {
    background: #dbeafe;
    color: #1e40af;
}

@media (max-width: 768px) {
    .user-bar {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .upload-form {
        flex-direction: column;
    }
    
    .books-grid {
        grid-template-columns: 1fr;
    }
}

/* Reader Page Styles */
.reader-header {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    border: 2px solid var(--primary-color);
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.1);
}

.reader-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.back-to-library {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.back-to-library:hover {
    background: rgba(220, 38, 38, 0.1);
}

.book-title-header {
    font-family: 'Times New Roman', serif;
    font-size: 1.5rem;
    font-weight: 700;
    flex: 1;
    text-align: center;
}

.user-email-small {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.reader-display {
    background: var(--card-bg);
    padding: 3rem;
    border-radius: 12px;
    border: 2px solid var(--primary-color);
    margin: 2rem 0;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.1);
}

.auto-save-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--success-color);
    color: white;
    border-radius: 8px;
    margin: 1rem auto;
    max-width: 300px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s;
}

.auto-save-indicator.show {
    opacity: 1;
    transform: translateY(0);
}

.save-icon {
    font-size: 1.2rem;
}

.save-text {
    font-weight: 600;
}

/* Message Notifications */
.message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-weight: 600;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

.message.success {
    border-left: 4px solid var(--success-color);
    color: var(--success-color);
}

.message.error {
    border-left: 4px solid #dc2626;
    color: #dc2626;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
