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

:root {
    color-scheme: light;
    --md-surface: #f5f7fb;
    --md-surface-raised: #ffffff;
    --md-surface-muted: #eef2fb;
    --md-outline: #d5dae8;
    --md-text: #0f172a;
    --md-text-muted: #5f6b83;
    --md-primary: #5c6ac4;
    --md-primary-dark: #4452a3;
    --md-secondary: #4a5568;
    --md-success: #3fb984;
    --md-warning: #f5a524;
    --md-danger: #e95464;
    --radius-xl: 1.25rem;
    --radius-lg: 1rem;
    --radius-md: 0.75rem;
    --radius-pill: 999px;
    --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.1);
    --shadow-md: 0 8px 16px rgba(15, 23, 42, 0.08), 0 4px 6px rgba(15, 23, 42, 0.09);
    --shadow-inset: inset 0 0 0 1px rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] {
    color-scheme: dark;
    --md-surface: #11131b;
    --md-surface-raised: #1b1e29;
    --md-surface-muted: #1f2230;
    --md-outline: #2f3445;
    --md-text: #e7ecff;
    --md-text-muted: #9aa2bf;
    --md-primary: #8ea5ff;
    --md-primary-dark: #6985ff;
    --md-secondary: #c0c6e1;
    --md-success: #7ee0b3;
    --md-warning: #ffc168;
    --md-danger: #ff8b94;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-inset: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    font-family: 'Open Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--md-surface);
    color: var(--md-text);
    transition: background 0.3s ease, color 0.3s ease;
}

.app-body {
    background: var(--md-surface);
}

a {
    color: var(--md-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--md-primary-dark);
}

.soft-surface {
    background: var(--md-surface);
}

.soft-nav {
    background: var(--md-surface-raised);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: 1.25rem 1.5rem;
    border: 1px solid rgba(0, 0, 0, 0.02);
    position: sticky;
    top: 1rem;
    z-index: 1050;
}

.soft-nav-wrapper {
    position: sticky;
    top: 0;
    z-index: 1100;
    background: transparent;
}


.soft-card {
    border: 1px solid var(--md-outline);
    border-radius: var(--radius-lg);
    background: var(--md-surface-raised);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.soft-card.reader-hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

[data-theme="dark"] .soft-card {
    border-color: rgba(255, 255, 255, 0.05);
}

.soft-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.soft-card-inset {
    border-radius: var(--radius-lg);
    background: var(--md-surface-muted);
    box-shadow: var(--shadow-inset);
    padding: 1rem;
}

.soft-button {
    border: none;
    border-radius: var(--radius-pill);
    padding: 0.5rem 1.4rem;
    font-weight: 600;
    background: var(--md-surface-muted);
    color: var(--md-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.soft-toggle {
    border-radius: var(--radius-pill);
    padding: 0.35rem 0.75rem;
    border: 1px solid rgba(0,0,0,0.1);
    background: var(--md-surface);
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.soft-toggle-track {
    width: 38px;
    height: 20px;
    border-radius: 999px;
    background: rgba(0,0,0,0.08);
    position: relative;
    transition: background 0.2s ease;
}

.soft-toggle-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--md-surface);
    position: absolute;
    top: 2px;
    left: 2px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease;
}

.soft-toggle-on .soft-toggle-track {
    background: rgba(92, 106, 196, 0.6);
}

.soft-toggle-on .soft-toggle-thumb {
    transform: translateX(18px);
}

.soft-button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.soft-button:active {
    transform: translateY(0);
}

.soft-button-primary {
    background: var(--md-primary);
    color: #fff;
}

.soft-button-ghost {
    background: transparent;
    color: var(--md-text-muted);
    box-shadow: none;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .soft-button-ghost {
    border-color: rgba(255, 255, 255, 0.12);
}

.soft-button-danger {
    background: var(--md-danger);
    color: #fff;
}

.soft-button-sm {
    padding: 0.35rem 0.95rem;
    font-size: 0.85rem;
}

.soft-button-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.soft-tag,
.badge {
    border-radius: var(--radius-pill);
    padding: 0.35rem 0.85rem;
    background: var(--md-surface-muted);
    color: var(--md-text-muted);
    border: 1px solid var(--md-outline);
}

.soft-input,
.form-control,
.form-select,
textarea,
input {
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--md-outline) !important;
    background: var(--md-surface-raised) !important;
    color: var(--md-text) !important;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--md-primary) !important;
    box-shadow: 0 0 0 3px rgba(92, 106, 196, 0.2);
}

.messages .alert {
    border-radius: var(--radius-md);
    border: 1px solid var(--md-outline);
    background: var(--md-surface-raised);
    color: var(--md-text);
    box-shadow: var(--shadow-sm);
}

.reader-panel {
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    background: var(--md-surface-muted);
    border: 1px solid var(--md-outline);
    transition: background 0.3s ease, color 0.3s ease;
}

.reader-display {
    min-height: 110px;
    font-size: 1.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: var(--radius-md);
    background: var(--md-surface-raised);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.5rem;
    color: var(--md-text);
}

.reader-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: flex-start;
}

