/* === CSS Variables & Themes === */
:root {
    /* Main Theme A (Warm White Minimal / Basic Sky turned Sunset) */
    --bg-color-default: #FFF9F0;
    --text-color-default: #5D4037;
    --border-color-default: #FFCC80;
    --cell-bg-default: #FFFFFF;
    --cell-completed-default: #FFE0B2;
    --cta-color-default: #FFB74D;
    --text-muted-default: #8D6E63;

    /* Theme B (Cozy Autumn) */
    --bg-color-green: #FFFAF0; /* Actually cozy autumn base */
    --text-color-green: #4E342E;
    --border-color-green: #FFBCA6;
    --cell-bg-green: #FFF3E0;
    --cell-completed-green: #FFAB91;
    --cta-color-green: #FF8A65;
    --text-muted-green: #A1887F;

    /* Theme C (Warm 3x3) */
    --bg-color-blue: #FCF8F2;
    --text-color-blue: #3E2723;
    --border-color-blue: #E6C280;
    --cell-bg-blue: #FFECB3;
    --cell-completed-blue: #FFD54F;
    --cta-color-blue: #FFCA28;
    --text-muted-blue: #795548;

    /* Theme D (Premium Cozy) */
    --bg-color-pink: #FFF3E0;
    --text-color-pink: #BF360C;
    --border-color-pink: #FFCCBC;
    --cell-bg-pink: #FBE9E7;
    --cell-completed-pink: #FFAB91;
    --cta-color-pink: #FF7043;
    --text-muted-pink: #D84315;

    /* Theme E (Premium Garden) */
    --bg-color-yellow: #F1F8E9;
    --text-color-yellow: #33691E;
    --border-color-yellow: #C5E1A5;
    --cell-bg-yellow: #DCEDC8;
    --cell-completed-yellow: #AED581;
    --cta-color-yellow: #8BC34A;
    --text-muted-yellow: #558B2F;

    /* Theme F (Premium Nature / Doodle) */
    --bg-color-purple: #F9FBE7;
    --text-color-purple: #827717;
    --border-color-purple: #E6EE9C;
    --cell-bg-purple: #F0F4C3;
    --cell-completed-purple: #DCE775;
    --cta-color-purple: #CDDC39;
    --text-muted-purple: #9E9D24;

    /* Theme G (Stitch Minimal) */
    --bg-color-stitch: #f7f8fa;
    --text-color-stitch: #1f2937;
    --border-color-stitch: #cbd5e1;
    --cell-bg-stitch: #ffffff;
    --cell-completed-stitch: #dbeafe;
    --cta-color-stitch: #3b82f6;
    --text-muted-stitch: #64748b;

    /* Theme H (Stitch Autumn) */
    --bg-color-stitch-autumn: #fffbf2;
    --text-color-stitch-autumn: #524a40;
    --border-color-stitch-autumn: #d4a356;
    --cell-bg-stitch-autumn: #ffffff;
    --cell-completed-stitch-autumn: #ffcf96;
    --cta-color-stitch-autumn: #d97757;
    --text-muted-stitch-autumn: #848a60;

    /* Theme I (Stitch Doodle) */
    --bg-color-stitch-doodle: #f7f6f1;
    --text-color-stitch-doodle: #2d5c24;
    --border-color-stitch-doodle: #79a96b;
    --cell-bg-stitch-doodle: #ffffff;
    --cell-completed-stitch-doodle: #d9f2d3;
    --cta-color-stitch-doodle: #5a8f4a;
    --text-muted-stitch-doodle: #4a6644;
}

body.theme-default {
    --bg-color: var(--bg-color-default);
    --text-color: var(--text-color-default);
    --border-color: var(--border-color-default);
    --cell-bg: var(--cell-bg-default);
    --cell-completed: var(--cell-completed-default);
    --cell-completed-text: var(--text-color-default);
    --cta-color: var(--cta-color-default);
    --text-muted: var(--text-muted-default);
}


body.theme-green {
    --bg-color: var(--bg-color-green);
    --text-color: var(--text-color-green);
    --border-color: var(--border-color-green);
    --cell-bg: var(--cell-bg-green);
    --cell-completed: var(--cell-completed-green);
    --cell-completed-text: #FFFFFF;
    --cta-color: var(--cta-color-green);
    --text-muted: var(--text-muted-green);
}

