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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 2.5rem;
    font-weight: 300;
}

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

.auth-container {
    display: flex;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    color: #555;
    font-size: 0.95rem;
}

.login-btn, .logout-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-weight: 500;
}

.login-btn {
    background-color: #4285f4;
    color: white;
}

.login-btn:hover {
    background-color: #357ae8;
}

.logout-btn {
    background-color: #e74c3c;
    color: white;
}

.logout-btn:hover {
    background-color: #c0392b;
}

.user-menu {
    position: relative;
}

.menu-btn {
    background: #f0f3f6;
    color: #2c3e50;
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 18px;
    cursor: pointer;
}

.menu-btn:hover {
    background: #e2e8f0;
}

.menu-panel {
    position: absolute;
    right: 0;
    top: 36px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    min-width: 160px;
    padding: 8px;
    z-index: 20;
    display: none;
}

.menu-item {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    color: #2c3e50;
}

.menu-item:hover {
    background: #f3f6f9;
}

/* Boards View Styles */
.boards-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.boards-header h2 {
    color: #2c3e50;
    font-size: 1.8rem;
    font-weight: 400;
    margin: 0;
}

.create-board-btn {
    padding: 12px 24px;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-weight: 500;
}

.create-board-btn:hover {
    background-color: #229954;
}

.boards-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.board-item {
    background: white;
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.board-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.board-item-name {
    font-size: 1.2rem;
    color: #2c3e50;
    font-weight: 500;
}

.board-item-count {
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Board Detail View Styles */
.board-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.back-btn {
    padding: 8px 16px;
    background-color: #95a5a6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.back-btn:hover {
    background-color: #7f8c8d;
}

.board-name {
    flex: 1;
    color: #2c3e50;
    font-size: 1.8rem;
    font-weight: 400;
    margin: 0;
}

.rename-board-btn, .delete-board-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.rename-board-btn {
    background-color: #f39c12;
    color: white;
}

.rename-board-btn:hover {
    background-color: #e67e22;
}

.delete-board-btn {
    background-color: #e74c3c;
    color: white;
}

.delete-board-btn:hover {
    background-color: #c0392b;
}

.add-card-section {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sort-panel {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.sort-panel-toggle {
    border: none;
    background: #f0f3f6;
    color: #2c3e50;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.sort-panel-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.sort-panel-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sort-panel-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #e2e8f0;
}

.sort-panel-chevron svg {
    display: block;
    transition: transform 0.15s ease;
}

.sort-panel-toggle[aria-expanded="false"] .sort-panel-chevron svg {
    transform: rotate(0deg);
}

.sort-panel-toggle[aria-expanded="true"] .sort-panel-chevron svg {
    transform: rotate(180deg);
}

.sort-panel-body {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    max-width: 240px;
    background: white;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.sort-panel-header {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9rem;
}

.sort-panel-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sort-option-btn {
    border: 1px solid transparent;
    border-radius: 10px;
    background: #f8fafc;
    color: #2c3e50;
    padding: 8px 10px;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

.sort-option-btn:hover {
    background: #eef2f7;
    transform: translateY(-1px);
}

.sort-option-btn.is-active {
    border-color: #2c3e50;
    background: #e2e8f0;
}

.sort-option-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.sort-panel.is-collapsed .sort-panel-body {
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
}

.sort-panel-body label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9rem;
}

.sort-panel-select {
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ddd;
    font-size: 0.9rem;
    background: white;
    color: #2c3e50;
}

.tag-filter-panel {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.tag-filter-toggle {
    border: none;
    background: #f0f3f6;
    color: #2c3e50;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.tag-filter-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tag-filter-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tag-filter-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #e2e8f0;
}

.tag-filter-chevron svg {
    display: block;
    transition: transform 0.15s ease;
}

.tag-filter-toggle[aria-expanded="false"] .tag-filter-chevron svg {
    transform: rotate(0deg);
}

.tag-filter-toggle[aria-expanded="true"] .tag-filter-chevron svg {
    transform: rotate(180deg);
}

.tag-filter-active-label {
    font-size: 0.85rem;
    color: #2c3e50;
    background: #e2e8f0;
    padding: 4px 8px;
    border-radius: 999px;
    display: none;
}

.tag-filter-panel.has-active-filter .tag-filter-active-label {
    display: inline-flex;
}

.tag-filter-body {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    max-width: 280px;
    background: white;
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
    z-index: 30;
}

.tag-filter-panel.is-collapsed .tag-filter-body {
    display: none;
}

.tag-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.tag-filter-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #2c3e50;
    font-weight: 500;
}

.tag-filter-clear {
    border: none;
    background: #ecf0f1;
    color: #2c3e50;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}

.tag-filter-clear:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.tag-filter-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-filter-empty {
    font-size: 0.9rem;
    color: #7f8c8d;
}

.tag-filter-option {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.tag-filter-option:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.tag-filter-option.is-selected {
    border-color: #2c3e50;
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.25);
}

#urlInput {
    flex: 1;
    max-width: 400px;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

#urlInput:focus {
    outline: none;
    border-color: #3498db;
}

#addCardBtn {
    padding: 12px 24px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-weight: 500;
}

#addCardBtn:hover {
    background-color: #2980b9;
}

#addCardBtn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.card.is-filtered-out {
    display: none;
}

.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: grab;
    touch-action: pan-y;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.card [contenteditable="true"] {
    -webkit-user-select: text;
    user-select: text;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.cards-container.drag-active .card {
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.cards-container.drag-active {
    touch-action: none;
}

.cards-container.drag-zoom {
    transform: scale(0.68);
    transform-origin: var(--drag-origin-x, 50%) var(--drag-origin-y, 20%);
    transition: transform 0.18s ease;
    will-change: transform;
}

.card.dragging {
    opacity: 0.6;
    transform: scale(0.98);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    cursor: grabbing;
}

.card-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background-color: #f8f9fa;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.card:hover .card-image img {
    transform: scale(1.05);
}

.card-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.2vw, 14px);
}

.card-url {
    font-size: 0.85rem;
    color: #7f8c8d;
    overflow: hidden;
}

.card-url a,
.public-card .card-url a {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #3498db;
    text-decoration: none;
}

.card-url a:hover,
.public-card .card-url a:hover {
    color: #2980b9;
    text-decoration: underline;
}

.card-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1.3;
}

