:root {
    /* --- COLOR THEME (DARK) --- */
    --bg-main: #121212; --bg-card: #1e1e1e; --text-main: #e0e0e0;
    --border-color: #333; --info-color: #3C82C5; --color-time: #ffffff;
    --color-stmarys: #a1a1a1; --color-tresco: #3C82C5;
    --color-stmartins: #CB6B38; --color-bryher: #91B760;
    --color-stagnes: #ECC346; --header-bg: #1a1a1a;

    /* 1. STRUCTURAL PADDING & SPACING */
    --card-padding: 12px 10px;
    --card-margin-bottom: 15px;
    --grid-gap: 15px;
    --page-padding: 15px;

    /* 2. TYPOGRAPHY (Posts & General Text) */
    --font-size-large: 1.15rem;
    --font-size-medium: 1rem;
    --font-size-small: 0.85rem;
    --text-line-height: 1.4;

    /* 3. BOAT SPECIFIC SPACING */
    --boat-time-width: 70px;
}

.light-theme {
    /* --- COLOR THEME (LIGHT) --- */
    --bg-main: #f4f7f6; --bg-card: #ffffff; --text-main: #333333;
    --border-color: #e0e0e0; --info-color: #2b659b; --color-time: #111111;
    --color-stmarys: #6c757d; --color-tresco: #2b659b;
    --color-stmartins: #a65429; --color-bryher: #6c8c45;
    --color-stagnes: #c29e25; --header-bg: #ffffff;
}

.item-card {
    background-color: var(--bg-card);
    border-radius: 8px;
    padding: var(--card-padding);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    line-height: var(--text-line-height);
    overflow: hidden;
    break-inside: avoid;
    margin-bottom: var(--card-margin-bottom);
}

.boat-day, .food-island, .events-month, .cards-container {
    display: none; column-count: 1; column-gap: var(--grid-gap);
}

.entry-details { font-size: var(--m-size, 1rem); white-space: pre-wrap; color: var(--text-main); margin-bottom: 0;}
.entry-extra-details { font-size: var(--s-size, 0.85rem); white-space: pre-wrap; width: 100%; }