body.theme-blue {
    --bg-color: var(--bg-color-blue);
    --text-color: var(--text-color-blue);
    --border-color: var(--border-color-blue);
    --cell-bg: var(--cell-bg-blue);
    --cell-completed: var(--cell-completed-blue);
    --cell-completed-text: #FFFFFF;
    --cta-color: var(--cta-color-blue);
    --text-muted: var(--text-muted-blue);
    --text-muted: var(--text-muted-blue);
}

body.theme-pink {
    --bg-color: var(--bg-color-pink);
    --text-color: var(--text-color-pink);
    --border-color: var(--border-color-pink);
    --cell-bg: var(--cell-bg-pink);
    --cell-completed: var(--cell-completed-pink);
    --cell-completed-text: #FFFFFF;
    --cta-color: var(--cta-color-pink);
    --text-muted: var(--text-muted-pink);
}

body.theme-yellow {
    --bg-color: var(--bg-color-yellow);
    --text-color: var(--text-color-yellow);
    --border-color: var(--border-color-yellow);
    --cell-bg: var(--cell-bg-yellow);
    --cell-completed: var(--cell-completed-yellow);
    --cell-completed-text: var(--text-color-yellow);
    --cta-color: var(--cta-color-yellow);
    --text-muted: var(--text-muted-yellow);
}

body.theme-purple {
    --bg-color: var(--bg-color-purple);
    --text-color: var(--text-color-purple);
    --border-color: var(--border-color-purple);
    --cell-bg: var(--cell-bg-purple);
    --cell-completed: var(--cell-completed-purple);
    --cell-completed-text: #FFFFFF;
    --cta-color: var(--cta-color-purple);
    --text-muted: var(--text-muted-purple);
}

body.theme-stitch {
    --bg-color: var(--bg-color-stitch);
    --text-color: var(--text-color-stitch);
    --border-color: var(--border-color-stitch);
    --cell-bg: var(--cell-bg-stitch);
    --cell-completed: var(--cell-completed-stitch);
    --cell-completed-text: var(--text-color-stitch);
    --cta-color: var(--cta-color-stitch);
    --text-muted: var(--text-muted-stitch);
}

body.theme-stitch-autumn {
    --bg-color: var(--bg-color-stitch-autumn);
    --text-color: var(--text-color-stitch-autumn);
    --border-color: var(--border-color-stitch-autumn);
    --cell-bg: var(--cell-bg-stitch-autumn);
    --cell-completed: var(--cell-completed-stitch-autumn);
    --cell-completed-text: var(--text-color-stitch-autumn);
    --cta-color: var(--cta-color-stitch-autumn);
    --text-muted: var(--text-muted-stitch-autumn);
}

body.theme-stitch-doodle {
    --bg-color: var(--bg-color-stitch-doodle);
    --text-color: var(--text-color-stitch-doodle);
    --border-color: var(--border-color-stitch-doodle);
    --cell-bg: var(--cell-bg-stitch-doodle);
    --cell-completed: var(--cell-completed-stitch-doodle);
    --cell-completed-text: var(--text-color-stitch-doodle);
    --cta-color: var(--cta-color-stitch-doodle);
    --text-muted: var(--text-muted-stitch-doodle);
}

body.theme-stitch {
    font-family: 'Patrick Hand', 'Architects Daughter', 'Inter', system-ui, -apple-system, sans-serif;
    background-image:
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.12) 0%, transparent 40%),
        radial-gradient(circle at bottom left, rgba(147, 197, 253, 0.12) 0%, transparent 40%);
}

body.theme-stitch-autumn {
    font-family: 'Patrick Hand', 'Architects Daughter', 'Inter', system-ui, -apple-system, sans-serif;
    background-image:
        radial-gradient(circle at top right, rgba(217, 119, 87, 0.15) 0%, transparent 38%),
        radial-gradient(circle at bottom left, rgba(255, 179, 71, 0.14) 0%, transparent 42%);
}

body.theme-stitch-doodle {
    font-family: 'Patrick Hand', 'Architects Daughter', 'Inter', system-ui, -apple-system, sans-serif;
    background-image:
        radial-gradient(circle at top right, rgba(121, 169, 107, 0.14) 0%, transparent 40%),
        radial-gradient(circle at bottom left, rgba(90, 143, 74, 0.12) 0%, transparent 40%);
}

body.theme-stitch .floating-blob {
    opacity: 0.28;
}

body.theme-stitch-autumn .floating-blob,
body.theme-stitch-doodle .floating-blob {
    opacity: 0.25;
}

