/* 모듈 공통 껍데기(UR-163). 허브(/)에서 서비스 카드를 눌러 들어간 뒤 회계·일정·플랫폼 관리가
   같은 레일과 같은 폭 규칙을 쓴다 — 레일 머리(← 허브 · 모듈 이름), 모듈 메뉴, 다른 업무, 내 정보.
   색·글자·간격은 tokens.css 가 원본이고 여기는 자리만 정한다. 모듈 고유 규칙(회계의 상단 바 내용,
   일정의 폴더 트리)은 각 모듈 CSS 에 남는다.

   폭 규칙 넷(2026-09-16 사용자 결정):
     ≥ 1440       레일 · 본문 · 오른쪽 맥락 패널 3열 — 본문 폭 상한 없음
     1024 – 1439  레일 · 본문 2열 — 패널 내용은 본문 안으로
     768 – 1023   아이콘 레일 64px — 이름은 두 글자 축약(data-short)
     < 768        레일이 위쪽 가로 띠가 된다(회계는 하단 탭이 대신하므로 shell.css 가 감춘다) */
:root {
  --rail-w: 200px;
  --rail-icon-w: 64px;
  --aside-w: 320px;
  --shell-gap: 12px;
  /* 색·모서리·그림자 값은 tokens.css 가 원본이다(--r-card · --r-control · --shadow-card). */
}

/* 껍데기는 창 가장자리까지 쓴다. 브라우저 기본 body 여백 8px 이 남아 있으면 레일과 본문이
   창에서 떠 보이고, min-height:100vh 인 껍데기가 그만큼 넘쳐 세로 스크롤이 늘 생긴다.
   회계(styles.css)·허브(hub.css)·관리(admin.css)는 각자 지우고 있었고 일정만 빠져 있었다. */
body {
  margin: 0;
}

/* 키보드로 올 때만 보이는 건너뛰기 링크. 회계(styles.css)·허브(hub.css)와 같은 패턴이다 —
   공통 껍데기를 쓰는 화면에는 선언이 없어 링크가 늘 왼쪽 위에 떠 있었다. */
.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  translate: 0 -160%;
  padding: 10px 16px;
  border-radius: var(--r-control);
  background: var(--c-action);
  color: #fff;
  font-size: var(--t-aux);
  font-weight: 700;
  text-decoration: none;
  transition: translate 120ms ease-out;
}

.skip-link:focus-visible { translate: 0 0; }

.app-shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* 패널(.shell-aside)에 내용이 있을 때만 셋째 열이 생긴다 — 빈 열로 오른쪽을 비워 두지 않는다.
   has-aside 는 모듈 스크립트가 패널을 채우면서 켠다. */
@media (min-width: 1440px) {
  .app-shell.has-aside {
    grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--aside-w);
  }
}

/* ---------- 레일 ---------- */
.rail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 12px;
  background: var(--c-ground);
  box-shadow: 1px 0 0 var(--c-line);
  position: sticky;
  top: 0;
  height: 100vh;
  /* 레일 전체가 아니라 메뉴만 스크롤한다 — 통째로 스크롤하면 모듈 목록이 길어졌을 때
     "다른 업무"와 "내 계정"이 화면 밖으로 밀려난다(일정관리에서 520px 아래였다).
     이음캘린더 ver2 도 로고·프로필은 고정하고 nav 만 스크롤한다. */
  overflow: hidden;
  box-sizing: border-box;
  min-width: 0;
}

.rail-head {
  display: grid;
  gap: 4px;
  padding: 2px 6px 12px;
  margin-bottom: 6px;
}

.rail-hub {
  font-size: var(--t-aux);
  color: var(--c-muted);
  text-decoration: none;
  font-weight: 600;
}

.rail-hub:hover {
  color: var(--c-navy);
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
}

.rail-brand .brand-mark {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 7px;
  object-fit: contain;
}

.rail-brand strong {
  display: block;
  font-size: var(--t-row);
  font-weight: 700;
  color: var(--c-ink);
  letter-spacing: -0.01em;
}

.rail-brand small {
  display: block;
  color: var(--c-muted);
  font-size: var(--t-micro);
}

.rail-nav {
  display: grid;
  gap: 2px;
  align-content: start;
  /* 길어지면 이 칸만 줄어들고 스크롤한다 — 아래 두 칸(다른 업무·내 계정)은 늘 보인다. */
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  /* 위아래로 더 있다는 표시. 끝까지 밀면 그쪽 그림자가 사라진다(배경을 내용에 붙여 둔다) —
     아니면 잘린 메뉴 한 줄이 글자가 깨진 것처럼 보인다. */
  background:
    linear-gradient(to bottom, var(--c-ground), transparent) top center / 100% 14px no-repeat local,
    linear-gradient(to top, var(--c-ground), transparent) bottom center / 100% 14px no-repeat local,
    radial-gradient(farthest-side at 50% 0, rgba(15, 23, 42, 0.1), transparent) top center / 100% 7px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgba(15, 23, 42, 0.1), transparent) bottom center / 100% 7px no-repeat scroll;
}

.rail-nav .nav-item,
.rail-others a {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-control);
  background: none;
  font: inherit;
  font-size: var(--t-body);
  color: var(--c-muted);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
}

.rail-nav .nav-item:hover,
.rail-others a:hover {
  background: rgb(19 26 42 / 4%);
  color: var(--c-ink);
}

