:root {
    /* Tactile Zine - Light Mode */
    --bg-color: #f7f4ed;
    /* Warmer, grittier off-white */
    --card-bg: #fdfbf7;
    --card-border: #333333;
    --text-primary: #1a1a1a;
    --text-secondary: #5a5a5a;
    --accent-color: #6a7c64;
    /* Olive */
    --tape-color-1: rgba(230, 220, 150, 0.7);
    /* Masking tape yellow */
    --tape-color-2: rgba(130, 160, 210, 0.7);
    /* Painters tape blue */
    --danger-color: #a44a4a;
    --input-bg: transparent;

    --font-heading: 'Special Elite', 'Courier Prime', monospace;
    --font-body: 'Patrick Hand', 'Courier Prime', cursive;
    --font-mono: 'Courier Prime', monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not(.light-theme) {
        --bg-color: #242424;
        --card-bg: #2d2d2d;
        --card-border: #a0a0a0;
        --text-primary: #f0f0f0;
        --text-secondary: #b0b0b0;
        --accent-color: #8da686;
        --tape-color-1: rgba(190, 180, 110, 0.5);
        --tape-color-2: rgba(90, 120, 180, 0.5);
        --danger-color: #d67a7a;
        --input-bg: transparent;
    }
}

.dark-theme {
    --bg-color: #242424;
    --card-bg: #2d2d2d;
    --card-border: #a0a0a0;
    --text-primary: #f0f0f0;
    --text-secondary: #b0b0b0;
    --accent-color: #8da686;
    --tape-color-1: rgba(190, 180, 110, 0.5);
    --tape-color-2: rgba(90, 120, 180, 0.5);
    --danger-color: #d67a7a;
    --input-bg: transparent;
}

.light-theme {
    --bg-color: #f7f4ed;
    --card-bg: #fdfbf7;
    --card-border: #333333;
    --text-primary: #1a1a1a;
    --text-secondary: #5a5a5a;
    --accent-color: #6a7c64;
    --tape-color-1: rgba(230, 220, 150, 0.7);
    --tape-color-2: rgba(130, 160, 210, 0.7);
    --danger-color: #a44a4a;
    --input-bg: transparent;
}

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

/* Disable transitions temporarily during theme toggle */
.no-transition,
.no-transition * {
    transition: none !important;
}

html, body {
    background-color: var(--bg-color);
}

body {
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    font-family: var(--font-body);
    font-size: 18px;
    /* Slightly larger for handwriting font */
    line-height: 1.6;
    letter-spacing: 0.01em;
}

/* Screen Reader Only Utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Utilities */
.w-100 {
    width: 100%;
}

.danger-text {
    color: var(--danger-color) !important;
}

.muted-text {
    color: var(--text-secondary) !important;
}

.button-group-right {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}

/* Background Noise Overlays */
body::before, body::after {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: -1;
    transition: opacity 0.3s ease;
}

body::before {
    /* Light Mode Noise */
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.08'/%3E%3C/svg%3E");
    opacity: 1;
}

body::after {
    /* Dark Mode Noise */
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.01'/%3E%3C/svg%3E");
    opacity: 0;
}

html.dark-theme body::before {
    opacity: 0;
}

html.dark-theme body::after {
    opacity: 1;
}

@media (prefers-color-scheme: dark) {
    html:not(.light-theme) body::before {
        opacity: 0;
    }
    html:not(.light-theme) body::after {
        opacity: 1;
    }
}


.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--card-bg);
    border: 2px solid var(--text-primary);
    border-radius: 50% 40% 60% 40% / 50% 60% 40% 50%;
    /* Hand-drawn circle */
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.theme-toggle:hover {
    transform: rotate(15deg) scale(1.1);
}

/* Washi Tape Decor */
.tape {
    position: absolute;
    height: 25px;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    opacity: 0.9;
}

.tape-1 {
    width: 120px;
    background-color: var(--tape-color-1);
    top: -10px;
    left: -20px;
    transform: rotate(-4deg);
}

.tape-2 {
    width: 90px;
    background-color: var(--tape-color-2);
    top: -12px;
    right: 20px;
    transform: rotate(6deg);
}

.tape-3 {
    width: 100px;
    background-color: var(--tape-color-1);
    top: -10px;
    left: 40%;
    transform: rotate(-2deg);
}

/* Containers */
.container {
    width: 100%;
    max-width: 1250px;
    display: none;
    margin: 0 auto;
}