body.theme-stitch .grid-cell {
    border: 2px solid #1f2937;
    border-radius: 255px 18px 225px 18px / 18px 225px 18px 255px;
    box-shadow: 0 3px 0 #1f2937;
    font-weight: 700;
}

body.theme-stitch-autumn .grid-cell,
body.theme-stitch-doodle .grid-cell {
    border: 2px solid var(--text-color);
    border-radius: 255px 20px 225px 20px / 20px 225px 20px 255px;
    box-shadow: 0 3px 0 var(--text-color);
    font-weight: 700;
}

body.theme-stitch .grid-cell.completed {
    border-color: #1e3a8a;
    color: #1e3a8a;
    background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 20c5 0 5-5 10-5s5 5 10 5 5-5 10-5 5 5 10 5' fill='none' stroke='%233b82f6' stroke-width='0.8' opacity='0.18'/%3E%3C/svg%3E");
}

body.theme-stitch-autumn .grid-cell.completed {
    border-color: #524a40;
    color: #524a40;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='20' viewBox='0 0 100 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 10 Q 25 0 50 10 T 100 10' fill='none' stroke='%23524A40' stroke-opacity='0.12' stroke-width='1.2'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

body.theme-stitch-doodle .grid-cell.completed {
    border-color: #2d5c24;
    color: #2d5c24;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10,20 Q30,10 50,20 T90,20 M15,40 Q35,30 55,40 T85,40 M10,60 Q40,50 60,60 T90,60 M20,80 Q40,70 70,80' stroke='%232d5c24' stroke-width='2' fill='none' opacity='0.16'/%3E%3C/svg%3E");
    background-size: 110px 110px;
}

body.theme-stitch .primary-btn,
body.theme-stitch .secondary-btn,
body.theme-stitch .option-btn {
    border-radius: 12px 6px 12px 6px / 6px 12px 6px 12px;
}

body.theme-stitch-autumn .primary-btn,
body.theme-stitch-autumn .secondary-btn,
body.theme-stitch-autumn .option-btn,
body.theme-stitch-doodle .primary-btn,
body.theme-stitch-doodle .secondary-btn,
body.theme-stitch-doodle .option-btn {
    border-radius: 12px 6px 12px 6px / 6px 12px 6px 12px;
}

/* === Global Reset === */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Quicksand', 'Nunito', 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
    background-image: radial-gradient(circle at top right, rgba(255, 204, 128, 0.15) 0%, transparent 40%),
                      radial-gradient(circle at bottom left, rgba(255, 171, 145, 0.15) 0%, transparent 40%);
}

/* === Decorative Background Elements === */
.floating-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    z-index: -1;
    opacity: 0.4;
    animation: float 10s ease-in-out infinite alternate;
}

.blob-1 {
    width: 250px;
    height: 250px;
    background-color: var(--cta-color);
    top: -50px;
    left: -50px;
    animation-duration: 15s;
}

.blob-2 {
    width: 200px;
    height: 200px;
    background-color: var(--cell-completed);
    bottom: 10%;
    right: -20px;
    animation-duration: 20s;
    animation-delay: -5s;
}

.blob-3 {
    width: 150px;
    height: 150px;
    background-color: var(--border-color);
    top: 40%;
    left: 20%;
    animation-duration: 12s;
    opacity: 0.2;
}

@keyframes float {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(30px) scale(1.1); }
}

/* --- Page shell + ad placeholders (Free; no third-party ad scripts) --- */
.page-shell {
    box-sizing: border-box;
    width: 100%;
    max-width: 1380px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 16px;
    padding: 12px 16px;
}