.reader-toolbar-actions .soft-button {
    min-width: 120px;
    justify-content: flex-start;
}

.reader-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.reader-controls .form-label {
    margin-bottom: 0.35rem;
}

.reader-controls .soft-button {
    width: 100%;
}

.reader-settings-header {
    gap: 0.5rem;
}

.reader-settings-panel {
    max-height: 0;
    overflow: hidden;
    display: grid;
    gap: 0.8rem;
    padding: 0;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.reader-settings-panel.open {
    max-height: 520px;
    padding-top: 1rem;
}

.reader-settings-panel.collapsed > * {
    display: none;
}

.reader-source-panel-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.4rem;
}

.reader-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--md-text-muted);
    font-size: 0.9rem;
}

.reader-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.reader-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.reader-progress-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.reader-progress-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.reader-progress-track-narrow {
    flex: 1 1 220px;
    min-width: 160px;
}

.reader-settings-inline-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
}

.reader-settings-inline-toggle .soft-toggle-track {
    width: 40px;
    height: 18px;
}

.reader-source-inline-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
}

.reader-source-inline-toggle .soft-toggle-track {
    width: 40px;
    height: 18px;
}
.reader-progress-track {
    flex-grow: 1;
    height: 6px;
    border-radius: var(--radius-pill);
    background: var(--md-outline);
    overflow: hidden;
    position: relative;
}

.reader-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 0%;
    border-radius: inherit;
    background: var(--md-primary);
    transition: width 0.2s ease;
}

.reader-progress-label {
    font-size: 0.8rem;
    color: var(--md-text-muted);
    min-width: 2.5rem;
    text-align: right;
}

.reader-source {
    margin-top: 1.5rem;
}

.reader-source-label {
    display: block;
    margin-bottom: 0.35rem;
}

.reader-source-inner {
    border-radius: var(--radius-lg);
    border: 1px solid var(--md-outline);
    padding: 0.65rem;
    background: var(--md-surface-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    font-size: 0.9rem;
    max-height: 180px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.reader-source-word {
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    border-radius: var(--radius-pill);
    color: var(--md-text-muted);
    transition: background 0.2s ease, color 0.2s ease;
}

.reader-source-word:hover,
.reader-source-word:focus-visible {
    background: var(--md-surface);
    color: var(--md-primary-dark);
}

.reader-source-word.active {
    background: var(--md-primary);
    color: var(--md-surface);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.4);
}

.reader-source-wrapper.collapsed .reader-source-text,
.reader-source-wrapper.collapsed .reader-source-inner {
    display: none;
}

[data-reader-shell]:fullscreen {
    background: var(--md-surface);
    padding: 2rem;
    border-radius: 0;
}

[data-reader-shell]:fullscreen .reader-panel {
    background: var(--md-surface);
    border-color: transparent;
    box-shadow: none;
}

[data-reader-shell]:fullscreen .reader-display {
    min-height: 180px;
    font-size: 2.6rem;
}

.reader-display {
    transition: font-size 0.2s ease, font-family 0.2s ease;
}

.comment-card {
    border-radius: var(--radius-md);
    border: 1px solid var(--md-outline);
    padding: 1rem 1.1rem;
    background: var(--md-surface-raised);
}

.soft-list {
    border-radius: var(--radius-lg);
    background: var(--md-surface-muted);
    border: 1px solid var(--md-outline);
    padding: 1rem;
}

.soft-link {
    color: var(--md-primary);
    font-weight: 600;
}

.soft-link:hover {
    color: var(--md-primary-dark);
}

.soft-table {
    border-collapse: separate;
    border-spacing: 0 10px;
}

.soft-table tr {
    background: var(--md-surface-raised);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.auth-wrapper {
    max-width: 480px;
    margin: 0 auto;
}

.soft-hero {
    border-radius: var(--radius-xl);
    background: var(--md-surface-muted);
    border: 1px solid var(--md-outline);
    box-shadow: var(--shadow-sm);
    padding: 2rem;
}

.hero-spotlight {
    position: relative;
    border-radius: var(--radius-xl);
    background: radial-gradient(circle at top right, rgba(92, 106, 196, 0.25), var(--md-surface-muted));
    border: 1px solid rgba(92, 106, 196, 0.25);
    padding: 2.5rem;
    overflow: hidden;
}

.hero-spotlight::after {
    content: '';
    position: absolute;
    inset: auto -40% -30% auto;
    width: 200px;
    height: 200px;
    background: rgba(92, 106, 196, 0.2);
    border-radius: 50%;
    filter: blur(40px);
}

.hero-highlight {
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--md-primary);
}

.hero-title {
    color: var(--md-text);
}

.hero-description {
    color: var(--md-text-muted);
}

.hero-cta a {
    min-width: 150px;
}

.hero-feature-list .hero-feature-bullet {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--md-primary);
    display: inline-block;
}

