@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;700&display=swap");

:root {
  --header-h: 50px;
  --plan-h: 50px;
  --sidebar-w: 12rem;

  --max-w: 1140px;
  --table-w: 98%;

  --bg-gray: rgb(229, 228, 228);
  --border: 1px solid #403f3f;

  --z-header: 6000;
  --z-sidebar: 5500;
  --z-plan: 5000;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: "Noto Sans KR", sans-serif;
}

.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  height: var(--header-h);
  background: var(--bg-gray);
  display: flex;
  align-items: center;
  justify-content: center;

  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-header);
}

.aside-main-wrapper {
  display: flex;
  flex-grow: 1;
  align-items: flex-start;
}

/* 왼쪽 메뉴: 헤더 아래에서 고정 */
aside {
  width: var(--sidebar-w);
  background: var(--bg-gray);

  position: fixed;
  top: var(--header-h);
  left: calc(50% - (var(--max-w) / 2));
  height: calc(100vh - var(--header-h));
  overflow: hidden;

  display: flex;
  flex-direction: column;
  align-items: center;

  z-index: var(--z-sidebar);
}

/* 화면이 좁아져 max-w보다 작을 때 왼쪽 정렬 */
@media (max-width: 1140px) {
  aside {
    left: 0;
  }
}

aside nav {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: calc(var(--plan-h) + 10px) 0 20px;
  gap: 6px;
}

aside nav button {
  width: 6rem;
  padding: 0.5rem;
  background: #faf9f9;
  border: var(--border);
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
}
aside nav button:hover {
  background: #d1d1d1;
}
.selected-month-button {
  background: #d1d1d1;
  font-weight: 700;
}

hr {
  width: 7rem;
  border: none;
  border-top: 1px solid #888;
  margin: 6px 0;
}

#file-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* 본문 영역: 사이드바 폭만큼 왼쪽 여백 + 헤더+플랜바만큼 위 여백 */
main {
  flex: 1;
  min-width: 0;

  margin-left: var(--sidebar-w);
  margin-top: calc(var(--header-h) + var(--plan-h));
}

/* Psalm/구약/신약 + 카운터: 헤더 바로 아래에 고정, 테이블 폭 안에서만 */
.plan-header {
  position: fixed;
  top: var(--header-h);
  left: 50%;
  transform: translateX(-50%);
  width: var(--table-w);
  max-width: var(--max-w);
  height: var(--plan-h);
  background: #fff;
  z-index: var(--z-plan);
  display: flex;
  align-items: center;
}

.plan-header-inner {
  width: 100%;
  display: flex;
  align-items: center;
  height: 100%;
}

.plan-header-spacer {
  width: 260px;
  flex: 0 0 260px;
}

.plan-header-title {
  flex: 1;
  margin: 0;
  text-align: center;
  font-weight: 700;
  font-size: 1.6rem;
  line-height: 1;
}

.count-wrap {
  width: 260px;
  flex: 0 0 260px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.count-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 4px 8px;
  font-size: 0.9em;
  line-height: 1;

  border: 2px solid #ccc;
  border-radius: 10px;
  cursor: pointer;
}

.count-text {
  font-weight: 800;
}

.count-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 4px 8px;
  border: var(--border);
  border-radius: 10px;
  background: #faf9f9;

  font-weight: 800;
  font-size: 0.9em;
  line-height: 1;
  cursor: pointer;
}

.count-reset:hover,
.count-box:hover {
  background: #d1d1d1;
}

#schedule-container {
  width: 100%;
  overflow-x: auto;
}

table {
  width: var(--table-w);
  max-width: var(--max-w);
  margin: 0 auto;
  border-collapse: collapse;
  table-layout: auto;
}
table,
th,
td {
  border: 1px solid rgb(169, 168, 168);
}
th,
td {
  height: 2rem;
  padding: 2px;
  text-align: center;
  white-space: nowrap;
}

.schedule-table {
  margin-bottom: 20vh;
}

.highlight {
  color: red;
  font-weight: 700;
}

input {
  zoom: 1.2;
}

.psalm-table tbody tr:nth-child(10n + 6),
.psalm-table tbody tr:nth-child(10n + 7),
.psalm-table tbody tr:nth-child(10n + 8),
.psalm-table tbody tr:nth-child(10n + 9),
.psalm-table tbody tr:nth-child(10n + 10),
.plan-table tbody tr:nth-child(10n + 6),
.plan-table tbody tr:nth-child(10n + 7),
.plan-table tbody tr:nth-child(10n + 8),
.plan-table tbody tr:nth-child(10n + 9),
.plan-table tbody tr:nth-child(10n + 10) {
  background: #f2f2f2;
}

.section-row td {
  background: #e9e9e9;
  font-weight: 700;
  text-align: left;
  padding-left: 10px;
}

footer {
  position: fixed;      /* 항상 화면 하단에 붙게 */
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;         /* ✅ 전체 폭 */
  background: #333;
  color: #fff;
  text-align: center;
  padding: 10px;
  z-index: 7000;        /* header/plan보다 낮게 */
}

header, footer {
  left: 0;
  right: 0;
}

.header-inner, .footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
}

/* 반응형: 사이드바 폭만 조절 */
@media (max-width: 992px) {
  :root {
    --sidebar-w: 10rem;
  }
}

/* ✅ 모바일: 한 줄 유지 + 제목 중앙 고정 + 헤더 높이 축소 */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 8rem;
    --plan-h: 42px;
  }
  html {
    font-size: 0.85rem;
  }

  .plan-header {
    height: var(--plan-h);
  }

  .plan-header-inner {
    height: 100%;
    padding: 0;

    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 8px;

    position: relative;
  }

  .plan-header-spacer {
    display: none;
  }

  .plan-header-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;

    max-width: 60%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    line-height: 1.1;
    font-size: 1.3rem;
    pointer-events: none;
  }

  .count-wrap {
    margin-left: auto;
    width: auto;
    flex: 0 1 auto;
    min-width: 0;

    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    line-height: 1;
  }

  .count-box,
  .count-reset {
    height: 28px;
    padding: 0 10px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    font-size: 0.9em;
    line-height: 1;
  }

  .count-box {
    border: 2px solid #bfbfbf;
    border-radius: 14px;
  }

  input {
    zoom: 1.1;
  }
}

/* ✅ 더 작은 화면: 줄바꿈 없이 더 컴팩트하게 */
@media (max-width: 576px) {
  :root {
    --sidebar-w: 7rem;
    --plan-h: 40px;
  }
  html {
    font-size: 0.75rem;
  }

  .plan-header-title {
    font-size: 1.15rem;
    max-width: 55%;
  }

  .count-wrap {
    gap: 4px;
  }

  .count-box,
  .count-reset {
    height: 26px;
    padding: 0 8px;
    font-size: 0.85em;
  }

  input {
    zoom: 1.05;
  }
}