.page-shell__center {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 760px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.ad-rail {
    display: none;
    flex-direction: column;
    justify-content: stretch;
    box-sizing: border-box;
    font-family: inherit;
    pointer-events: auto;
    position: relative;
}

.ad-rail-inner {
    border: 1px dashed var(--border-color);
    border-radius: 14px;
    padding: 20px 14px;
    background: var(--cell-bg);
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
    box-sizing: border-box;
    width: 100%;
}

.ad-rail-inner--compact {
    padding: 12px 14px;
}

.ad-rail-inner--mobile {
    min-height: 100px;
    max-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 14px 16px;
    font-size: 12px;
}

.ad-rail-line {
    margin: 0 0 8px 0;
}

.ad-rail-line:last-child {
    margin-bottom: 0;
}

.ad-rail-line--muted {
    font-size: 11px;
    opacity: 0.88;
}

.ad-rail-link {
    color: var(--cta-color);
    text-decoration: none;
    font-weight: 600;
}

.ad-rail-link:hover {
    text-decoration: underline;
}

/* Desktop: skyscraper-style side columns (Free only), wide viewports only */
@media (min-width: 1220px) {
    .page-shell {
        flex-direction: row;
        align-items: stretch;
    }

    .desktop-ad-slot.ad-rail--left,
    .desktop-ad-slot.ad-rail--right {
        width: clamp(180px, 17vw, 220px);
        flex: 0 0 clamp(180px, 17vw, 220px);
        align-self: stretch;
        min-height: 0;
    }

    body:not(.is-pro-user) .desktop-ad-slot.ad-rail--left,
    body:not(.is-pro-user) .desktop-ad-slot.ad-rail--right {
        display: flex;
    }

    body:not(.is-pro-user) .desktop-ad-slot.ad-rail--left .ad-rail-inner,
    body:not(.is-pro-user) .desktop-ad-slot.ad-rail--right .ad-rail-inner {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        min-height: clamp(560px, 70vh, 720px);
        max-height: min(720px, calc(100dvh - 40px));
        padding: 28px 18px;
        font-size: 13px;
    }

    .ad-rail--mobile-below {
        display: none !important;
    }
}

/* Narrow: stack + horizontal strip below app (Free only) */
@media (max-width: 1219px) {
    .page-shell {
        flex-direction: column;
        align-items: stretch;
        padding: 10px 12px 14px;
        gap: 12px;
    }

    .page-shell__center {
        max-width: 100%;
        flex: 1 1 auto;
        min-height: 0;
    }

    .ad-rail--left,
    .ad-rail--right {
        display: none !important;
    }

    body:not(.is-pro-user) .mobile-ad-slot.ad-rail--mobile-below {
        display: flex;
        flex: 0 0 auto;
        width: 100%;
        max-width: 760px;
        margin: 0 auto;
        justify-content: center;
    }

    #app {
        height: calc(100dvh - 132px);
        max-height: calc(100dvh - 132px);
        min-height: 0;
    }

    body.is-pro-user #app {
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
    }
}

body.is-pro-user .ad-rail {
    display: none !important;
}

/* Limit width for desktop, full width for mobile */
#app {
    width: 100%;
    max-width: 760px;
    position: relative;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === Views === */
.view {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
    padding: 20px;
    overflow-y: auto;
}

.view.active {
    display: flex;
}

/* === Header === */
header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    padding-top: 10px;
    gap: 12px;
}

header h1 {
    font-size: 24px;
    font-weight: 600;
}

.header-title-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.header-illustration {
    display: inline-flex;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 4px;
}

.header-illustration .animal {
    font-size: 34px;
    line-height: 1;
}

.header-illustration .food {
    font-size: 20px;
    line-height: 1;
    transform: translateY(4px);
}

.header-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
}

.header-decoration {
    margin-top: 4px;
    opacity: 0.65;
    font-size: 14px;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

header button {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 5px;
}

/* Board picker (toolbar): grid icon + "Boards" label */
.boards-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 6px;
    border-radius: 8px;
    max-width: min(100%, 132px);
}

.boards-toolbar-btn:hover {
    background: rgba(0, 0, 0, 0.045);
}

.boards-toolbar-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-color);
    line-height: 1.1;
}

@media (max-width: 380px) {
    .boards-toolbar-label {
        display: none;
    }
}

.mode-indicator {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    background: var(--cell-bg);
    letter-spacing: 0.04em;
}

.mode-indicator.is-pro {
    color: #0f5132;
    border-color: #75c69d;
    background: #d8f3dc;
}

.mode-indicator.is-free {
    color: #664d03;
    border-color: #ffda6a;
    background: #fff3cd;
}

/* === Grid Layout === */
#grid-container {
    display: grid;
    gap: 8px;
    width: min(88vw, 88vh, 560px);
    aspect-ratio: 1 / 1;
    flex-grow: 0;
    margin: 0 auto 20px;
}

/* Dynamic Grids based on JS classes */
.grid-3x3 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.grid-4x4 { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); }
.grid-5x5 { grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(5, 1fr); }
.grid-6x6 { grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(6, 1fr); }

.grid-cell {
    background-color: var(--cell-bg);
    border: 3px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    word-break: break-word;
    box-shadow: 0 4px 0 var(--border-color);
}

