:root {
  color-scheme: light;
  --desktop: #008080;
  --face: #c0c0c0;
  --light: #ffffff;
  --shadow: #808080;
  --dark: #000000;
  --blue: #000080;
  --ok: #008000;
  --warn: #b85c00;
  --bad: #a00000;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, .08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0, 0, 0, .08) 25%, transparent 25%),
    var(--desktop);
  background-size: 10px 10px;
  color: var(--dark);
  font-family: "MS Sans Serif", Tahoma, Arial, sans-serif;
  font-size: 14px;
  padding: 18px;
}

.window {
  width: min(1120px, 100%);
  margin: 0 auto;
  background: var(--face);
  border: 2px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .45);
}

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  padding: 3px 4px 3px 8px;
  color: white;
  background: linear-gradient(90deg, var(--blue), #1084d0);
  font-weight: 700;
}

.debug-refresh {
  display: none;
}

body.debug .debug-refresh {
  display: inline-block;
  min-height: 20px;
  padding: 0 6px;
  font-size: 12px;
}

button {
  border: 2px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
  background: var(--face);
}

.toolbar,
.status-grid,
.recent-feed,
.weekly-report,
.weekly-summary,
.brother-detail {
  margin: 10px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
}

.toolbar p,
.channel,
.video-date,
.note,
.month-label,
small {
  color: #202020;
}

.toolbar p:empty {
  display: none;
}

.month-label {
  margin-top: 4px;
  font-weight: 700;
}

.channel-button {
  min-width: 0;
  min-height: 0;
  padding: 0;
  color: #202020;
  background: transparent;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.channel-button:hover {
  text-decoration: underline;
}

.mini-calendar {
  display: grid;
  grid-template-columns: repeat(7, 42px);
  gap: 4px;
  margin-top: 8px;
}

.week-nav {
  display: inline-grid;
  grid-template-columns: 28px auto 28px;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.week-nav[hidden] {
  display: none;
}

.week-nav button {
  min-height: 28px;
}

.week-nav .arrow-button {
  min-width: 28px;
  width: 28px;
  padding: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 18px;
}

.mini-calendar[hidden] {
  display: none;
}

.mini-day {
  min-height: 38px;
  padding: 4px;
  text-align: center;
  background: white;
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
}

.mini-day strong,
.mini-day span {
  display: block;
}

.mini-day strong {
  font-size: 10px;
}

.mini-day span {
  font-size: 16px;
  font-weight: 700;
}

.mini-day.today {
  color: white;
  background: var(--blue);
}

button {
  min-width: 88px;
  min-height: 32px;
  color: var(--dark);
  font: inherit;
  cursor: pointer;
}

button:active {
  border-color: var(--dark) var(--light) var(--light) var(--dark);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tabs button.active {
  border-color: var(--dark) var(--light) var(--light) var(--dark);
  background: white;
  font-weight: 700;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
  padding-bottom: 10px;
}

.card {
  display: grid;
  gap: 10px;
  min-height: 210px;
  padding: 10px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--light) var(--shadow) var(--shadow) var(--light);
  cursor: pointer;
}

.card:focus {
  outline: 2px dotted var(--dark);
  outline-offset: -6px;
}

.card.behind {
  background: #d8d0c8;
}

.card.complete {
  background: #c8d8c8;
}

.card.error {
  background: #d8c8c8;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.person-line {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.person-line::before,
.summary-brother span::before {
  display: none;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  content: var(--initials, "?");
  color: white;
  background: var(--blue);
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
  font-weight: 700;
}

.person-line:has(.avatar[hidden])::before,
.summary-brother span:has(.avatar[hidden])::before {
  display: grid;
}

.avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  object-fit: cover;
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
  background: white;
}

h2 {
  font-size: 18px;
}

.score {
  min-width: 56px;
  height: 34px;
  padding-top: 6px;
  text-align: center;
  background: white;
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
}

.meter {
  height: 18px;
  padding: 2px;
  background: white;
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: repeating-linear-gradient(90deg, #000080 0 8px, #1084d0 8px 16px);
}

.video-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  align-items: start;
}

.video-row img {
  width: 96px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
  background: white;
}

.video-title {
  display: -webkit-box;
  overflow: hidden;
  min-height: 36px;
  color: var(--blue);
  font-weight: 700;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.note {
  align-self: end;
  padding: 6px;
  background: white;
  border: 1px solid var(--shadow);
}

.recent-feed {
  display: grid;
  gap: 8px;
  padding-bottom: 10px;
}

.recent-feed[hidden],
.status-grid[hidden],
.weekly-report[hidden],
.weekly-summary[hidden],
.brother-detail[hidden] {
  display: none;
}

.feed-item {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px;
  background: white;
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
}

.feed-item img {
  width: 120px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--shadow);
}

.brother-detail {
  display: grid;
  gap: 10px;
  padding-bottom: 10px;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  background: white;
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
}

.weekly-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.weekly-total {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--light) var(--shadow) var(--shadow) var(--light);
}

.detail-posts {
  display: grid;
  gap: 8px;
}

.empty-state {
  padding: 10px;
  background: white;
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
}

.weekly-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding-bottom: 10px;
}

.weekly-report {
  display: flex;
  justify-content: flex-end;
  padding-bottom: 10px;
}

.weekly-report pre {
  display: none;
}

.summary-group {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--light) var(--shadow) var(--shadow) var(--light);
}

.summary-group > div {
  display: grid;
  gap: 6px;
}

.summary-brother {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  color: var(--dark);
  text-align: left;
  -webkit-appearance: none;
  appearance: none;
}

.summary-brother.count-0 {
  background: #d7d2cc;
}

.summary-brother.count-1 {
  background: #ddd5be;
}

.summary-brother.count-2 {
  background: #d8dcbf;
}

.summary-brother.count-3 {
  background: #cbdcbf;
}

.summary-brother.count-5 {
  background: #b9d6b6;
}

.summary-brother.count-7 {
  background: #a4cda8;
}

.summary-brother.count-10 {
  background: #8fbd99;
}

.summary-brother span {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.summary-brother .avatar {
  width: 24px;
  height: 24px;
}

.summary-brother span::before {
  width: 24px;
  height: 24px;
  font-size: 11px;
}

.summary-brother em {
  overflow: hidden;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-brother small {
  display: block;
  margin-top: 2px;
  color: #5a2a00;
  font-size: 12px;
  font-weight: 700;
}

.summary-brother small[hidden] {
  display: none;
}

@media (max-width: 640px) {
  body {
    padding: 8px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .mini-calendar {
    grid-template-columns: repeat(7, minmax(30px, 1fr));
  }

  .toolbar-actions,
  .tabs {
    align-items: stretch;
    flex-direction: column;
  }

  .weekly-summary {
    grid-template-columns: 1fr;
  }

  .feed-item {
    grid-template-columns: 96px 1fr;
  }

  .feed-item img {
    width: 96px;
  }

  .detail-header {
    align-items: stretch;
    flex-direction: column;
  }

  #backButton {
    align-self: flex-end;
  }
}
