:root {
    --bg-color: #f8f9fa;
    --text-color: #212529;
    --secondary-text: #888;
    --accent-color: #e60023; /* Pinterest Red */
    --card-bg: #ffffff;
    --header-bg: #ffffff;
    --border-color: #eee;
    --drop-zone-bg: #fafafa;
    --drop-zone-border: #ccc;
    --overlay-bg: rgba(255, 255, 255, 0.4);
    --text-shadow: 0 1px 2px rgba(255,255,255,0.5);
    --border-radius: 16px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --header-height: 70px;
}

.dark-mode {
    --bg-color: #121212;
    --text-color: #e1e1e1;
    --secondary-text: #a0a0a0;
    --accent-color: #ff2d55;
    --card-bg: #1e1e1e;
    --header-bg: #181818;
    --border-color: #333;
    --drop-zone-bg: #252525;
    --drop-zone-border: #444;
    --overlay-bg: rgba(0, 0, 0, 0.4);
    --text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Outfit', system-ui, sans-serif;
    font-feature-settings: "kern" 1, "liga" 1;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding-top: var(--header-height);
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Nunito', system-ui, sans-serif;
    line-height: 1.2;
}

/* Drag Overlay (Global) */
body.drag-over {
    background-color: #e2e8f0;
}
body.dark-mode.drag-over {
    background-color: #1e2a38;
}

header {
    position: fixed;
    top: 0;
    width: 100%;
    height: var(--header-height);
    background: var(--header-bg);
    z-index: 100;
    box-shadow: 0 1px 0 rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    padding: 0 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

#logo-container {
    display: flex;
    flex-direction: column;
}

#app-logo {
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent-color);
    margin: 0;
    cursor: pointer;
    line-height: 1;
    letter-spacing: -0.02em;
}

#app-subtitle {
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--secondary-text);
    margin: 0;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

#nav-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

main#app {
    flex: 1; /* Pushes footer down */
    width: 100%;
}

.view {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.board-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--drop-zone-border);
    border-radius: 24px;
    padding: 0.5rem 1.5rem;
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.9rem;
    background: var(--drop-zone-bg);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    cursor: default;
    height: 40px;
}

.drop-zone.active {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: #fff0f0;
    transform: scale(1.05);
}

.hidden {
    display: none !important;
}

/* Grids */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    align-items: start;
    position: relative; /* For insertion marker positioning context if needed, though we usually attach to card */
}

.masonry {
    /* Use a standard grid but ensure items don't stretch */
    align-items: start;
}

/* Empty State */
.empty-msg {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-color);
    background: rgba(0,0,0,0.02);
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: grab;
    position: relative;
    border: 1px solid var(--border-color);
    transform: rotate(var(--rotation, 0deg));
    /* Native DnD */
    user-select: none;
    -webkit-user-drag: element;
}

.card:hover {
    transform: translateY(-4px) rotate(var(--rotation, 0deg));
    box-shadow: 0 8px 16px rgba(0,0,0,0.12);
    z-index: 5;
}

.card.dragging {
    opacity: 0.4;
    cursor: grabbing;
}

/* Insertion Marker (Vertical Bar) */
.insertion-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6px;
    background-color: #007bff;
    border-radius: 3px;
    z-index: 99999;
    pointer-events: none;
    display: none;
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.8);
    transition: left 0.1s ease-out, top 0.1s ease-out;
}

/* Drag Target Highlight (Breadcrumbs/Nav) */
.drag-over-target {
    box-shadow: 0 0 0 4px var(--accent-color) !important;
    transform: scale(1.02) !important;
    z-index: 20 !important;
}
.crumb.drag-over-target {
    color: var(--accent-color);
    text-decoration: underline;
    background: #e6002322;
    border-radius: 4px;
}

/* Explicit Drop Overlay inside cards (for nesting) */
.card-drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50; 
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    background: var(--overlay-bg);
    border: 6px solid var(--accent-color);
    border-radius: var(--border-radius);
}

/* Post-it Note Style */
.card-note {
    background: #fff740; /* Post-it Yellow (Default) */
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    border-radius: 2px; /* More square */
    box-shadow: 3px 3px 10px rgba(0,0,0,0.15);
}

.card-note .card-content {
    width: 100%;
    text-align: center;
}

.card-note .card-title {
    font-family: 'Caveat', 'Segoe Print', cursive;
    font-size: 1.35rem;
    font-weight: 700;
    color: #333;
    line-height: 1.3;
}

.card-content {
    padding: 1rem;
}

.card-image {
    width: 100%;
    display: block;
    object-fit: cover;
    max-height: 400px;
    background: #eee;
}

/* Rich Link Card Styles */
.link-title-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
    border-radius: 8px 8px 0 0;
}

.link-card-title {
    flex: 1;
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    word-break: break-word;
    color: #333;
}

.link-favicon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex-shrink: 0;
}

.link-domain {
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--secondary-text);
    letter-spacing: 0.01em;
}