#view-main {
    align-items: center;
}

#view-main > header,
#view-main > .streak-card,
#view-main > .secondary-btn {
    width: min(88vw, 88vh, 560px);
}

.grid-cell:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 var(--border-color);
}

.grid-4x4 .grid-cell { font-size: 14px; padding: 5px; border-radius: 12px; }
.grid-5x5 .grid-cell { font-size: 12px; padding: 4px; border-radius: 10px; }
.grid-6x6 .grid-cell { font-size: 10px; padding: 2px; border-radius: 8px; border-width: 2px; box-shadow: 0 2px 0 var(--border-color); }

.grid-cell.completed {
    background-color: var(--cell-completed);
    color: var(--cell-completed-text);
    border-color: var(--cell-completed);
    transform: translateY(4px) scale(0.98);
    box-shadow: 0 0 0 var(--border-color);
    opacity: 0.95;
    border-style: dashed;
}

/* Empty / user-editable last-row cells */
.grid-cell.is-empty {
    background-color: transparent;
    color: var(--text-muted);
    border-style: dashed;
    box-shadow: none;
    font-weight: 500;
    font-style: italic;
    opacity: 0.55;
}

.grid-cell.is-empty:hover {
    opacity: 0.85;
}

.grid-4x4 .grid-cell.is-empty { font-size: 12px; }
.grid-5x5 .grid-cell.is-empty { font-size: 10px; }
.grid-6x6 .grid-cell.is-empty { font-size: 9px; line-height: 1.1; }

/* === Stats Bar === */
.stats-bar {
    display: flex;
    justify-content: space-around;
    padding: 12px 0 6px;
    margin-bottom: 0;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 600;
}

.stat-label {
    font-size: 14px;
    color: var(--text-muted);
}

.streak-card {
    position: relative;
    border: 3px solid var(--border-color);
    border-radius: 30px 100px 40px 120px / 100px 40px 120px 30px;
    background: var(--cell-bg);
    padding: 16px 14px 14px;
    margin-bottom: 16px;
    box-shadow: 0 8px 0 rgba(0, 0, 0, 0.08);
    text-align: center;
}

.streak-card-deco {
    position: absolute;
    font-size: 30px;
    line-height: 1;
    opacity: 0.9;
}

.streak-card-deco.left {
    left: -6px;
    bottom: -10px;
}

.streak-card-deco.right {
    right: -8px;
    top: -14px;
}

.streak-caption {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
}

.streak-main {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 8px;
    margin-top: 6px;
}

.streak-number {
    font-size: 46px;
    line-height: 1;
    font-weight: 800;
}

.streak-unit {
    font-size: 16px;
    font-weight: 700;
    opacity: 0.85;
}

.streak-progress {
    margin: 8px auto 0;
    width: 92%;
    height: 10px;
    border: 2px solid var(--border-color);
    border-radius: 999px;
    padding: 1px;
    background: var(--bg-color);
}

.streak-progress-bar {
    width: 75%;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--cta-color), var(--cell-completed));
}

.streak-quote {
    margin-top: 10px;
    font-size: 14px;
    color: var(--text-muted);
    font-style: italic;
}

.streak-sparkles {
    margin-top: 4px;
    opacity: 0.7;
}

/* === Buttons === */
button {
    font-family: inherit;
    transition: opacity 0.2s;
}

button:active {
    opacity: 0.7;
}

.primary-btn {
    width: 100%;
    padding: 16px;
    background-color: var(--cta-color);
    color: #fff;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: auto;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
    transition: transform 0.1s, box-shadow 0.1s;
}

.primary-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.1);
}

.secondary-btn {
    width: 100%;
    padding: 14px;
    background-color: transparent;
    color: var(--text-muted);
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 20px;
}

/* === FAQ + Footer (SEO/GEO content) === */
.page-faq {
    width: min(88vw, 88vh, 560px);
    margin: 8px auto 24px;
    text-align: left;
}

.page-faq h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 12px;
    letter-spacing: 0.02em;
}

.faq-item {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--cell-bg);
    padding: 12px 14px;
    margin-bottom: 10px;
}

.faq-item summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
    content: "＋";
    color: var(--text-muted);
    font-weight: 400;
    font-size: 16px;
    flex-shrink: 0;
}

.faq-item[open] summary::after {
    content: "－";
}

.faq-item p {
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-muted);
}