/* BOAT & TIDE INHERITANCE */
.boat-line { display: flex; align-items: flex-start; margin-bottom: var(--m-mb, 8px); line-height: var(--m-lh, 1.4); font-size: var(--m-size, 1rem); }
.time-col { flex: 0 0 var(--boat-time-width); color: var(--color-time); font-weight: 600 !important; font-variant-numeric: tabular-nums;}
.boat-note { color: var(--color-stmarys, #a1a1a1); font-style: var(--s-i, italic); margin-bottom: 8px; font-size: var(--s-size, 0.85rem); margin-left: 0; line-height: var(--s-lh, 1.4); }
.card-footer p { font-size: var(--s-size, 0.85rem); line-height: var(--s-lh, 1.4); }

.tide-grid { display: flex; flex-direction: row; flex-wrap: nowrap; justify-content: space-between; align-items: center; gap: 5px; font-size: var(--s-size, 0.85rem); }
.tide-col { flex: 1; min-width: 0; }
.weather-col { flex: 0 0 auto; }

html { background-color: #050505; }
html.light-theme { background-color: #d1d8e0; }

body {
    font-family: var(--main-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
    background-color: var(--bg-main); color: var(--text-main); margin: 0 auto;
    padding: 0 0 80px 0; transition: all 0.3s ease; max-width: 1250px; min-height: 100vh; position: relative;
}

@media (min-width: 601px) {
    body { box-shadow: 0 0 40px rgba(0,0,0,0.5); }
    .light-theme body { box-shadow: 0 0 40px rgba(0,0,0,0.1); }
}

#sticky-header {
    position: sticky; top: 0; left: 0; right: 0; background: var(--header-bg); z-index: 1000;
    box-shadow: 0 4px 15px -5px rgba(0,0,0,0.6); display: flex; flex-direction: column;
    transition: background-color 0.3s ease; max-width: 1250px; margin: 0 auto;
}

.logo-bar { text-align: center; padding: 0; border-bottom: 1px solid var(--border-color); background: var(--header-bg); }
.banner-img { width: 100%; max-width: 600px; height: auto; display: block; margin: 0 auto; }
.light-only { display: none; }
.dark-only { display: block; }
.light-theme .light-only { display: block; }
.light-theme .dark-only { display: none; }

.main-tabs { display: flex; justify-content: space-around; border-bottom: 1px solid var(--border-color); background: rgba(0,0,0,0.2); }
.light-theme .main-tabs { background: #fafafa; }
.tab-btn { flex: 1; padding: 12px 0; text-align: center; font-size: 15px; font-weight: 600; color: #888; cursor: pointer; border-bottom: 3px solid transparent; transition: all 0.2s;}
.tab-btn.active { color: var(--color-tresco); border-bottom: 3px solid var(--color-tresco); background: var(--bg-card); }
.light-theme .tab-btn.active { color: var(--color-tresco); border-bottom: 3px solid var(--color-tresco); }

.sub-nav { display: flex; justify-content: space-between; align-items: center; padding: 0 15px; background: var(--bg-card); font-weight: 700; font-size: 1.2em; text-align: center; height: 56px; }
.nav-arrow { cursor: pointer; padding: 5px 15px; color: #ce9178; user-select: none; font-size: 24px; font-weight: bold;}
#sub-nav-title { color: #ce9178; height: 100%; display: flex; align-items: center; justify-content: center;}
.light-theme .nav-arrow, .light-theme #sub-nav-title { color: var(--color-tresco); }

.view-container { display: none; padding: var(--page-padding, 15px); max-width: 1250px; margin: 0 auto; }
.view-container.active { display: block; }
.cards-container { display: block; margin-bottom: 40px; }

.mobile-flex-container { display: contents; }
@media (max-width: 699px) {
    .mobile-flex-container { display: flex; flex-direction: column; gap: var(--card-margin-bottom); }
    .mobile-flex-container .item-card { margin-bottom: 0; }
    .order-1 { order: 1; } .order-2 { order: 2; } .order-3 { order: 3; } .order-4 { order: 4; }
}

@media (min-width: 700px) { .boat-day, .food-island, .events-month, .cards-container { column-count: 2; } }
@media (min-width: 1100px) { .boat-day, .food-island, .events-month, .cards-container { column-count: 3; } }

.entry-top-wrapper { display: flex; gap: 15px; align-items: flex-start; margin-bottom: 10px; }
.entry-top-wrapper.reverse { flex-direction: row-reverse; }

.entry-media-col { display: flex; flex-direction: column; flex-shrink: 0; gap: 8px; }
.entry-text-col { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 0px; }
.entry-location { font-size: 0.8rem; color: #888; text-transform: uppercase; font-weight: bold; margin-bottom: 3px; }

.return-header { font-weight: bold; color: #ce9178; margin-top: 15px; margin-bottom: 10px; border-bottom: 1px dashed var(--border-color); padding-bottom: 4px; display: block; }
.light-theme .return-header { color: #c0392b; }
.placeholder-text { text-align: center; color: #888; padding: 40px 20px; font-style: italic; width: 100%; display: block; }

.fab { position: fixed; bottom: 25px; right: 25px; background: var(--color-tresco); color: white; width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: bold; border: none; box-shadow: 0 4px 12px rgba(0,0,0,0.5); cursor: pointer; z-index: 999; }
.light-theme .fab { box-shadow: 0 4px 12px rgba(43, 101, 155, 0.4); }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.8); z-index: 2000; align-items: center; justify-content: center; padding: 15px; overflow-y: auto;}
.modal-content { background: var(--bg-card); width: 100%; max-width: 500px; border-radius: 12px; padding: 25px; box-sizing: border-box; border: 1px solid var(--border-color); margin: auto;}

.form-group { margin-bottom: 15px; border-bottom: 1px solid rgba(128,128,128,0.2); padding-bottom: 10px;}
.form-group:last-child { border-bottom: none; }
.form-group label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 5px; color: var(--text-main);}
.form-group input[type="text"], .form-group input[type="url"], .form-group input[type="password"], .form-group select, .form-group textarea { width: 100%; padding: 10px; border: 1px solid var(--border-color); border-radius: 6px; box-sizing: border-box; font-family: inherit; font-size: 15px; background: var(--bg-main); color: var(--text-main);}

.radio-group { display: flex; gap: 15px; margin-top: 8px; font-size: 14px;}
.slider-group { margin-top: 10px; display: none; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; border: none;}
.btn { padding: 10px 18px; border-radius: 6px; font-weight: 600; font-size: 15px; border: none; cursor: pointer; }
.btn-cancel { background: var(--border-color); color: var(--text-main);}

.app-footer { margin-top: 20px; padding: 30px 15px; border-top: 1px solid var(--border-color); text-align: center; }
.theme-btn { background: none; border: 1px solid var(--border-color); color: var(--text-main); padding: 10px 20px; border-radius: 8px; cursor: pointer; font-size: 1.1em; font-weight: bold;}

.slider-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 15px; }
.slider-cell { font-size: 13px; }
.slider-cell input[type="range"] { width: 100%; margin-top: 5px; }

.editable-text { outline: none; border-bottom: 1px dashed transparent; transition: border-bottom 0.2s; min-height: 1.2em; display: inline-block; width: 100%;}
.editable-text:focus { border-bottom: 1px dashed var(--color-tresco); background: rgba(0,0,0,0.1); border-radius: 4px;}
.light-theme .editable-text:focus { background: rgba(43,101,155,0.05); }
.editable-text:empty:before { content: attr(placeholder); color: #888; pointer-events: none; display: block; }

.admin-h1 { color: var(--color-tresco); border-bottom: 2px solid var(--border-color); padding-bottom: 10px; margin-bottom: 30px;}
.admin-h2 { margin-top: 20px; color: #888; width: 100%; border-bottom: 1px solid var(--border-color); padding-bottom: 5px;}
.pending-card { border-left: 5px solid #ff9800; }
.approved-card { border-left: 5px solid #28a745; }
.admin-controls { margin-top: 15px; padding-top: 15px; border-top: 1px dashed var(--border-color); display: flex; gap: 10px; clear: both;}
.admin-btn { padding: 8px 15px; border-radius: 5px; cursor: pointer; font-weight: bold; text-decoration: none; font-size: 14px; text-align: center; flex: 1; border: none;}
.btn-approve { background: #28a745; color: #000 !important; }
.btn-edit { background: #ffc107; color: #000 !important; }
.btn-delete { background: #dc3545; color: #000 !important; }
.btn-submit { background: var(--color-tresco); color: #000 !important; }

.admin-empty { font-style: italic; color: #888; column-span: all;}
.back-link { display: inline-block; margin: 20px 0; color: var(--color-tresco); text-decoration: none; font-weight: bold; }
.content-wrapper { padding: 0 var(--page-padding, 15px); max-width: 1250px; margin: 0 auto;}
.toolbar-btn { background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border-color); border-radius: 4px; padding: 4px 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 13px; transition: all 0.2s;}
.toolbar-btn:hover { background: rgba(128,128,128,0.2); }
.toolbar-divider { width: 1px; height: 18px; background: var(--border-color); margin: 0 4px; }

/* CENTRALIZED ISLAND THEME FORMATTING */
.entry-title, .txt-heading, .entry-details h1, .entry-details h2, .entry-details h3 { font-size: var(--h-size) !important; line-height: var(--h-lh) !important; margin-top: var(--h-mt) !important; margin-bottom: var(--h-mb) !important; font-weight: var(--h-b) !important; font-style: var(--h-i) !important; text-decoration: var(--h-u) !important; display: block; transition: color 0.2s; }
.txt-large { font-size: var(--l-size) !important; line-height: var(--l-lh) !important; margin-top: var(--l-mt) !important; margin-bottom: var(--l-mb) !important; font-weight: var(--l-b) !important; font-style: var(--l-i) !important; text-decoration: var(--l-u) !important; display: block; }
.txt-medium, .entry-details p { font-size: var(--m-size) !important; line-height: var(--m-lh) !important; margin-top: var(--m-mt) !important; margin-bottom: var(--m-mb) !important; font-weight: var(--m-b) !important; font-style: var(--m-i) !important; text-decoration: var(--m-u) !important; display: block; }
.txt-small, .entry-extra-details, .entry-extra-details p { font-size: var(--s-size) !important; line-height: var(--s-lh) !important; margin-top: var(--s-mt) !important; margin-bottom: var(--s-mb) !important; font-weight: var(--s-b) !important; font-style: var(--s-i) !important; text-decoration: var(--s-u) !important; display: block; }
.txt-heading a, .txt-large a, .txt-medium a, .txt-small a, .entry-details a, .entry-extra-details a { font-size: inherit !important; font-weight: inherit !important; text-decoration: underline !important; }

/* FIX 1: RESTORED HIGHLIGHT COLORS */
.stmarys-hl { color: var(--color-stmarys) !important; font-weight: bold; white-space: nowrap; cursor: pointer; }
.tresco-hl { color: var(--color-tresco) !important; font-weight: bold; white-space: nowrap; cursor: pointer; }
.bryher-hl { color: var(--color-bryher) !important; font-weight: bold; white-space: nowrap; cursor: pointer; }
.stmartins-hl { color: var(--color-stmartins) !important; font-weight: bold; white-space: nowrap; cursor: pointer; }
.stagnes-hl { color: var(--color-stagnes) !important; font-weight: bold; white-space: nowrap; cursor: pointer; }

.theme-tresco .entry-title, .theme-tresco .txt-heading, .theme-tresco a { color: var(--color-tresco) !important; }
.theme-stmarys .entry-title, .theme-stmarys .txt-heading, .theme-stmarys a { color: var(--color-stmarys) !important; }
.theme-stmartins .entry-title, .theme-stmartins .txt-heading, .theme-stmartins a { color: var(--color-stmartins) !important; }
.theme-bryher .entry-title, .theme-bryher .txt-heading, .theme-bryher a { color: var(--color-bryher) !important; }
.theme-stagnes .entry-title, .theme-stagnes .txt-heading, .theme-stagnes a { color: var(--color-stagnes) !important; }

/* FIX 2: FORCE TINTING */
.item-card.theme-tresco, .live-preview-box.theme-tresco { background: color-mix(in srgb, var(--color-tresco) var(--card-tint-percent, 0%), var(--bg-card)) !important; }
.item-card.theme-stmarys, .live-preview-box.theme-stmarys { background: color-mix(in srgb, var(--color-stmarys) var(--card-tint-percent, 0%), var(--bg-card)) !important; }
.item-card.theme-stmartins, .live-preview-box.theme-stmartins { background: color-mix(in srgb, var(--color-stmartins) var(--card-tint-percent, 0%), var(--bg-card)) !important; }
.item-card.theme-bryher, .live-preview-box.theme-bryher { background: color-mix(in srgb, var(--color-bryher) var(--card-tint-percent, 0%), var(--bg-card)) !important; }
.item-card.theme-stagnes, .live-preview-box.theme-stagnes { background: color-mix(in srgb, var(--color-stagnes) var(--card-tint-percent, 0%), var(--bg-card)) !important; }

.location-link-wrapper { display: inline-flex; align-items: center; gap: 6px; text-decoration: none !important; transition: transform 0.2s ease; }
.location-link-wrapper:hover { transform: scale(1.05); }
.custom-pin-icon { display: inline-block; width: 22px; height: 22px; background-color: currentColor; -webkit-mask-image: url('/static/assets/custom-pin.png'); mask-image: url('/static/assets/custom-pin.png'); -webkit-mask-size: contain; mask-size: contain; -webkit-mask-position: center; mask-position: center; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
.location-text { font-size: var(--s-size) !important; font-weight: var(--s-b) !important; font-style: var(--s-i) !important; text-decoration: var(--s-u) !important; line-height: 1; }

/* MOBILE STICKY-SPLIT EDITOR (OPTION B) */
.live-preview-box {
    border-radius: 8px;
    padding: var(--card-padding);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    line-height: var(--text-line-height);
    margin: 0 auto 20px auto;
    max-width: 380px;
}

@media (max-width: 600px) {
    .modal-overlay { padding: 0 !important; align-items: flex-start; }
    .modal-content { height: 100dvh; width: 100vw; max-width: none; border-radius: 0; border: none; padding: 0 !important; display: flex; flex-direction: column;}
    .modal-content h3 { display: none; } 
    .modal-content form { height: 100%; overflow-y: auto; position: relative; padding-bottom: 20px; }
    
    .live-preview-box {
        position: sticky !important; top: 0; z-index: 100; flex: none !important;
        height: 40dvh; max-height: 40dvh !important; max-width: 100% !important; margin: 0 0 15px 0 !important;
        border-radius: 0 0 12px 12px !important; border: none; border-bottom: 4px solid var(--color-tresco);
        box-shadow: 0 4px 20px rgba(0,0,0,0.4); overflow-y: auto; 
    }
    
    .form-group, .radio-group, .slider-grid, .modal-buttons { padding-left: 15px; padding-right: 15px; }
    .compact-toolbar { padding: 6px 2px !important; margin: 12px 15px; }
    .compact-toolbar .toolbar-btn { padding: 8px 6px !important; }
}

/* --- 5009 POLISH --- */
.admin-btn.btn-submit[href*='fetch_'] { width: 140px; white-space: normal; line-height: 1.2; font-size: 0.8em; padding: 6px; display: inline-flex; align-items: center; justify-content: center; height: auto; }
.entry-details > :last-child, .entry-extra-details > :last-child { margin-bottom: 0 !important; }

/* --- NOTICE CARD STYLING --- */
.notice-card { background-color: var(--card-b-col) !important; border: none !important; color: #ffffff !important; box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important; }
.notice-card * { color: #ffffff !important; }
.notice-card .entry-location { font-size: 0.9em; border-bottom: 1px dashed rgba(255,255,255,0.4); padding-bottom: 5px; margin-bottom: 8px; }
.notice-card .location-link-wrapper span { background-color: #ffffff !important; }