.card-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    word-break: break-word;
}

.card-link {
    font-size: 0.85rem;
    color: var(--secondary-text);
    text-decoration: none;
    display: block;
    margin-top: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Card Actions */
.card-actions {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.card:hover .card-actions {
    opacity: 1;
}

.card-btn {
    background: var(--header-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s, color 0.2s;
    color: var(--secondary-text); /* Icon color */
}

.card-btn svg, .btn-icon svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.card-btn:hover {
    background: white;
    transform: scale(1.05);
    color: var(--accent-color);
}

/* Button with icon adjustment */
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 24px;
    border: none;
    font-family: 'Outfit', system-ui, sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: filter 0.2s;
}

.card-comment {
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--secondary-text);
    font-style: italic;
    word-break: break-word;
}

/* Topic Cards specific */
.topic-card {
    height: 200px; /* Match typical card height better for masonry mixing */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: white;
    background: var(--accent-color);
    position: relative; /* Ensure buttons are positioned relative to card */
    padding: 1rem;
}

/* Buttons */
button {
    padding: 0.6rem 1.2rem;
    border-radius: 24px;
    border: none;
    font-family: 'Outfit', system-ui, sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: filter 0.2s, background-color 0.2s, color 0.2s;
    background-color: var(--drop-zone-bg);
    color: var(--text-color);
}

button:hover {
    filter: brightness(0.9);
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-secondary {
    background-color: var(--drop-zone-bg);
    color: var(--text-color);
}

/* Dialog */
dialog {
    border: none;
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 400px;
    background: var(--card-bg);
    color: var(--text-color);
}

dialog::backdrop {
    background: rgba(0,0,0,0.5);
}

dialog input {
    width: 100%;
    padding: 0.8rem;
    margin: 1rem 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 0.95rem;
}

.dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.hint {
    font-size: 0.9rem;
    color: #888;
}

/* Sync Dialog Styles */
.sync-container {
    text-align: center;
}

.sync-tabs {
    display: flex;
    background: #efefef;
    border-radius: 24px;
    padding: 4px;
    margin-bottom: 1.5rem;
}

.sync-tabs button {
    flex: 1;
    background: transparent;
    color: #666;
    padding: 0.5rem;
    border-radius: 20px;
}

.sync-tabs button.active {
    background: white;
    color: black;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.sync-panel {
    min-height: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#qrcode-container {
    margin: 1rem 0;
    background: white;
    padding: 1rem;
    border-radius: 8px;
}

.sync-id-display {
    font-family: monospace;
    font-size: 1.2rem;
    background: #eee;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    margin: 0.5rem 0;
}

.status-box {
    margin-top: 1rem;
    padding: 0.8rem;
    background: #f0f8ff;
    border: 1px solid #cce5ff;
    border-radius: 8px;
    color: #004085;
    font-size: 0.9rem;
    width: 100%;
}

/* Footer */
#app-footer {
    text-align: center;
    padding: 2rem;
    margin-top: auto;
    color: var(--secondary-text);
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    border-top: 1px solid var(--border-color);
}

.version-info {
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    opacity: 0.6;
    margin-top: 0.5rem;
}

/* Dragging state for SortableJS */
.sortable-ghost {
    opacity: 0.4;
    border: 2px dashed var(--accent-color);
}

/* Color Picker Styles */
.color-option {
    cursor: pointer;
    position: relative;
    display: inline-block;
    width: 32px;
    height: 32px;
}

.color-option input[type="radio"] {
    opacity: 0;
    position: absolute;
    width: 0;
    height: 0;
}

.color-swatch {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.color-option input[type="radio"]:checked + .color-swatch {
    border-color: #333;
    transform: scale(1.1);
    box-shadow: 0 0 0 2px #fff inset; /* Create a gap effect */
}

.color-option:hover .color-swatch {
    transform: scale(1.1);
}

/* Spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loading-spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
    color: #999;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Outfit', system-ui, sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
    color: var(--text-color);
    background: var(--drop-zone-bg);
    padding: 0.5rem 1rem;
    border-radius: 20px;
}

.crumb {
    cursor: pointer;
    transition: color 0.2s;
}

.crumb:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.crumb.active {
    color: var(--text-color);
    font-weight: 700;
    cursor: default;
    text-decoration: none;
}

.crumb-sep {
    color: #999;
    font-size: 0.9em;
}

/* Grid Loading State */
.grid.loading {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.3s;
}

#view-description {
    color: var(--secondary-text);
}

#btn-theme-toggle {
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    justify-content: center;
}

.actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Recycle Card Special Styling */
.recycle-card {
    background-color: transparent !important;
    box-shadow: none !important;
    border: 2px solid #ccc !important;
    width: 200px !important;
}

.dark-mode .recycle-card {
    border-color: var(--text-color) !important;
}

.dark-mode .recycle-card img {
    filter: invert(1) brightness(2);
}