.page-footer {
    width: min(88vw, 88vh, 560px);
    margin: 0 auto 24px;
    text-align: center;
}

.page-footer .builder-note {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 8px;
}

.page-footer .disclaimer {
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-muted);
    opacity: 0.85;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-top: 4px;
}

/* === Modals (Overlays) === */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    background-color: var(--bg-color);
    z-index: 100;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
}

.modal.active {
    transform: translateY(0);
}

.modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--bg-color);
    border-radius: 24px 24px 0 0; /* Softer top edges for modals */
    box-shadow: 0 -10px 40px rgba(0,0,0,0.05); /* Soft drop shadow */
    padding: 30px 20px 20px 20px;
    margin-top: 20px;
}

.close-btn {
    font-size: 28px;
    line-height: 1;
}

section {
    margin-bottom: 30px;
}

h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-muted);
}

/* Settings Options */
.options-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.option-btn {
    padding: 12px;
    border: 2px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.option-btn.active {
    background-color: var(--text-color);
    color: var(--bg-color);
}

/* Tier: layouts/themes not allowed for current user (still tappable → Premium modal). */
.option-btn.is-locked:not(.active) {
    opacity: 0.58;
}

.badge {
    background-color: #FFB800;
    color: #000;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 600;
}

/* Shared Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.form-group input, .form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.disabled-fields {
    opacity: 0.5;
    pointer-events: none;
}

.premium-fields.hidden {
    display: none;
}

.premium-benefits ul {
    list-style: none;
    margin-bottom: 30px;
}

.premium-benefits li {
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 500;
}

.footer-links {
    margin-top: auto;
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 12px;
    text-decoration: none;
}

/* === Calendar View === */
.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-color);
    padding: 10px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    text-align: center;
    margin-bottom: 20px;
}

.cal-day-header {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 5px;
}

.cal-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid transparent;
}

.cal-cell.empty {
    cursor: default;
}

.cal-cell.has-data {
    font-weight: bold;
    color: var(--cta-color);
    background-color: var(--bg-color);
    border: 1px solid var(--cta-color);
}

.cal-cell.has-data:hover, .cal-cell.has-data.selected {
    background-color: var(--cta-color);
    color: #fff;
}

.cal-cell.today {
    text-decoration: underline;
}

.history-details {
    margin-top: auto;
    background-color: var(--cell-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    min-height: 150px;
}

.history-details h4 {
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--text-muted);
}

#history-tasks-list {
    list-style: none;
    font-size: 14px;
}

#history-tasks-list li {
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
}

#history-tasks-list li::before {
    content: '✓';
    color: var(--cta-color);
    margin-right: 8px;
    font-weight: bold;
}

/* === Home & Custom Board Creator === */
.home-view-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.link-btn {
    background: none;
    border: none;
    color: var(--cta-color);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 4px;
    font-family: inherit;
}

.link-btn:hover {
    text-decoration: underline;
}

.home-heading {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 20px;
    line-height: 1.25;
}

.home-choice-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.home-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 8px;
    padding: 18px 16px;
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    background: var(--cell-bg);
    cursor: pointer;
    font-family: inherit;
    color: var(--text-color);
    transition: border-color 0.15s ease, transform 0.1s ease;
}

button.home-card:hover {
    border-color: var(--cta-color);
    transform: translateY(-1px);
}

.home-card-saved {
    cursor: default;
    border-style: solid;
}

.home-card-saved.is-hidden {
    display: none;
}

.home-card > .home-card-title {
    font-size: 17px;
    font-weight: 600;
}

.home-card-eyebrow {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.home-card-desc {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.45;
}

.home-card-action {
    margin-top: 8px;
    width: 100%;
}

.custom-board-helper {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 20px;
}

.custom-board-label {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--text-muted);
}

.label-hint {
    font-weight: 400;
    color: var(--text-muted);
    opacity: 0.9;
}

.custom-size-options {
    margin-bottom: 0;
}

.custom-task-fields-wrap {
    margin-bottom: 24px;
}

.custom-task-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: min(50vh, 320px);
    overflow-y: auto;
    padding: 4px 2px 8px 0;
}

.custom-task-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.custom-task-num {
    flex: 0 0 26px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.custom-task-row input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
}

.custom-task-row input:focus {
    outline: none;
    border-color: var(--cta-color);
}

#custom-generate-btn {
    width: 100%;
    margin-top: 8px;
}
