:root {
    --bg-color: #f8f9fa;
    --text-color: #333;
    --card-bg: white;
    --border-color: #e9ecef;
    --primary-color: #007bff;
    --secondary-bg: #f8f9fa;
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --card-bg: #2d2d2d;
    --border-color: #404040;
    --primary-color: #4dabf7;
    --secondary-bg: #333333;
}

body {
    background: var(--bg-color);
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-color);
    transition: all 0.3s ease;
}

.navbar {
    background: var(--card-bg) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid var(--border-color);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--primary-color) !important;
}

.nav-link {
    color: var(--text-color) !important;
}

.nav-link:hover {
    color: var(--primary-color) !important;
}

.main-container {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-top: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.illust-header {
    background: var(--secondary-bg);
    color: var(--text-color);
    border-radius: 8px 8px 0 0;
    padding: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.illust-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.illust-author {
    font-size: 1.1rem;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 1rem;
}

.illust-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.5rem;
}

.meta-item {
    background: var(--card-bg);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.content-section {
    padding: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
    min-height: 120px;
}

.stat-card {
    background: var(--secondary-bg);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100px;
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--text-color);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.7;
}

.illust-description {
    background: var(--secondary-bg);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    line-height: 1.8;
    font-size: 1.1rem;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.illust-description a {
    color: var(--primary-color);
    text-decoration: none;
}

.illust-description a:hover {
    text-decoration: underline;
}

.image-gallery {
    margin: 2rem 0;
}

.gallery-item {
    margin-bottom: 2rem;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

.gallery-image {
    width: 100%;
    max-width: 100%;
    max-height: 80vh;
    height: auto;
    display: block;
    object-fit: contain;
    margin: 0 auto;
}

.gallery-caption {
    padding: 1rem;
    text-align: center;
    background: var(--card-bg);
    color: var(--text-color);
    border-top: 1px solid var(--border-color);
}

.btn-custom {
    background: var(--primary-color);
    border: none;
    border-radius: 6px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    color: white;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s ease;
}

.btn-custom:hover {
    background: var(--primary-color);
    opacity: 0.9;
    color: white;
    transform: translateY(-1px);
}

.btn-outline-custom {
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s ease;
    background: transparent;
}

.btn-outline-custom:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

.footer {
    background: var(--secondary-bg);
    color: var(--text-color);
    text-align: center;
    padding: 2rem;
    border-radius: 0 0 8px 8px;
    border-top: 1px solid var(--border-color);
}

.tag {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    margin: 0.25rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}

.thumbnail-container {
    text-align: center;
    margin-bottom: 2rem;
}

.main-thumbnail {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.gallery-container {
    max-width: 100%;
    margin: 0 auto;
}

.theme-toggle {
    background: var(--primary-color);
    border: none;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    opacity: 0.9;
}

@media (max-width: 768px) {
    .illust-title {
        font-size: 1.5rem;
    }

    .content-section {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .illust-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

    .gallery-image {
        max-height: 70vh;
        width: 100%;
    }

    .main-thumbnail {
        max-height: 50vh;
        width: 100%;
    }
}

/* Gallery Modal Styles */
.gallery-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
}

.gallery-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.gallery-modal-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
    color: white;
}

.gallery-close {
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    color: white;
    transition: all 0.2s ease;
}

.gallery-close:hover {
    color: #ff6b6b;
    transform: scale(1.1);
}

.gallery-counter {
    font-size: 1.1rem;
    font-weight: 600;
}

.gallery-modal-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 4rem 1rem 6rem 1rem;
    overflow: hidden;
}

.gallery-main-image-container {
    position: relative;
    width: calc(100% - 2rem);
    height: calc(100% - 1rem);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.gallery-main-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    font-size: 1.2rem;
    backdrop-filter: blur(10px);
}

.gallery-nav:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.gallery-prev {
    left: 2rem;
}

.gallery-next {
    right: 2rem;
}

.gallery-modal-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 1rem 2rem;
}

.gallery-thumbnails {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.gallery-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.gallery-thumbnails::-webkit-scrollbar-track {
    background: transparent;
}

.gallery-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.gallery-thumbnail {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.gallery-thumbnail:hover {
    opacity: 1;
    transform: scale(1.05);
}

.gallery-thumbnail.active {
    border-color: var(--primary-color);
    opacity: 1;
}

.gallery-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Gallery item hover effect */
.gallery-item {
    cursor: pointer;
    transition: all 0.2s ease;
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Responsive design for gallery modal */
@media (max-width: 768px) {
    .gallery-modal-header {
        padding: 1rem;
    }

    .gallery-modal-body {
        padding: 3rem 0.5rem 5rem 0.5rem;
    }

    .gallery-nav {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .gallery-prev {
        left: 1rem;
    }

    .gallery-next {
        right: 1rem;
    }

    .gallery-modal-footer {
        padding: 1rem;
    }

    .gallery-thumbnail {
        width: 60px;
        height: 60px;
    }

    .gallery-counter {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .gallery-modal-body {
        padding: 2.5rem 0.25rem 4rem 0.25rem;
    }

    .gallery-nav {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }

    .gallery-prev {
        left: 0.5rem;
    }

    .gallery-next {
        right: 0.5rem;
    }

    .gallery-thumbnail {
        width: 50px;
        height: 50px;
    }
}

.comment-list .card,
.card.bookmark-user-card {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}
.comment-list .card-body {
    background: transparent;
    color: var(--text-color);
}
.comment-list .fw-bold,
.comment-list .text-muted,
.comment-list .small {
    color: var(--text-color) !important;
    opacity: 0.85;
}
.bookmark-user-card .fw-bold,
.bookmark-user-card .text-muted,
.bookmark-user-card .small {
    color: var(--text-color) !important;
    opacity: 0.85;
}
.tag {
    background: var(--primary-color);
    color: #fff;
}
.tag-more {
    background: var(--secondary-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}
.gallery-modal-header,
.gallery-modal-footer {
    background: var(--card-bg);
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
}
.gallery-modal-body {
    background: var(--bg-color);
    color: var(--text-color);
}
.gallery-close {
    color: var(--text-color);
}
.btn,
.btn-primary,
.btn-secondary,
.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-custom {
    color: var(--text-color);
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
}
.btn-primary {
    background: var(--primary-color);
    color: #fff;
    border: none;
}
.btn-primary:hover {
    background: #0056b3;
}
.btn-secondary {
    background: var(--secondary-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}
.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-custom:hover {
    background: var(--primary-color);
    color: #fff;
}
.ugoira-player-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto 1.5rem auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.ugoira-responsive-canvas {
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    background: #222;
    border-radius: 8px;
}
.ugoira-controls {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.ugoira-meta {
    color: var(--text-color) !important;
    text-align: center;
    opacity: 0.8;
}
.ugoira-controls input[type=range] {
    width: 200px;
    accent-color: var(--primary-color);
    background: transparent;
    margin: 0 8px;
    height: 4px;
}
.ugoira-controls input[type=range]::-webkit-slider-thumb {
    background: var(--primary-color);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    border: 2px solid var(--card-bg);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.ugoira-controls input[type=range]:focus {
    outline: none;
}
/* --- Ugoira Speed Slider Modern Style --- */
#ugoira-speed {
  flex: 1 1 140px;
  min-width: 100px;
  max-width: 240px;
  width: 100%;
  height: 8px;
  background: transparent;
  border-radius: 4px;
  margin: 0 12px;
  outline: none;
  accent-color: unset;
}
#ugoira-speed::-webkit-slider-runnable-track {
  height: 8px;
  background: linear-gradient(90deg, var(--primary-color) 0%, #b3d8ff 100%);
  border-radius: 4px;
}
#ugoira-speed::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-color);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  cursor: pointer;
  transition: background 0.2s, border 0.2s;
  margin-top: calc((8px - 28px) / 2);
}
#ugoira-speed:focus::-webkit-slider-thumb {
  border: 3px solid #0056b3;
  background: #0056b3;
}
#ugoira-speed:hover::-webkit-slider-thumb {
  background: #339cff;
}
#ugoira-speed::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-color);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  cursor: pointer;
  transition: background 0.2s, border 0.2s;
  position: relative;
  top: calc((8px - 28px) / 2);
}
#ugoira-speed:focus::-moz-range-thumb {
  border: 3px solid #0056b3;
  background: #0056b3;
}
#ugoira-speed:hover::-moz-range-thumb {
  background: #339cff;
}
#ugoira-speed::-ms-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-color);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  cursor: pointer;
  transition: background 0.2s, border 0.2s;
  margin-top: 0;
}
#ugoira-speed:focus::-ms-thumb {
  border: 3px solid #0056b3;
  background: #0056b3;
}
#ugoira-speed:hover::-ms-thumb {
  background: #339cff;
}
#ugoira-speed::-ms-fill-lower {
  background: var(--primary-color);
  border-radius: 4px;
}
#ugoira-speed::-ms-fill-upper {
  background: #b3d8ff;
  border-radius: 4px;
}
#ugoira-speed::-moz-range-track {
  height: 8px;
  background: linear-gradient(90deg, var(--primary-color) 0%, #b3d8ff 100%);
  border-radius: 4px;
}
#ugoira-speed:focus {
  outline: none;
}
@media (max-width: 600px) {
  #ugoira-speed {
    min-width: 60px;
    max-width: 120px;
    height: 8px;
  }
}
body.dark #ugoira-speed::-webkit-slider-runnable-track,
body.dark #ugoira-speed::-moz-range-track,
body.dark #ugoira-speed::-ms-fill-lower,
body.dark #ugoira-speed::-ms-fill-upper {
  background: linear-gradient(90deg, #4dabf7 0%, #222 100%);
}
body.dark #ugoira-speed::-webkit-slider-thumb,
body.dark #ugoira-speed::-moz-range-thumb,
body.dark #ugoira-speed::-ms-thumb {
  background: #4dabf7;
  border: 3px solid #181a1b;
}
body.dark #ugoira-speed:focus::-webkit-slider-thumb,
body.dark #ugoira-speed:focus::-moz-range-thumb,
body.dark #ugoira-speed:focus::-ms-thumb {
  border: 3px solid #339cff;
  background: #339cff;
}
body.dark #ugoira-speed:hover::-webkit-slider-thumb,
body.dark #ugoira-speed:hover::-moz-range-thumb,
body.dark #ugoira-speed:hover::-ms-thumb {
  background: #90caff;
}