:root {
    --bg:           #f9f7f4;
    --surface:      #ffffff;
    --ink:          #111111;
    --ink-mid:      #444444;
    --ink-light:    #525252;
    --rule:         #d8d2c8;
    --accent:       #1D212E;
    --accent-hover: #3F4864;
    --danger:       #a31621;
    --success:      #1a5c2a;
}

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

body {
    background: var(--bg);
    font-family: 'DM Sans', sans-serif;
    color: var(--ink);
    min-height: 100vh;
}

/* SKIP LINK */
.skip-link {
  	position: absolute;
  	left: -10000px;
  	top: auto;
  	width: 1px;
  	height: 1px;
  	overflow: hidden;
	color: var(--surface);
  	background: var(--accent);
}

.skip-link:focus {
  	position: static;
  	width: auto;
  	height: auto;
}

/* HEADER */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--rule);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    padding: 14px 0;
    gap: 12px;
}

.admin .header-inner { max-width: 800px; }

.masthead { display: flex; flex-direction: column; gap: 2px; }

.header-refresh { display: flex; flex-direction: column;}

.paper-title {
    font-family: 'Cormorant SC', serif;
    font-size: 25px;
    font-weight: 600;
    letter-spacing: 2px;
    line-height: 1;
}

.paper-date {
    font-size: 12px;
    color: var(--ink-light);
    font-weight: 300;
}

.header-actions { display: flex; gap: 8px; flex-shrink: 0; }


/* BUTTONS */
.btn {
    border: none;
    padding: 8px 14px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    cursor: pointer;
    border-radius: 3px;
    white-space: nowrap;
    text-decoration: none;
    display: inline-block;
    transition: background 0.15s;
    margin-top: auto;
}

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

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid #e0b4b4;
    font-size: 12px;
    padding: 5px 10px;
}
.btn-danger:hover { background: #fff0f0; }

.btn-sm { font-size: 12px; padding: 6px 12px; }

.btn-test {
    background: #f0ede8;
    color: var(--ink-mid);
    font-size: 12px;
    padding: 6px 12px;
}
.btn-test:hover { background: #e5e0d8; }

/* MAIN */
main {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

.admin main { max-width: 800px; }

/* ---- Index: cache note ---------------------------------------------------- */

.cache-note {
    padding: 14px 0 0;
    font-size: 11px;
    color: var(--ink-light);
    font-weight: 300;
    text-align: right;
}

/* ---- Index: section head -------------------------------------------------- */

.section-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 32px 0 4px;
}

.section-head h1 {
    font-family: 'Cormorant SC', serif;
    font-size: 22px;
    font-weight: 400;
    letter-spacing: 3px;
    color: var(--ink-light);
    white-space: nowrap;
}

.section-line { flex: 1; height: 1px; background: var(--rule); }

/* ---- Index: lead story ---------------------------------------------------- */

.lead-story {
    padding: 22px 0 18px;
    border-bottom: 1px solid var(--rule);
}

.lead-story h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(22px, 5vw, 30px);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 8px;
}

.lead-story .desc {
    font-family: 'Cormorant Garamond', serif;
    font-size: 16px;
    font-weight: 300;
    font-style: italic;
    color: var(--ink-mid);
    line-height: 1.6;
    margin-bottom: 10px;
}

/* ---- Index: story card ---------------------------------------------------- */

.story-card {
    padding: 16px 0;
    border-bottom: 1px solid var(--rule);
}

.story-card h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(16px, 3.5vw, 20px);
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 5px;
}

.story-card .desc {
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--ink-mid);
    font-weight: 300;
}

/* ---- Shared link styles --------------------------------------------------- */

.lead-story h2 a,
.story-card h2 a,
.briefing-item h3 a {
    color: inherit;
    text-decoration: none;
}

.lead-story h2 a:hover,
.story-card h2 a:hover,
.briefing-item h3 a:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
}

/* ---- Index: briefings grid ------------------------------------------------ */

.briefings {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.briefing-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--rule);
}

.briefing-item:nth-child(odd) {
    padding-right: 20px;
    border-right: 1px solid var(--rule);
}

.briefing-item:nth-child(even) { padding-left: 20px; }

.briefing-item h3 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 3px;
}

.briefing-item p {
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--ink-mid);
    font-weight: 300;
}

/* ---- Shared: meta line ---------------------------------------------------- */

