:root {
  color-scheme: dark;
  --bg: #171717;
  --panel: #202020;
  --line: #3a3a3a;
  --text: #f1f1f1;
  --muted: #aaa;
  --button: #2c2c2c;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 Arial, Helvetica, sans-serif; }
button, input { font: inherit; }
button, .file-button { border: 1px solid #505050; background: var(--button); color: var(--text); border-radius: 4px; padding: 8px 11px; cursor: pointer; }
button:hover, .file-button:hover { background: #393939; }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: #e8e8e8; color: #111; border-color: #e8e8e8; font-weight: 700; }
button.primary:hover { background: white; }
button.active { background: #555; border-color: #777; }
.wrap { width: min(1080px, calc(100% - 24px)); margin: 0 auto; }
.site-header { display: flex; gap: 20px; align-items: end; justify-content: space-between; padding: 26px 0 18px; border-bottom: 1px solid var(--line); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 3px; font-size: 28px; }
h2 { margin-bottom: 3px; }
h3 { margin-bottom: 8px; font-size: 15px; }
.site-header p, .panel-title p { margin-bottom: 0; color: var(--muted); }
.header-actions { display: flex; flex-wrap: wrap; gap: 7px; justify-content: end; }
.toolbar { padding: 14px 0 10px; display: grid; grid-template-columns: auto auto 1fr; gap: 12px; align-items: center; }
.view-toggle { display: flex; gap: 5px; }
.personal-filter { color: var(--muted); font-size: 13px; white-space: nowrap; }
.personal-filter input { vertical-align: middle; }
.date-nav { display: grid; grid-template-columns: auto auto minmax(180px, 1fr) auto; align-items: center; gap: 7px; }
.date-nav strong { text-align: center; font-size: 16px; }
.calendar { border-top: 1px solid var(--line); }
.week-block { border-bottom: 1px solid #555; }
.week-block:last-child { border-bottom: 0; }
.week-heading { padding: 8px 10px; background: #1d1d1d; color: #bbb; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--line); }
.week-block.current-week .week-heading { color: #f7f177; }
.day { display: grid; grid-template-columns: 150px 1fr; border-bottom: 1px solid var(--line); min-height: 66px; }
.day:last-child { border-bottom: 0; }
.day-head { padding: 11px 12px 11px 0; }
.day-name { font-size: 16px; font-weight: 700; }
.day-date { color: var(--muted); font-size: 13px; }
.day.today .day-name::after { content: " today"; color: #f7f177; font-size: 11px; font-weight: 400; text-transform: uppercase; margin-left: 5px; }
.day-shows { border-left: 1px solid var(--line); padding: 8px 0 8px 14px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.airing { display: flex; align-items: baseline; gap: 8px; padding: 5px 8px; border-radius: 3px; width: fit-content; max-width: 100%; }
.airing.untracked { opacity: .48; filter: saturate(.35); }
.airing-name { font-weight: 700; }
.airing-code { color: inherit; opacity: .95; font-variant-numeric: tabular-nums; font-weight: 700; }
.airing-title { color: inherit; opacity: .78; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-day { color: #666; font-size: 13px; }

.panel-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.68); z-index: 90; }
.panel { position: fixed; top: 72px; left: 50%; transform: translateX(-50%); width: min(900px, calc(100% - 24px)); max-height: calc(100vh - 96px); overflow: auto; z-index: 100; margin: 0; padding: 18px; border: 1px solid #555; background: var(--panel); border-radius: 7px; box-shadow: 0 18px 60px rgba(0,0,0,.55); }
body.panel-open { overflow: hidden; }
.panel-title { display: flex; justify-content: space-between; gap: 20px; }
.close-panel { font-size: 22px; line-height: 1; padding: 5px 10px; align-self: start; }
.add-section { margin-top: 16px; }
.search-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.search-form input, .form-grid input:not([type=color]), .auth-grid input { display: block; width: 100%; border: 1px solid #555; background: #121212; color: white; padding: 9px; border-radius: 4px; }
.wiki-results { margin-top: 8px; border-top: 1px solid var(--line); }
.wiki-result { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.wiki-result strong { display: block; }
.wiki-result span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.or-divider { display: flex; align-items: center; gap: 10px; color: #777; margin: 18px 0 0; }
.or-divider::before, .or-divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 2fr auto auto; gap: 10px; align-items: end; }
.form-grid label, .auth-grid label { color: var(--muted); font-size: 12px; }
.form-grid label span, .auth-grid label span { opacity: .7; }
.form-grid input:not([type=color]) { margin-top: 4px; }
.color-label input { display: block; width: 52px; height: 38px; margin-top: 4px; padding: 2px; border: 1px solid #555; background: #121212; border-radius: 4px; }
.small { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.show-row { display: grid; grid-template-columns: auto 34px 1fr auto; gap: 10px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.show-row:first-child { margin-top: 10px; }
.track-toggle { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.track-toggle input { width: 16px; height: 16px; }
.show-color { width: 30px; height: 30px; border-radius: 3px; border: 1px solid rgba(255,255,255,.3); padding: 0; }
.show-color:disabled { opacity: .28; }
.show-main strong { display: block; }
.show-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.show-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: end; }
.show-actions a { color: #cfcfcf; padding: 7px 3px; }
.danger { color: #ff9b9b; }
.backup-row { display: flex; gap: 8px; margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--line); }
.notice { margin: 14px 0 0; padding: 10px 12px; border: 1px solid #6a5f36; background: #292615; border-radius: 4px; }
.notice.error { border-color: #713d3d; background: #2b1717; }
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 16px; }
.auth-grid form { border: 1px solid var(--line); padding: 14px; border-radius: 4px; }
.auth-grid label { display: block; margin-bottom: 10px; }
.auth-grid input { margin-top: 4px; }
#account-current { margin-top: 14px; }
.account-current-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
footer { display: flex; gap: 8px; color: #777; font-size: 12px; padding: 24px 0 35px; }
@media (max-width: 820px) {
  .panel { top: 12px; max-height: calc(100vh - 24px); }
  .site-header { align-items: start; flex-direction: column; }
  .header-actions { justify-content: start; }
  .toolbar { grid-template-columns: 1fr; }
  .date-nav { grid-template-columns: auto auto 1fr auto; }
  .form-grid { grid-template-columns: 1fr; }
  .auth-grid { grid-template-columns: 1fr; }
  .day { grid-template-columns: 105px 1fr; }
  .airing { flex-wrap: wrap; }
  .airing-title { width: 100%; }
  .show-row { grid-template-columns: auto 34px 1fr; }
  .show-actions { grid-column: 1 / -1; justify-content: start; }
}

.admin-settings { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.setting-toggle { display: flex; align-items: center; gap: 8px; color: var(--text); }
.setting-toggle input { width: 16px; height: 16px; }