.container.active {
    display: block;
}

#login-container {
    max-width: 450px;
    margin-top: 10vh;
}

/* Zine Cards */
.zine-card {
    background: var(--card-bg);
    /* Hand-drawn sketchy border */
    border: 2px solid var(--card-border);
    border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.06);
    position: relative;
    transition: transform 0.2s ease;
}

/* Header */
.zine-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    padding: 0 20px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hand-icon {
    width: 36px;
    height: 36px;
    stroke: var(--text-primary);
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--text-primary);
    letter-spacing: 2px;
}

.nav-links {
    display: flex;
    gap: 24px;
    align-items: center;
}

.nav-links a,
.nav-links button {
    font-family: var(--font-mono);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1.1rem;
    letter-spacing: 0.02em;
    font-weight: bold;
    cursor: pointer;
    border: none;
    background: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-links .active-link {
    border-bottom: 2px solid var(--text-primary);
    border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
}

/* Typography */
h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.3;
}

h2 {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    letter-spacing: 1px;
    line-height: 1.3;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 24px;
    text-align: center;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
}

@media (min-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1.4fr 1fr;
    }
}

.right-column {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* Forms & Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

.input-group label {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 6px;
}

input {
    background: var(--input-bg);
    border: none;
    border-bottom: 2px solid var(--card-border);
    border-radius: 0;
    color: var(--text-primary);
    padding: 10px 4px;
    font-size: 1.2rem;
    outline: none;
    font-family: var(--font-body);
}

input:focus {
    border-color: var(--accent-color);
}

/* Row Input for Add Account */
.row-input {
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border: 2px solid var(--card-border);
    border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
    padding: 8px 16px;
    background-color: rgba(255, 255, 255, 0.3);
}

.row-input input {
    border: none;
    flex-grow: 1;
    font-size: 1.2rem;
    padding: 4px;
}

.row-input {
    display: flex;
    align-items: center;
    gap: 8px;
}

.row-input input:focus {
    border: none;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    font-size: 1.1rem;
    cursor: pointer;
    font-family: var(--font-mono);
    font-weight: bold;
    letter-spacing: 0.03em;
    transition: all 0.2s;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;

    /* Color setup for inversion */
    --btn-color: var(--text-primary);
    border: 2px solid var(--btn-color);
    color: var(--btn-color);

    /* Sketched outline */
    border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
    background: transparent;
}

.btn:focus-visible, a:focus-visible, .text-btn:focus-visible {
    outline: 2px dashed var(--accent-color);
    outline-offset: 4px;
}

.btn:hover {
    background-color: var(--btn-color);
    color: var(--bg-color);
}

.primary-btn {
    background: var(--text-primary);
    color: var(--bg-color);
    width: 100%;
    margin-top: 10px;
}

.danger-btn {
    --btn-color: var(--danger-color);
}

.outline-btn {
    padding: 4px 12px;
    font-size: 0.95rem;
    width: 130px;
}

.text-btn {
    border: none;
    background: none;
    box-shadow: none;
    padding: 0;
}

.text-btn:hover {
    transform: none;
    text-decoration: underline;
    cursor: pointer;
}

.account-actions {
    display: flex;
    gap: 8px;
}

/* URL Box */
.url-box-container {
    background: var(--input-bg);
    border: 2px solid var(--card-border);
    border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
    padding: 16px;
    margin-bottom: 12px;
}

.url-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.url-box input {
    flex-grow: 1;
    border: none;
    font-family: var(--font-mono);
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.4);
    padding: 10px;
    border-radius: 4px;
}



.instructions p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Accounts List */
.add-account-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px dashed var(--card-border);
}

.accounts-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.account-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    gap: 12px;
}