.rail-nav .nav-item.active,
.rail-nav .nav-item[aria-current="page"],
.rail-nav .nav-item.is-active {
  background: var(--c-navy-soft);
  color: var(--c-navy);
  font-weight: 600;
}

.rail-count {
  margin-left: auto;
  min-width: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--c-seal);
  color: #fff;
  font-size: var(--t-micro);
  font-weight: 600;
  text-align: center;
}

.rail h5,
.rail-others h5 {
  margin: 0;
  padding: 14px 12px 4px;
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-faint);
}

.rail-others a::after {
  content: "↗";
  margin-left: auto;
  font-size: var(--t-micro);
  color: var(--c-faint);
}

.rail-foot {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid var(--c-line);
  font-size: var(--t-aux);
  color: var(--c-muted);
}

.rail-foot strong {
  display: block;
  color: var(--c-ink);
  font-weight: 600;
}

.rail-links {
  display: flex;
  gap: 12px;
  margin-top: 6px;
}

.rail-links a,
.rail-links .text-button {
  color: var(--c-action);
  font-size: var(--t-aux);
  text-decoration: none;
  padding: 0;
  min-height: 0;
  border: 0;
  background: none;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- 본문 · 패널 ---------- */
.workspace {
  min-width: 0;
  padding: 16px clamp(16px, 1.6vw, 24px) 40px;
}

.shell-aside {
  display: none;
}

@media (min-width: 1440px) {
  .app-shell.has-aside .shell-aside {
    display: grid;
    gap: var(--shell-gap);
    align-content: start;
    padding: 16px 20px 40px 0;
    min-width: 0;
  }
}

/* ---------- 패드 세로: 아이콘 레일 ---------- */
/* 일정관리는 레일이 구역·폴더 트리라 아이콘으로 줄일 수 없다 — 패드에서도 글자 레일을 유지한다(.rail-keep).
   폰 경계는 회계 shell.css 와 같은 760px 이다. */
@media (min-width: 761px) and (max-width: 1023px) {
  .app-shell:not(.rail-keep) {
    grid-template-columns: var(--rail-icon-w) minmax(0, 1fr);
  }

  .app-shell.rail-keep .rail {
    padding: 14px 10px;
  }

  .app-shell:not(.rail-keep) .rail {
    padding: 12px 8px;
    align-items: center;
  }

  .app-shell:not(.rail-keep) .rail-head {
    padding: 0 0 10px;
    justify-items: center;
  }

  .app-shell:not(.rail-keep) :is(.rail-hub, .rail-brand strong, .rail-brand small, .rail h5, .rail-others h5, .rail-foot, .rail-nav .nav-item > .nav-label, .rail-nav .nav-item > .rail-count, .rail-others a > .nav-label, .rail-others a::after) {
    display: none;
  }

  .app-shell:not(.rail-keep) :is(.rail-nav, .rail-others) {
    width: 100%;
  }

  .app-shell:not(.rail-keep) :is(.rail-nav .nav-item, .rail-others a) {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    width: 48px;
    min-height: 48px;
    margin: 0 auto;
    padding: 0;
    font-size: 10px;
    position: relative;
  }

  /* 아이콘 세트가 없다 — 작은 네모 하나와 두 글자 축약(data-short)이 자리를 잡는다. */
  .app-shell:not(.rail-keep) :is(.rail-nav .nav-item, .rail-others a)::before {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-radius: 4px;
    box-sizing: border-box;
  }

  .app-shell:not(.rail-keep) :is(.rail-nav .nav-item, .rail-others a)::after {
    content: attr(data-short);
    display: block;
    margin: 0;
    font-size: 10px;
    color: inherit;
  }

  .app-shell:not(.rail-keep) .rail-nav .nav-item .rail-count {
    display: block;
    position: absolute;
    top: 2px;
    right: 2px;
    margin: 0;
    min-width: 16px;
    padding: 0 4px;
  }
}

/* ---------- 폰: 레일은 왼쪽 덮개, 위에는 얇은 바 ----------
   회계는 shell.css 가 레일을 감추고 하단 탭을 쓴다. 일정·플랫폼 관리는 .shell-phone-bar(← 허브 · 모듈명 · 메뉴)를
   두고, 메뉴를 누르면 레일이 왼쪽에서 덮개로 나온다(platform-shell.js). 폴더 트리가 화면을 밀어내지 않는다. */
.shell-phone-bar {
  display: none;
}

.rail-backdrop {
  display: none;
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
    min-height: 0;
  }

  .shell-phone-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--c-ground);
    box-shadow: 0 1px 0 var(--c-line);
    font-size: var(--t-body);
  }

  .shell-phone-bar .rail-hub {
    font-size: var(--t-aux);
  }

  .shell-phone-bar strong {
    font-weight: 700;
    color: var(--c-ink);
  }

  .shell-phone-bar .rail-toggle {
    margin-left: auto;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--c-line);
    border-radius: var(--r-pill);
    background: var(--c-ground);
    font: inherit;
    font-size: var(--t-aux);
    font-weight: 600;
    color: var(--c-navy);
    cursor: pointer;
  }

  .rail {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(300px, 86vw);
    height: 100%;
    transform: translateX(-104%);
    transition: transform var(--motion-sheet);
    box-shadow: 16px 0 40px rgb(19 26 42 / 18%);
  }

  .app-shell.rail-open .rail {
    transform: none;
  }

  .app-shell.rail-open .rail-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 59;
    background: rgb(19 26 42 / 30%);
  }

  .workspace {
    padding: 12px 16px 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rail {
    transition: none;
  }
}
