* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Pin color-scheme so the browser doesn't darken the page when the device is in system dark mode
   but the user hasn't turned on the page's dark theme. JS sets it to match the app theme. */
html {
    color-scheme: light;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #007DC3 0%, #004A8D 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
    min-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.header-logo {
    width: 124px;
    height: 55px;
    flex-shrink: 0;
}

.header-text {
    text-align: left;
}

h1 {
    color: #007DC3;
    font-size: 1.5em;
    margin-bottom: 5px;
    font-weight: 700;
}

.header-subtitle {
    color: #666;
    font-size: 0.9em;
    margin: 0;
}

.content-wrapper {
    flex: 1;
}

footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
    text-align: center;
    color: #666;
    font-size: 0.9em;
}

.search-container {
    margin-bottom: 30px;
}

.search-input {
    width: 100%;
    padding: 15px 20px;
    font-size: 16px;
    border: 2px solid #007DC3;
    border-radius: 8px;
    outline: none;
    transition: all 0.3s ease;
    background: white;
}

.search-input:focus {
    border-color: #004A8D;
    box-shadow: 0 0 0 3px rgba(0, 125, 195, 0.2);
}

.floating-controls {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-category-control {
    padding: 8px 14px;
    font-size: 0.9em;
    border: 2px solid #007DC3;
    border-radius: 6px;
    background: white;
    color: #007DC3;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-category-control:hover {
    background: #f0f4ff;
    border-color: #004A8D;
    color: #004A8D;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.btn-category-control-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-category-control-icon .btn-expand-collapse-icon,
.btn-category-control-icon .btn-theme-icon,
.btn-category-control-icon .btn-compact-icon {
    font-size: 1.4em;
    line-height: 1;
}

/* Night mode (dark theme) */
body.theme-dark {
    background: linear-gradient(135deg, #0d2137 0%, #051a2d 100%);
    color: #e0e0e0;
}

body.theme-dark .container {
    background: #1a2d42;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

body.theme-dark header {
    border-bottom-color: #2d4558;
}

body.theme-dark .header-subtitle {
    color: #a0b8c8;
}

body.theme-dark h1 {
    color: #5ba3d0;
}

body.theme-dark .search-input {
    background: #152535;
    border-color: #2d4558;
    color: #e0e0e0;
}

body.theme-dark .search-input:focus {
    border-color: #5ba3d0;
    box-shadow: 0 0 0 3px rgba(91, 163, 208, 0.25);
}

body.theme-dark .search-input::placeholder {
    color: #7a8f9e;
}

body.theme-dark .btn-category-control {
    background: #152535;
    border-color: #5ba3d0;
    color: #5ba3d0;
}

body.theme-dark .btn-category-control:hover {
    background: #1e3649;
    border-color: #7bb8e0;
    color: #7bb8e0;
}

body.theme-dark .category-header {
    background: linear-gradient(135deg, #1e4a6e 0%, #0d3249 100%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

body.theme-dark .bookmark-card {
    background: #152535;
    border-color: #2d4558;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.theme-dark .bookmark-card:hover {
    border-color: #5ba3d0;
    box-shadow: 0 4px 15px rgba(30, 74, 110, 0.4);
}

body.theme-dark .bookmark-card.selected {
    border-color: #5ba3d0;
    background: #1e3649;
    box-shadow: 0 4px 15px rgba(91, 163, 208, 0.3);
}

body.theme-dark .bookmark-title {
    color: #7bb8e0;
}

body.theme-dark .bookmark-url,
body.theme-dark .bookmark-description-preview {
    color: #a0b8c8;
}

body.theme-dark .bookmark-favorite {
    color: #4a6578;
}

body.theme-dark .bookmark-favorite:hover {
    color: #5ba3d0;
}

body.theme-dark .bookmark-favorite.bookmark-favorite-is-favorite {
    color: #e6b800;
}

body.theme-dark footer {
    border-top-color: #2d4558;
    color: #a0b8c8;
}

body.theme-dark .no-results {
    color: #7a8f9e;
}

body.theme-dark .modal-content {
    background: #1a2d42;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

body.theme-dark .modal-title {
    color: #7bb8e0;
}

body.theme-dark .modal-close,
body.theme-dark .modal-url-label,
body.theme-dark .modal-description-label {
    color: #a0b8c8;
}

body.theme-dark .modal-close:hover {
    color: #7bb8e0;
}

body.theme-dark .modal-url-link {
    color: #5ba3d0;
    background: #152535;
}

body.theme-dark .modal-url-link:hover {
    background: #1e3649;
}

body.theme-dark .modal-description-content {
    color: #e0e0e0;
}

body.theme-dark .bookmark-favorite-modal {
    color: #4a6578;
}

body.theme-dark .bookmark-favorite-modal:hover {
    color: #5ba3d0;
}

body.theme-dark .bookmark-favorite-modal.bookmark-favorite-is-favorite {
    color: #e6b800;
}

.category-section {
    margin-bottom: 40px;
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(135deg, #007DC3 0%, #004A8D 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    font-size: 1.3em;
    font-weight: 600;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 125, 195, 0.4);
    cursor: pointer;
    user-select: none;
}

.category-header:hover {
    filter: brightness(1.05);
}

.category-toggle {
    flex-shrink: 0;
    background: none;
    border: none;
    color: white;
    font-size: 0.8em;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: transform 0.2s ease;
}

.category-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.category-section.collapsed .category-toggle {
    transform: rotate(-90deg);
}

.category-section.collapsed .category-content {
    display: none;
}

.bookmarks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* Compact cards (toggle in floating controls) */
body.cards-compact .bookmarks-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

body.cards-compact .bookmark-card {
    padding: 12px;
    padding-top: 28px;
    border-radius: 6px;
}

body.cards-compact .bookmark-favorite {
    top: 6px;
    right: 6px;
    font-size: 1.1em;
}

body.cards-compact .bookmark-title {
    font-size: 1em;
    margin-bottom: 6px;
}

body.cards-compact .bookmark-url {
    font-size: 0.8em;
    margin-bottom: 4px;
}

body.cards-compact .bookmark-description-preview {
    font-size: 0.75em;
    -webkit-line-clamp: 1;
}

body.cards-compact .category-section {
    margin-bottom: 24px;
}

body.cards-compact .category-header {
    padding: 10px 14px;
    font-size: 1.1em;
    margin-bottom: 12px;
}

.bookmark-card {
    position: relative;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    padding-top: 36px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.bookmark-favorite {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.3em;
    color: #ccc;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s ease;
}

.bookmark-favorite:hover {
    color: #007DC3;
}

.bookmark-favorite.bookmark-favorite-is-favorite {
    color: #e6b800;
}

.bookmark-favorite.bookmark-favorite-is-favorite:hover {
    color: #b38600;
}

.bookmark-card:hover {
    border-color: #007DC3;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 125, 195, 0.3);
}

.bookmark-card.selected {
    border-color: #007DC3;
    background: #f0f4ff;
    box-shadow: 0 4px 15px rgba(0, 125, 195, 0.4);
    transform: translateY(-2px);
}

.bookmark-title {
    color: #005A8D;
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 10px;
    word-wrap: break-word;
}

.bookmark-url {
    color: #555;
    font-size: 0.9em;
    word-break: break-all;
    margin-bottom: 8px;
}

.bookmark-description-preview {
    color: #555;
    font-size: 0.85em;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.3s ease;
    position: relative;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    transition: color 0.3s ease;
    background: none;
    border: none;
    line-height: 1;
}

.bookmark-favorite-modal {
    position: absolute;
    top: 15px;
    right: 50px;
    font-size: 1.5em;
    color: #ccc;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.bookmark-favorite-modal:hover {
    color: #007DC3;
}

.bookmark-favorite-modal.bookmark-favorite-is-favorite {
    color: #e6b800;
}

.modal-close:hover {
    color: #007DC3;
}

.modal-title {
    color: #007DC3;
    font-size: 1.8em;
    font-weight: 700;
    margin-bottom: 15px;
    padding-right: 80px;
}

.modal-category {
    display: inline-block;
    background: linear-gradient(135deg, #007DC3 0%, #004A8D 100%);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 20px;
}

.modal-url {
    margin-bottom: 20px;
}

.modal-source {
    margin-bottom: 20px;
}

.modal-url-label {
    color: #666;
    font-size: 0.9em;
    font-weight: 600;
    margin-bottom: 5px;
}

.modal-url-link {
    color: #007DC3;
    font-size: 1em;
    word-break: break-all;
    text-decoration: none;
    display: inline-block;
    padding: 8px 12px;
    background: #f0f4ff;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.modal-url-link:hover {
    background: #e8f0fe;
    text-decoration: underline;
}

.modal-description {
    margin-top: 20px;
}

.modal-description-label {
    color: #666;
    font-size: 0.9em;
    font-weight: 600;
    margin-bottom: 10px;
}

.modal-description-content {
    color: #333;
    line-height: 1.6;
    white-space: pre-wrap;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 1.1em;
}

.hidden {
    display: none;
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    .header-content {
        flex-direction: column;
        gap: 15px;
    }

    .header-text {
        text-align: center;
    }

    h1 {
        font-size: 1.3em;
    }

    .bookmarks-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        padding: 20px;
        width: 95%;
    }
}