.account-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.account-name {
    font-family: var(--font-body);
    font-size: 1.2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Avatar placeholder */
.account-name:not(.has-pic)::before {
    content: '';
    display: inline-block;
    width: 56px;
    height: 56px;
    border-radius: 50% 40% 60% 40% / 50% 60% 40% 50%;
    background-color: var(--text-secondary);
    opacity: 0.2;
    border: 2px solid var(--text-primary);
}

.profile-pic {
    width: 56px;
    height: 56px;
    border-radius: 50% 40% 60% 40% / 50% 60% 40% 50%;
    object-fit: cover;
    border: 2px solid var(--text-primary);
}



/* Stats */
.status-grid {
    display: flex;
    gap: 40px;
    margin-bottom: 30px;
}

.hint {
    font-family: var(--font-heading);
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.status-value {
    font-family: var(--font-body);
    font-size: 1.2rem;
}

/* History Dots */
.history-track {
    display: flex;
    gap: 4px;
}

.history-dot {
    display: inline-block;
    font-size: 1.2rem;
    cursor: pointer;
    position: relative;
}

.status-success {
    color: var(--accent-color);
}

.status-error {
    color: var(--danger-color);
}

.tooltip {
    visibility: hidden;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: var(--bg-color);
    padding: 6px 10px;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 100;
}

.history-dot:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 10px;
}

@keyframes popIn {
    0% { opacity: 0; transform: translateY(-10px) scale(0.98); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.account-item.new-item {
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.success-msg {
    color: #4ade80; /* vibrant green */
    font-weight: bold;
    font-family: var(--font-body);
    font-size: 0.95rem;
    margin-top: 10px;
    opacity: 1;
    transition: opacity 0.3s ease;
    text-align: center;
}

.success-msg.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Feeds Sidebar & List styles */
.feeds-list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 4px;
}

.feed-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.feed-item:not(.active) {
    display: flex;
    flex-direction: row;
    align-items: center;
    cursor: pointer;
    padding: 10px 12px;
    border: none;
    border-bottom: 1px dashed var(--card-border);
    border-radius: 0;
    background: transparent;
    transition: all 0.15s ease;
}

.feed-item:not(.active)::before {
    content: '▶';
    font-size: 0.95rem;
    margin-right: 10px;
    color: var(--text-secondary);
    display: inline-block;
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.feed-item:not(.active) .feed-name-txt {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-weight: bold;
    font-size: 1.15rem;
    transition: color 0.15s ease;
}

.feed-item:not(.active):hover {
    background-color: rgba(0, 0, 0, 0.015);
}

.dark-theme .feed-item:not(.active):hover,
:root:not(.light-theme) .feed-item:not(.active):hover {
    background-color: rgba(255, 255, 255, 0.015);
}

.feed-item:not(.active):hover::before {
    color: var(--accent-color);
}

.feed-item:not(.active):hover .feed-name-txt {
    color: var(--accent-color);
    text-decoration: underline;
}

.feed-item.active {
    background-color: var(--card-bg);
    border: 2px solid var(--accent-color);
    border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
    padding: 12px 16px;
    box-shadow: 3px 3px 0px rgba(0, 0, 0, 0.1);
    cursor: default;
}

.feed-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 28px;
}

.feed-rename-input {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: bold;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--accent-color);
    outline: none;
    padding: 0 4px;
    margin: 0;
    height: 24px;
    box-sizing: border-box;
    width: 70%;
}

.feed-name {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: bold;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.feed-name::before {
    content: '▼';
    font-size: 1.1rem;
    margin-right: 10px;
    color: var(--text-secondary);
    display: inline-block;
    flex-shrink: 0;
}

.feed-item-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    transform: scale(1.05);
}

.dark-theme .icon-btn:hover,
:root:not(.light-theme) .icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.icon-btn.danger-text {
    color: var(--danger-color);
}
.icon-btn.danger-text:hover {
    background-color: rgba(164, 74, 74, 0.15);
    border-color: var(--danger-color);
}

.feed-item-body {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--card-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feed-url-label {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.feed-url-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.feed-url-input {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 6px 10px;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.copy-url-btn {
    padding: 6px 10px;
    font-size: 0.85rem;
    height: 29px;
    width: auto;
    white-space: nowrap;
}

.regen-token-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    margin-top: 4px;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: auto;
}

.hidden {
    display: none !important;
}

#feed-details-view {
    transition: opacity 0.15s ease-in-out;
}

/* Delete Animations */
.feed-item.deleting {
    animation: slideOutLeft 0.3s ease-out forwards;
}

#feed-details-view.deleting {
    animation: fadeScaleOut 0.3s ease-out forwards;
}

@keyframes slideOutLeft {
    0% {
        opacity: 1;
        transform: translateX(0);
        height: 38px;
        margin-bottom: 12px;
        padding-top: 8px;
        padding-bottom: 8px;
    }
    100% {
        opacity: 0;
        transform: translateX(-30px);
        height: 0;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
        border: none;
    }
}

@keyframes fadeScaleOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* Custom Confirmation Modal */
.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.confirm-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
}

.confirm-modal-content {
    position: relative;
    width: 90%;
    max-width: 450px;
    z-index: 10;
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes modalPop {
    0% {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}