:root {
    --primary-color: #009688;
    --primary-dark: #00796B;
    --primary-light: #B2DFDB;
    --accent-color: #536DFE;
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-on-primary: #FFFFFF;
    --divider-color: #BDBDBD;
    --background-color: #FAFAFA;
    --surface-color: #FFFFFF;

    --elevation-1: 0 2px 1px -1px rgba(0,0,0,0.2), 0 1px 1px 0 rgba(0,0,0,0.14), 0 1px 3px 0 rgba(0,0,0,0.12);
    --elevation-2: 0 3px 1px -2px rgba(0,0,0,0.2), 0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12);
    --elevation-4: 0 2px 4px -1px rgba(0,0,0,0.2), 0 4px 5px 0 rgba(0,0,0,0.14), 0 1px 10px 0 rgba(0,0,0,0.12);
    --elevation-8: 0 5px 5px -3px rgba(0,0,0,0.2), 0 8px 10px 1px rgba(0,0,0,0.14), 0 3px 14px 2px rgba(0,0,0,0.12);
}

/* Reset and Base Styles */
body {
    margin: 0;
    padding: 0;
    font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    padding-top: 88px; /* Space for fixed AppBar */
}

/* AppBar */
.app-bar {
    background-color: var(--primary-color);
    color: var(--text-on-primary);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center; /* Center content horizontally */
    text-align: center;
    padding: 0 24px;
    box-shadow: var(--elevation-4);
    z-index: 1000;
}

.app-bar h1 {
    font-size: 20px;
    font-weight: 500;
    margin: 0;
    letter-spacing: 0.15px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-bar p {
    display: none; /* Hide subtitle in app bar for cleaner look, or move to tooltip */
}

/* Book Grid */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

/* Material Card */
.book-card {
    background-color: var(--surface-color);
    border-radius: 4px;
    box-shadow: var(--elevation-1);
    transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
}

.book-card:hover {
    box-shadow: var(--elevation-8);
    transform: translateY(-2px);
}

.book-card-content {
    padding: 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 120px;
    text-align: center;
    /* Primary color background for the visual part of the card */
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--text-on-primary);
}

.book-title {
    font-size: 24px;
    font-weight: 400;
    margin-bottom: 8px;
    line-height: 1.334;
    letter-spacing: 0em;
}

.book-meta {
    font-size: 14px;
    font-weight: 400;
    opacity: 0.9;
    letter-spacing: 0.25px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.2);
}

/* Ripple effect (simple CSS approximation) */
.book-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0);
    transition: background-color 0.2s;
}

.book-card:active::after {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Read Page Styles */
.read-body {
    background-color: #FFFFFF;
}

/* FAB (Floating Action Button) */
.fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background-color: var(--accent-color);
    color: var(--text-on-primary);
    box-shadow: var(--elevation-4);
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s, background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    outline: none;
    font-size: 24px;
}

.fab:hover {
    box-shadow: var(--elevation-8);
    background-color: #657bf7; /* Slightly lighter accent */
}

.fab:active {
    box-shadow: var(--elevation-8);
    transform: scale(0.98);
}

/* Position FABs */
.menu-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    background-color: var(--primary-color);
}

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

.font-btn {
    position: fixed;
    top: 16px;
    right: 88px; /* 16px + 56px + 16px spacing */
    background-color: var(--surface-color);
    color: var(--text-secondary); /* Grey icon on white background */
}

.font-btn:hover {
    background-color: #f0f0f0;
}

.font-btn svg {
    fill: var(--text-secondary);
}

/* Menus - Material Sheets/Dialogs */
.menu-overlay {
    position: fixed;
    top: 80px;
    right: 16px;
    background: var(--surface-color);
    border-radius: 4px;
    box-shadow: var(--elevation-8);
    padding: 8px 0;
    z-index: 99;
    min-width: 200px;
}

#book-menu {
    display: none;
    position: fixed;
    top: 80px;
    right: 16px;
    background: var(--surface-color);
    border-radius: 4px;
    box-shadow: var(--elevation-8);
    padding: 8px 0;
    max-height: 80vh;
    overflow-y: auto;
    max-width: 320px;
    min-width: 250px;
    z-index: 1000;
    transform-origin: top right;
    animation: menu-pop 0.2s cubic-bezier(0.0, 0.0, 0.2, 1);
}

@keyframes menu-pop {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

#book-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#book-menu li {
    padding: 0;
}

.book-menu-item {
    cursor: pointer;
    font-size: 16px;
    color: var(--text-primary);
    display: block;
    padding: 12px 24px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color 0.2s;
}

.book-menu-item:hover {
    background-color: rgba(0, 0, 0, 0.04);
    color: var(--primary-color);
}

/* Font Setting Menu */
#font-setting-menu {
    display: none;
    position: fixed;
    top: 80px;
    right: 88px;
    background: var(--surface-color);
    padding: 16px;
    border-radius: 4px;
    box-shadow: var(--elevation-8);
    z-index: 1000;
    text-align: center;
    min-width: 200px;
    animation: menu-pop 0.2s cubic-bezier(0.0, 0.0, 0.2, 1);
}

.font-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.font-control-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.font-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.icon-btn {
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f5f5f5;
    color: var(--text-primary);
    font-size: 20px;
    transition: background-color 0.2s;
    user-select: none;
}

.icon-btn:hover {
    background-color: #e0e0e0;
}

.current-size {
    font-size: 18px;
    font-weight: 500;
    color: var(--primary-color);
    min-width: 30px;
    text-align: center;
}

/* Context Menu */
#context-menu {
    display: none;
    position: absolute;
    background: #333;
    color: white;
    border-radius: 4px;
    padding: 0;
    z-index: 2000;
    transform: translate3d(-50%, -100%, 0px);
    box-shadow: var(--elevation-4);
    overflow: hidden;
}

.context-menu-content {
    display: flex;
}

.context-menu-item {
    cursor: pointer;
    padding: 12px 16px;
    font-size: 14px;
    transition: background-color 0.2s;
}

.context-menu-item:hover {
    background-color: #444;
}

/* Book Content */
#book-content {
    background-color: #FFFFFF;
    fill: var(--text-primary);
    font-size: 24px;
    font-family: 'syhtRegular', "Noto Serif SC", serif;
    padding: 0;
    margin: 0;
    position: fixed;
    left: 0;
    top: 0;
    z-index: -1;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .container {
        padding: 16px;
        padding-top: 72px;
    }

    .app-bar {
        height: 56px;
        padding: 0 16px;
    }

    .menu-btn, .font-btn {
        top: 8px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .font-btn {
        right: 64px;
    }

    #book-menu, #font-setting-menu {
        top: 60px;
    }
}
