/* HAM4LIFE Portal — base styles */
:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --ink: #1c2733;
    --muted: #6b7885;
    --line: #dfe4ea;
    --brand: #0b6bcb;
    --brand-ink: #ffffff;
    --danger: #c0392b;
    --ok: #1e7e34;
    --radius: 10px;
}
/* Dark mode — system-determined (visitors cannot choose) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1419;
        --panel: #171d24;
        --ink: #e6ebf0;
        --muted: #9aa7b2;
        --line: #2a333d;
        --brand: #3b95e6;
        --brand-ink: #ffffff;
    }
    input, select, textarea { background: #0f141a; color: var(--ink); }
    .btn.secondary { background: #232c35; color: var(--ink); }
    .steps li { background: #232c35; }
    body.setup { background: #0b0f14; }
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 1000px; margin: 0 auto; padding: 0 16px; }

/* Top bar */
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { font-weight: 700; font-size: 1.2rem; color: var(--ink); }
.mainnav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.mainnav a { color: var(--ink); }
.inline { display: inline; }
.linkbtn { background: none; border: 0; color: var(--ink); cursor: pointer; font: inherit; padding: 0; }

/* Layout blocks */
main.container { padding-top: 20px; padding-bottom: 40px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.hero { padding: 30px 0; }
.hero h1 { font-size: 2rem; margin: 0 0 8px; }
.lead { font-size: 1.1rem; color: var(--muted); }
.muted { color: var(--muted); }
.hint { display: block; color: var(--muted); font-size: .85rem; margin-top: 3px; }
.footer { border-top: 1px solid var(--line); color: var(--muted); padding: 18px 0; }

/* Buttons */
.btn {
    display: inline-block; background: var(--brand); color: var(--brand-ink);
    border: 0; border-radius: 8px; padding: 9px 16px; cursor: pointer; font: inherit; text-decoration: none;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn.secondary { background: #eef1f5; color: var(--ink); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.download { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.btn.download .dl-icon { flex: 0 0 auto; }
.btn.download.small { gap: 6px; }

/* Forms */
label { display: block; margin: 10px 0; font-weight: 600; }
input, select, textarea {
    width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px;
    font: inherit; background: #fff; color: var(--ink); margin-top: 4px; font-weight: 400;
}
label.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.checkbox input { width: auto; margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-form input, .row-form select { width: auto; flex: 1 1 160px; margin: 0; }
.inline-edit { display: flex; gap: 6px; align-items: center; }
.inline-edit input, .inline-edit select { width: auto; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 12px 0; padding: 12px; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 8px; margin: 12px 0; }
.alert.success { background: #e6f4ea; color: var(--ok); border: 1px solid #bfe3c8; }
.alert.error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c0; }
.keybox { display: block; margin-top: 6px; font-size: 1.05rem; word-break: break-all; }

/* Tables / listings */
.table-wrap { overflow-x: auto; }
table.listing { width: 100%; border-collapse: collapse; }
table.listing th, table.listing td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.listing th a { color: var(--ink); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge.live { background: #ffe1e1; color: #c0261b; }
.badge.off { background: #eceff2; color: var(--muted); }

/* Lists */
.calllist { list-style: none; padding: 0; margin: 0; }
.calllist li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: baseline; }
.calllist .date, .callsign-row .muted { margin-left: auto; color: var(--muted); font-size: .85rem; }
.call { font-weight: 700; }
.callsign-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.request blockquote { margin: 6px 0; padding: 6px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.search { display: flex; gap: 8px; align-items: center; }
.search input { width: auto; margin: 0; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat .num { display: block; font-size: 1.8rem; font-weight: 700; }

/* Event page */
.cards { display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 0; }
.event-dates { color: var(--muted); }

/* Public event photo gallery — auto-arranged, up to 5 photos.
   Fixed-size frame; the whole image is always shown (contain, never cropped). */
.photo-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.photo-grid figure { margin: 0; }
.photo-grid img {
    width: 100%; height: 220px; object-fit: contain;
    background: var(--panel); border: 1px solid var(--line); border-radius: 8px; display: block;
}
.photo-grid figcaption { font-size: .85rem; color: var(--muted); margin-top: 6px; }
/* A single photo gets a taller frame, centered */
.photo-grid.photos-1 { grid-template-columns: minmax(0, 560px); justify-content: center; }
.photo-grid.photos-1 img { height: 360px; }
/* Two photos side by side */
.photo-grid.photos-2 { grid-template-columns: repeat(2, 1fr); }

/* Editor thumbnail grid — also show the full image in a fixed frame */
.panel .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.panel .grid figure { margin: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.panel .grid img { width: 100%; height: 120px; object-fit: contain; border-radius: 6px; background: var(--panel); }
.panel .grid figcaption { font-size: .8rem; color: var(--muted); margin: 6px 0; }

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

/* Rich-text editor */
.field { margin: 10px 0; }
.field-label { display: block; font-weight: 600; margin-bottom: 4px; }
.editor { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px; background: var(--bg); border-bottom: 1px solid var(--line); }
.editor-toolbar button { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; cursor: pointer; font: inherit; color: var(--ink); line-height: 1; }
.editor-toolbar button:hover { border-color: var(--brand); }
.editor-toolbar button.active { background: var(--brand); color: var(--brand-ink); }
.editor-toolbar .sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }
.editor-toolbar .spacer { flex: 1; }
.editor-visual { min-height: 200px; padding: 10px 12px; outline: none; background: var(--panel); }
.editor-visual:empty::before { content: attr(data-placeholder); color: var(--muted); }
.editor-code { min-height: 200px; border: 0; border-radius: 0; margin: 0; font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }

/* Shared formatting for editor + published body (incl. tables) */
.editor-visual table, .event-body table { border-collapse: collapse; margin: 10px 0; max-width: 100%; }
.editor-visual th, .editor-visual td, .event-body th, .event-body td { border: 1px solid var(--line); padding: 5px 9px; }
.event-body { overflow-x: auto; }
.event-body h3, .event-body h4 { margin: 14px 0 6px; }
.event-body ul, .event-body ol { padding-left: 22px; }

/* Guide */
.guide { max-width: 780px; }
.guide h2 { margin-top: 28px; }
.guide .chain { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 18px 0; }
.guide .chain-box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; text-align: center; font-weight: 600; }
.guide .chain-arrow { color: var(--muted); font-weight: 700; }
.guide-img { margin: 14px 0 4px; }
.guide-img img { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.guide-img figcaption { color: var(--muted); font-size: .85rem; margin-top: 6px; }

/* Setup wizard */
body.setup { background: #eef1f5; }
.setup-wrap { max-width: 640px; margin: 40px auto; padding: 0 16px; }
.setup-head h1 { margin-bottom: 8px; }
.steps { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 16px; }
.steps li { padding: 4px 10px; border-radius: 999px; background: #dfe4ea; font-size: .8rem; }
.steps li.active { background: var(--brand); color: #fff; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.checks { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.checks td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.checks .mark { width: 28px; font-weight: 700; }
.checks tr.ok .mark { color: var(--ok); }
.checks tr.fail .mark { color: var(--danger); }
.test { margin: 14px 0; }
.review { line-height: 1.9; }

@media (max-width: 560px) {
    .two-col { grid-template-columns: 1fr; }
}
