/* ===== CSS Variables (overridden by display settings) ===== */
:root {
    --unread-weight: bold;
    --read-weight: normal;
    --unread-color: #1a1a1a;
    --read-color: #666666;
    --highlight-color: #fff59d;
    --highlight-text-color: #000000;
    --accent-color: #2563eb;
    --font-size: 14px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: var(--font-size);
    line-height: 1.6;
    color: #1a1a1a;
    background: #f8f9fa;
}

a { color: var(--accent-color); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
.container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 1rem;
}

/* ===== Header ===== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: #1a1a1a;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-nav a, .header-nav button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #374151;
    background: none;
    border: 1px solid #d1d5db;
    cursor: pointer;
    transition: background 0.15s;
}

.header-nav a:hover, .header-nav button:hover {
    background: #f3f4f6;
    text-decoration: none;
}

/* ===== Notification bar ===== */
.notify-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.notify-bar.empty {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.notify-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    transition: all 0.15s;
}
.btn:hover { background: #f3f4f6; }
.btn-primary {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}
.btn-primary:hover { opacity: 0.9; }
.btn-danger {
    color: #dc2626;
    border-color: #fca5a5;
}
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

/* ===== Change feed entries ===== */
.feed-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.feed-entry {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    transition: background 0.15s;
}
.feed-entry:hover { background: #f9fafb; }

.feed-entry.unread {
    font-weight: var(--unread-weight);
    color: var(--unread-color);
}
.feed-entry.read {
    font-weight: var(--read-weight);
    color: var(--read-color);
    opacity: 0.5;
}
.feed-entry.fade-out {
    transition: opacity 0.4s, max-height 0.4s, padding 0.4s, margin 0.4s, border 0.4s;
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
    border-color: transparent;
    overflow: hidden;
}

.feed-favicon {
    width: 1.1em;
    height: 1.1em;
    flex-shrink: 0;
    border-radius: 2px;
}

.feed-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feed-ratio {
    font-size: 0.75em;
    color: #6b7280;
    background: #f3f4f6;
    padding: 0.1em 0.45em;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}
.feed-ratio.feed-ratio-mid {
    color: #92400e;
    background: #fef3c7;
}
.feed-ratio.feed-ratio-high {
    color: #991b1b;
    background: #fee2e2;
}

.feed-date {
    font-size: 0.85em;
    color: #6b7280;
    white-space: nowrap;
}

.feed-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* ===== Sites table ===== */
.sites-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.sites-table th, .sites-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid #f3f4f6;
}

.sites-table th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 0.85rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sites-table td { font-size: 0.9rem; }

.sites-table td.url-cell {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sites-table td.url-cell a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sites-table td.mode-cell {
    text-align: center;
}
.mode-icon { width: 1.1em; height: 1.1em; vertical-align: -0.15em; }

.sites-table tr.selected { background: #eff6ff; }

/* ===== Sortable headers ===== */
.sortable-header {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.sortable-header:hover { color: #374151; background: #f3f4f6; }
.sort-indicator {
    font-size: 0.7em;
    margin-left: 0.2rem;
    color: var(--accent-color);
}

.sites-table td.last-changed-cell,
.sites-table td.last-checked-cell {
    font-size: 0.8rem;
    color: #6b7280;
    white-space: nowrap;
}

.sites-table td.name-cell {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.site-name-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}
.site-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Mode legend ===== */
.mode-legend {
    display: flex;
    gap: 1.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    color: #6b7280;
}
.mode-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.mode-legend i, .mode-legend svg { width: 0.9em; height: 0.9em; }

/* ===== Bulk action bar ===== */
.bulk-bar {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.9rem;
}
.bulk-bar .bulk-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ===== Form ===== */
.form-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 600px;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.3rem;
    color: #374151;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.45rem 0.65rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.form-row {
    display: flex;
    gap: 1rem;
}
.form-row > .form-group { flex: 1; }

.email-time-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.25rem;
}
.email-time-row input[type="time"] { width: auto; }

.form-help {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.2rem;
}

/* ===== Diff condition builder ===== */
.diff-builder {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.75rem;
    background: #f9fafb;
}
.diff-builder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: #374151;
}
.diff-builder-header select {
    width: auto;
    padding: 0.2rem 0.5rem;
    font-size: 0.85rem;
}
.diff-condition {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    flex-wrap: wrap;
}
.diff-condition label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 500;
    font-size: 0.85rem;
    min-width: 6rem;
    cursor: pointer;
}
.diff-condition input[type="number"] {
    width: 5rem;
    padding: 0.25rem 0.4rem;
    font-size: 0.85rem;
}
.diff-condition .unit {
    font-size: 0.8rem;
    color: #6b7280;
}
.diff-condition.disabled {
    opacity: 0.4;
}
.diff-condition.disabled input[type="number"] {
    pointer-events: none;
}

/* ===== Diff view ===== */
.diff-container {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-size: 0.85rem;
    line-height: 1.7;
    overflow-x: auto;
}

.diff-line { padding: 1px 0.5rem; }
.diff-deleted {
    background: #fef2f2;
    color: #991b1b;
}
.diff-deleted del { text-decoration: line-through; }
.diff-changed {
    background: #fffbeb;
}
.diff-highlight {
    background-color: var(--highlight-color);
    color: var(--highlight-text-color);
    padding: 1px 3px;
    border-radius: 2px;
}

/* ===== Settings ===== */
.settings-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 1000px;
}

.settings-section {
    margin-bottom: 1.25rem;
}

.settings-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.color-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-input-wrap input[type="color"] {
    width: 36px;
    height: 30px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 2px;
    cursor: pointer;
}

.color-input-wrap input[type="text"] {
    width: 90px;
    font-family: monospace;
}

/* ===== Lucide icon alignment ===== */
svg[data-lucide], .lucide-icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    stroke-width: 2;
}

/* ===== Toast notification ===== */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.65rem 1.1rem;
    background: #1f2937;
    color: #fff;
    border-radius: 8px;
    font-size: 0.875rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s;
    z-index: 1000;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .header { flex-wrap: wrap; gap: 0.5rem; }
    .feed-date { display: none; }
    .form-row { flex-direction: column; gap: 0; }
}

/* ===== Spinner ===== */
.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid #d1d5db;
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-sm {
    display: inline-block;
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid #d1d5db;
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    flex-shrink: 0;
}

/* ===== Checkbox labels in settings ===== */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
}
.checkbox-label input[type="checkbox"] {
    width: auto;
    accent-color: var(--accent-color);
}

/* ===== Settings Tabs ===== */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 1.25rem;
}
.tab-btn {
    padding: 0.55rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: #374151; }
.tab-btn.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Selector Picker ===== */
.picker-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.picker-toolbar-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}
.picker-toolbar-selector { flex: 1; min-width: 200px; }
.picker-toolbar-selector input {
    width: 100%;
    padding: 0.4rem 0.65rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-size: 0.85rem;
    background: #f9fafb;
}
.picker-toolbar-actions { display: flex; gap: 0.5rem; }

#picker-frame {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    height: calc(100vh - 180px);
}