.card-title-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
}

.card-drag-handle {
    display: none;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: #eef2f7;
    color: #2c3e50;
    cursor: grab;
    position: relative;
    padding: 0;
    touch-action: none;
}

.card-drag-handle::before {
    content: '';
    position: absolute;
    left: 8px;
    right: 8px;
    top: 7px;
    height: 2px;
    background: currentColor;
    box-shadow: 0 5px 0 currentColor, 0 10px 0 currentColor;
    opacity: 0.7;
}

.card-drag-handle:active {
    cursor: grabbing;
}

@media (pointer: coarse) {
    .card-drag-handle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

.card-description {
    color: #555;
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.card-description[contenteditable="true"]:empty::before {
    content: attr(data-placeholder);
    color: #95a5a6;
}

.card-tags {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}


.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    width: fit-content;
}

.tag-remove-btn {
    border: none;
    background: rgba(0, 0, 0, 0.2);
    color: inherit;
    border-radius: 999px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    font-size: 14px;
    line-height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tag-placeholder {
    font-size: 0.82rem;
    color: #95a5a6;
}

.tag-input-row {
    position: relative;
}

.tag-input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
    font-size: 0.9rem;
}

.tag-suggestions {
    position: absolute;
    top: 40px;
    left: 0;
    right: 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12);
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    z-index: 10;
}

.tag-suggestion {
    border: none;
    border-radius: 999px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}

.tag-suggestion-dismiss {
    border: none;
    background: #f1f5f9;
    color: #475569;
    border-radius: 999px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-weight: 700;
    margin-left: auto;
}

/* Card actions buttons */
.card-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.card-actions button {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    text-transform: none;
    font-family: inherit;
    transition: background-color 0.2s ease, transform 0.06s ease;
}

.card-actions button:active {
    transform: translateY(1px);
}

.edit-btn {
    background-color: #f39c12;
}
.edit-btn:hover { background-color: #e67e22; }

.save-btn { background-color: #27ae60; }
.save-btn:hover { background-color: #229954; }

.delete-btn { background-color: #e74c3c; }
.delete-btn:hover { background-color: #c0392b; }

/* Editable field styles (make edit mode obvious) */
.card-title[contenteditable="true"],
.card-description[contenteditable="true"] {
    border: 1px solid #3498db;
    padding: 8px;
    border-radius: 6px;
    background-color: #f8f9fa;
    cursor: text;
    min-height: 28px;
}

.card-title[contenteditable="true"]:focus,
.card-description[contenteditable="true"]:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(52,152,219,0.12);
}

/* Public Share Panel */
.public-share-panel {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.public-share-toggle {
    border: none;
    background: #eef2f7;
    color: #2c3e50;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.public-share-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.public-share-globe {
    font-size: 1rem;
    line-height: 1;
}

.public-share-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #e2e8f0;
}

.public-share-chevron svg {
    display: block;
    transition: transform 0.15s ease;
}

.public-share-toggle[aria-expanded="false"] .public-share-chevron svg {
    transform: rotate(0deg);
}

.public-share-toggle[aria-expanded="true"] .public-share-chevron svg {
    transform: rotate(180deg);
}

.public-share-body {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 260px;
    max-width: 320px;
    background: white;
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.public-share-panel.is-collapsed .public-share-body,
.public-share-panel.is-private .public-share-body {
    display: none;
}

.public-share-link {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.public-share-link label {
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
}

.public-share-link-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.public-link-input {
    flex: 1;
    min-width: 180px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: monospace;
    background-color: white;
    color: #333;
}

.copy-link-btn {
    padding: 8px 16px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.copy-link-btn:hover {
    background-color: #2980b9;
}

.public-remove-btn {
    padding: 8px 14px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background-color 0.2s;
}

.public-remove-btn:hover {
    background-color: #c0392b;
}

/* Tags management view */
.tags-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.tags-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

#tagSearchInput {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
    min-width: 220px;
}

.create-tag-btn {
    padding: 10px 16px;
    background: #2c7be5;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.create-tag-btn:hover {
    background: #1d64c8;
}

.tags-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tag-row {
    display: grid;
    grid-template-columns: 1fr 110px 2fr 80px 90px 90px;
    gap: 12px;
    align-items: center;
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.tag-preview {
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
}

.tag-count {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    background: #f0f3f6;
    color: #2c3e50;
    min-width: 90px;
}

.tag-name-input {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
    font-size: 0.9rem;
}

.tag-color-input {
    border: none;
    width: 48px;
    height: 36px;
    background: transparent;
}

.tag-save-btn {
    padding: 8px 12px;
    border: none;
    background: #27ae60;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.tag-delete-btn {
    padding: 8px 12px;
    border: none;
    background: #e74c3c;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.tags-empty {
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    color: #7f8c8d;
    margin-bottom: 16px;
}

@media (max-width: 720px) {
    .tag-row {
        grid-template-columns: 1fr;
    }

    .tags-controls {
        flex-direction: column;
        align-items: stretch;
    }

    #tagSearchInput {
        width: 100%;
    }
}