.hero-stat-card {
    background: linear-gradient(135deg, rgba(92, 106, 196, 0.08), var(--md-surface-raised));
    border-radius: var(--radius-lg);
    border: 1px solid rgba(92, 106, 196, 0.15);
}

.rich-text {
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--md-text);
}

.rich-text h2,
.rich-text h3,
.rich-text h4 {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.rich-text p {
    margin-bottom: 1rem;
}

.soft-cover {
    border-radius: var(--radius-lg);
    width: 100%;
    box-shadow: var(--shadow-md);
}

.soft-divider {
    height: 1px;
    width: 100%;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0),
        var(--md-outline),
        rgba(255, 255, 255, 0)
    );
    margin: 2rem 0;
}

.soft-meta-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.soft-meta-pill {
    font-size: 0.85rem;
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius-pill);
    background: var(--md-surface-muted);
    border: 1px solid var(--md-outline);
    color: var(--md-text-muted);
}

.soft-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.soft-notice {
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    background: var(--md-surface-muted);
    border: 1px solid var(--md-outline);
}

.comment-form textarea {
    margin-bottom: 0.5rem;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.sidebar-card + .sidebar-card {
    margin-top: 1.5rem;
}

.soft-related-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.soft-related-item {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: var(--md-surface-muted);
    border: 1px solid var(--md-outline);
    text-decoration: none;
    color: var(--md-text);
    transition: transform 0.15s ease;
}

.soft-related-item:hover {
    transform: translateX(2px);
    color: var(--md-primary);
}

.soft-table-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--md-text-muted);
}

.ql-toolbar.ql-snow,
.ql-container.ql-snow {
    border: none !important;
    background: var(--md-surface-muted);
    color: var(--md-text);
}

.ql-toolbar.ql-snow {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border: 1px solid var(--md-outline) !important;
    border-bottom: none !important;
}

.ql-container.ql-snow {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    border: 1px solid var(--md-outline) !important;
    min-height: 240px;
}

.pagination .page-link {
    border: none;
    border-radius: var(--radius-pill) !important;
    margin: 0 0.2rem;
    padding: 0.35rem 1rem;
    background: var(--md-surface-muted);
    box-shadow: var(--shadow-sm);
    color: var(--md-text);
}

.pagination .page-item.active .page-link {
    background: var(--md-primary);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    opacity: 0.6;
}

.form-range {
    accent-color: var(--md-primary);
}

.theme-toggle {
    min-width: 44px;
}

.theme-toggle span {
    font-size: 1rem;
}

.app-footer {
    background: var(--md-surface-raised);
    border-radius: var(--radius-lg);
    border: 1px solid var(--md-outline);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
}

@media (max-width: 576px) {
    .reader-display {
        font-size: 1.5rem;
    }

    .reader-toolbar {
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .soft-input,
[data-theme="dark"] .reader-display,
[data-theme="dark"] .reader-controls,
[data-theme="dark"] .reader-source-inner {
    background: var(--md-surface-muted);
    color: var(--md-text);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .reader-display,
[data-theme="dark"] .reader-sidebar,
[data-theme="dark"] .reader-meta span,
[data-theme="dark"] .soft-card .form-label,
[data-theme="dark"] .soft-card a,
[data-theme="dark"] .soft-card p,
[data-theme="dark"] .soft-card .soft-meta-pill,
[data-theme="dark"] .soft-card .text-muted {
    color: var(--md-text) !important;
}

[data-theme="dark"] .form-control::-webkit-input-placeholder,
[data-theme="dark"] .form-control::-moz-placeholder,
[data-theme="dark"] .form-control:-ms-input-placeholder,
[data-theme="dark"] .form-control::-ms-input-placeholder,
[data-theme="dark"] .form-control::placeholder,
[data-theme="dark"] .soft-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
    opacity: 1;
}
