:root {
    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #f0fdfa;
    
    --bg: #ffffff;
    --text: #334155;
    --text-dark: #0f172a;
    --border: #e2e8f0;
}

body {
    font-family: 'Segoe UI', 'Inter', sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

* {
    box-sizing: border-box;
}

#app {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 0;
    min-height: 100vh;
    background: #fff;
    box-shadow: none;
    position: relative;
    z-index: 1;
}

#home-view {
    padding: 20px;
    padding-top: 80px;
}

.home-header {
    text-align: center;
    margin-bottom: 40px;
}

.home-header h2 {
    color: var(--primary-dark); 
    margin-bottom: 25px;
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.search-container {
    width: 100%;
    max-width: 100%;
}

#topic-search {
    width: 100%;
    padding: 18px 24px;
    border: 2px solid var(--border);
    border-radius: 16px;
    font-size: 1.1rem;
    outline: none;
    transition: all 0.3s ease;
    background: var(--primary-light); 
    color: var(--text-dark);
}

#topic-search::placeholder {
    color: #94a3b8;
}

#topic-search:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 4px 20px rgba(13, 148, 136, 0.15);
}

.topic-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px;
    margin-bottom: 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.01);
}

.topic-link::after {
    content: '→';
    color: var(--primary);
    font-weight: 900;
    font-size: 1.4rem;
    transition: transform 0.2s;
}

.topic-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(13, 148, 136, 0.08);
    border-color: var(--primary);
    color: var(--primary-dark);
}

.topic-link:hover::after {
    transform: translateX(5px);
}

.topic-link:active {
    transform: scale(0.98);
}

#topic-view {
    width: 100%;
    min-height: 100vh;
    background: #fff;
    padding-bottom: 40px;
}

.hidden {
    display: none !important;
}

.topic-header-bar {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center; 
}

#back-to-home {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid transparent;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

#back-to-home:hover {
    background: #ccfbf1;
    border-color: #99f6e4;
    text-decoration: none;
}

.content-wrapper {
    padding: 20px 20px 40px 20px;
}

#current-topic-title {
    font-size: 2rem;
    margin-top: 10px;
    margin-bottom: 35px;
    color: var(--primary-dark);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.chapter-item {
    background: white;
    border: 1px solid var(--border);
    margin-bottom: 16px;
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.chapter-item.open {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.05);
}

.chapter-header {
    padding: 22px 24px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-dark);
    background: #fff;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chapter-header::after {
    content: '+';
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--primary);
}

.chapter-item.open .chapter-header {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.chapter-item.open .chapter-header::after {
    content: '−';
    font-weight: 700;
}

.chapter-header:hover {
    background: #fafafa;
}

.chapter-body-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease-out;
}

.chapter-item.open .chapter-body-wrapper {
    grid-template-rows: 1fr;
    border-top: 1px solid rgba(13, 148, 136, 0.1);
}

.chapter-content {
    min-height: 0;
    padding: 0 24px;
    line-height: 1.65;
    color: var(--text);
    font-size: 1.05rem;
}

.chapter-item.open .chapter-content {
    padding: 24px;
}

.chapter-content ul {
    padding-left: 20px;
    margin-top: 5px;
}
.chapter-content li {
    margin-bottom: 8px;
    padding-left: 5px;
}
.chapter-content li::marker {
    color: var(--primary);
}

#hamburger-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 48px;
    height: 48px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}

#hamburger-btn:active {
    transform: scale(0.95);
    background: var(--primary-light);
}

#hamburger-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--text-dark);
    border-radius: 2px;
    transition: background 0.2s;
}

#hamburger-btn:hover span {
    background-color: var(--primary);
}

#menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

#main-menu {
    position: fixed;
    top: 0;
    left: -350px;
    width: 320px;
    height: 100vh;
    background: #ffffff;
    z-index: 2001;
    box-shadow: 10px 0 30px rgba(0,0,0,0.1);
    transition: cubic-bezier(0.4, 0.0, 0.2, 1) 0.4s;
    padding: 30px 25px;
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

#main-menu.active {
    left: 0;
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 25px;
    margin-bottom: 20px;
}

.menu-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-dark);
}

#close-menu {
    background: var(--primary-light);
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--primary);
    padding: 8px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#close-menu:hover {
    background: #ccfbf1;
    color: var(--primary-dark);
}

#library-categories {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none; 
    -ms-overflow-style: none;
}
#library-categories::-webkit-scrollbar { 
    display: none; 
}

.lib-category {
    margin-bottom: 35px;
}

.lib-cat-title {
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 15px;
    text-transform: uppercase;
    font-size: 1rem;
    letter-spacing: 1.5px;
    padding-left: 12px;
}

.lib-doc-link {
    display: block;
    padding: 14px 16px;
    color: var(--text-dark);
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 500;
    border-radius: 12px;
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.lib-doc-link:hover {
    color: var(--primary-dark);
    background-color: var(--primary-light);
    transform: translateX(4px);
}

.lib-doc-link:active {
    background-color: #ccfbf1;
    transform: translateX(2px);
}

#reader-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: white;
    z-index: 4000;
    display: flex;
    flex-direction: column;
}

#reader-view.hidden {
    display: none;
}

.reader-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    background: white;
    display: flex;
    align-items: center;
    position: relative; 
    height: 70px;
}

#reader-title {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    padding: 0 90px; 
    margin: 0;
    
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    color: var(--primary-dark); 
    
    white-space: normal; 
    overflow: visible;
    text-overflow: clip;
    line-height: 1.3;
    pointer-events: none; 
}

#close-reader {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    z-index: 2;
    transition: all 0.2s;
}

#close-reader:hover {
    background: #ccfbf1;
}

.reader-body {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.7;
    font-size: 1.1rem;
    color: var(--text);
}

.reader-body h3 {
    color: var(--primary-dark);
    margin-top: 30px;
    margin-bottom: 15px;
}

.lib-subcat-title {
    font-weight: 600;
    color: var(--primary-dark);
    margin-top: 15px;
    margin-bottom: 8px;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
}