.meta {
    margin-top: 8px;
    font-size: 11px;
    color: var(--ink-light);
    font-weight: 300;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ---- Index: empty section ------------------------------------------------- */

.empty-section {
    padding: 20px 0;
    font-size: 13px;
    color: var(--ink-light);
    font-style: italic;
    border-bottom: 1px solid var(--rule);
}

/* ---- Footer --------------------------------------------------------------- */

footer {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 20px 40px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid var(--rule);
}

footer span { font-size: 12px; color: var(--ink-light); font-weight: 300; }

/* ---- Admin: flash message ------------------------------------------------- */

.flash {
    padding: 12px 16px;
    border-radius: 3px;
    margin-bottom: 20px;
    font-size: 13px;
}

.flash.success { background: #f0faf2; border: 1px solid #a7d7b4; color: var(--success); }
.flash.error   { background: #fff0f0; border: 1px solid #e0b4b4; color: var(--danger); }

/* ---- Admin: section cards ------------------------------------------------- */

.section-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 4px;
    margin-bottom: 20px;
    overflow: hidden;
}

.section-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--rule);
    gap: 12px;
}

.section-card-head h2 {
    font-family: 'Cormorant SC', serif;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 1px;
}

.section-key {
    font-size: 11px;
    color: var(--ink-light);
    font-weight: 300;
    margin-top: 1px;
}

.section-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---- Admin: feed list ----------------------------------------------------- */

.feed-list { list-style: none; }

.feed-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    border-bottom: 1px solid var(--rule);
    gap: 12px;
}

.feed-item:last-child { border-bottom: none; }

.feed-info { flex: 1; min-width: 0; }
.feed-name { font-size: 13px; font-weight: 400; }

.feed-url {
    font-size: 11px;
    color: var(--ink-light);
    font-weight: 300;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 380px;
    margin-top: 2px;
}

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

.feed-status {
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 2px;
    white-space: nowrap;
}

.feed-status.ok      { background: #f0faf2; color: var(--success); }
.feed-status.err     { background: #fff0f0; color: var(--danger); }
.feed-status.pending { background: #f5f5f5; color: var(--ink-light); }

/* ---- Admin: add-feed form ------------------------------------------------- */

.add-feed-form {
    padding: 14px 18px;
    background: #faf9f7;
    border-top: 1px solid var(--rule);
    display: none;
}

.add-feed-form.open { display: block; }

.form-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 140px;
}

.form-group-wide { flex: 2; }

.form-group label {
    font-size: 11px;
    color: var(--ink-light);
    letter-spacing: 0.5px;
    font-weight: 300;
}

.form-group input {
    padding: 8px 10px;
    border: 1px solid var(--rule);
    border-radius: 3px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    background: var(--surface);
    color: var(--ink);
    outline: none;
}

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

.form-actions {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    padding-bottom: 1px;
}

.test-result { font-size: 12px; margin-top: 6px; }
.test-result.ok  { color: var(--success); }
.test-result.err { color: var(--danger); }

/* ---- Admin: add section box ----------------------------------------------- */

.add-section-box {
    background: var(--surface);
    border: 1px dashed var(--rule);
    border-radius: 4px;
    padding: 18px;
    margin-bottom: 20px;
}

.add-section-box h2 {
    font-size: 13px;
    font-weight: 400;
    color: var(--ink-mid);
    margin-bottom: 12px;
}

/* ---- Admin: empty feeds --------------------------------------------------- */

.empty-feeds {
    padding: 14px 18px;
    font-size: 13px;
    color: var(--ink-light);
    font-style: italic;
}

/* ---- Admin: danger zone --------------------------------------------------- */

.danger-zone {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--rule);
}

.danger-zone h2 {
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--ink-light);
    margin-bottom: 12px;
}

.cache-note-inline {
    font-size: 12px;
    color: var(--ink-light);
    margin-left: 10px;
}

/* RESPONSIVE */
@media (max-width: 480px) {
    .briefings        { grid-template-columns: 1fr; }
    .feed-url         { max-width: 180px; }
    .form-row         { flex-direction: column; }
}

/* DARK MODE */
@media (prefers-color-scheme: dark) {
    :root {
        --bg:           #060802;
        --surface:      #000000;
        --ink:          #eeeeee;
        --ink-mid:      #bbbbbb;
        --ink-light:    #adadad;
        --rule:         #272d37;
        --accent:       #5a6a9e;
        --accent-hover: #7d8fb8;
        --danger:       #a31621;
        --success:      #1a5c2a;
    }
}
