* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Hiragino Sans', 'Yu Gothic', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8f0f8 100%);
    min-height: 100vh;
}

header {
    background: white;
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.logo {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c5aa0;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-user-container {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.user-info-below-logo {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.85rem;
    color: #666;
    align-items: flex-start;
}

.user-info-below-logo .username-display {
    color: #2c5aa0;
    font-weight: 500;
}

.user-info-below-logo .plan-display {
    color: #666;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    transition: background 0.3s;
}

.user-info-below-logo .plan-display:hover {
    background: #f0f4f8;
}

.patent-badge {
    font-size: 0.65rem;
    background: #e3f2fd;
    color: #2c5aa0;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

.hamburger-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.patent-notice {
    font-size: 0.65rem;
    font-weight: 600;
    color: #1565c0;
    background: #b3d9ff;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    text-align: center;
    line-height: 1.3;
    white-space: nowrap;
    margin-left: -1rem;
}

.hamburger-menu {
    width: 40px;
    height: 40px;
    background: white;
    border: 2px solid #2c5aa0;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 8px;
    transition: all 0.3s;
    position: relative;
    z-index: 1001;
    margin-left: -0.45cm;
}

.hamburger-menu:hover {
    background: #f0f4f8;
}

.hamburger-menu span {
    display: block;
    width: 20px;
    height: 2px;
    background: #2c5aa0;
    transition: all 0.3s;
}

.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.dropdown-menu {
    position: absolute;
    top: 50px;
    left: 0;
    background: white;
    border: 2px solid #2c5aa0;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: none;
    flex-direction: column;
    min-width: 180px;
    overflow: hidden;
    z-index: 1000;
}

.dropdown-menu.active {
    display: flex;
}

.dropdown-menu a {
    padding: 1rem 1.5rem;
    color: #2c5aa0;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s;
    border-bottom: 1px solid #e3f2fd;
}

.dropdown-menu a:last-child {
    border-bottom: none;
}

.dropdown-menu a:hover {
    background: #f0f4f8;
    padding-left: 2rem;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-email {
    color: #666;
    font-size: 0.9rem;
}

.btn-logout {
    padding: 0.6rem 1rem;
    background: transparent;
    color: #2c5aa0;
    border: none;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-logout:hover {
    color: #1e4278;
    text-decoration: underline;
}

.container {
    max-width: 1200px;
    margin: 3rem auto;
    padding: 0 2rem 4rem;
}

.page-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #1a1a1a;
}

.page-subtitle {
    text-align: center;
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 3rem;
}

/* ローディング表示 */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.loading.show {
    opacity: 1;
    pointer-events: auto;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f0f4f8;
    border-top: 4px solid #2c5aa0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ライブラリグリッド */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.library-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.library-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.library-card-header {
    margin-bottom: 1rem;
}

.library-card-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
}

.library-card-author {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.library-card-style {
    display: inline-block;
    background: #e3f2fd;
    color: #2c5aa0;
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

.library-card-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #f0f4f8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.saved-date {
    color: #999;
    font-size: 0.85rem;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

.card-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-read {
    background: #2c5aa0;
    color: white;
}

.btn-read:hover {
    background: #1e3d70;
}

.btn-remove {
    background: transparent;
    color: #d32f2f;
    border: 1px solid #d32f2f;
}

.btn-remove:hover {
    background: #ffebee;
}

/* 空のライブラリメッセージ */
.empty-library {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
}

.empty-library h2 {
    font-size: 1.8rem;
    color: #1a1a1a;
    margin-bottom: 1rem;
}

.empty-library p {
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.btn-primary {
    padding: 0.8rem 2rem;
    background: #2c5aa0;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary:hover {
    background: #1e3d70;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44, 90, 160, 0.3);
}

/* 作品表示モーダル */
.story-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.story-modal.show {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-header {
    padding: 2rem;
    border-bottom: 1px solid #f0f4f8;
    display: flex;
    justify-content: space-between;
    align-items: start;
}

.modal-header h2 {
    font-size: 1.8rem;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
}

#modal-meta {
    color: #666;
    font-size: 0.95rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #999;
    cursor: pointer;
    transition: color 0.3s;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #666;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.story-content {
    line-height: 1.8;
    color: #1a1a1a;
}

.story-content h3 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
    color: #2c5aa0;
}

.story-content p {
    margin-bottom: 1rem;
    text-indent: 1em;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid #f0f4f8;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.btn-secondary {
    padding: 0.8rem 1.5rem;
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: #f0f4f8;
}

.btn-danger {
    padding: 0.8rem 1.5rem;
    background: #d32f2f;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-danger:hover {
    background: #b71c1c;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .page-title {
        font-size: 2rem;
    }

    .library-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1.5rem;
    }

    .modal-header h2 {
        font-size: 1.5rem;
    }

    .nav-right {
        flex-direction: column;
        align-items: flex-end;
        gap: 0.5rem;
    }
}
