/* naya admin — 데스크톱은 한 줄 테이블, 모바일은 카드.
   마크업은 하나고 grid-template-areas만 바꾼다. 모바일에서 테이블을 그대로 줄이면
   가로 스크롤이 생기는데, 그게 이 화면에서 가장 못 쓸 결과다. */

:root {
  --bg: #0a0a12; --fg: #e8e8ef; --dim: #8b8b9c; --line: #23232f;
  --card: #12121c; --accent: #6b8afd; --ok: #43c08a; --bad: #e0576b; --warn: #d9a441;
  --pad: 16px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f6f9; --fg: #1a1a24; --dim: #6a6a7a; --line: #dedee6;
    --card: #fff; --accent: #3358e0;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.5 'Apple SD Gothic Neo', 'Malgun Gothic', -apple-system, sans-serif;
  -webkit-text-size-adjust: 100%;
  /* 내용이 짧아도 배경이 화면을 채우게 한다. 모바일은 아래 미디어쿼리에서
     height + 세로 flex(앱 셸)로 덮어쓴다. */
  min-height: 100vh;
  min-height: 100dvh;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
a { color: inherit; text-decoration: none; }

/* 로그인 — 덩그러니 입력창 하나. 라벨도 버튼도 두지 않는다. */
/* min-height는 body에서 상속받는다(위 규칙) — 여기선 중앙 정렬만. */
body.bare { display: flex; align-items: center; justify-content: center; }
body.bare input {
  width: min(280px, 76vw); padding: 12px 14px; font-size: 16px; /* 16px 미만이면 iOS가 확대한다 */
  background: var(--card); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px; outline: none;
}

/* --- 내비 --- */
.nav { display: flex; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 16px; color: var(--dim); font-size: 13px;
}
.nav-item.on { color: var(--fg); }
.nav-item .ico { font-size: 15px; }

.main { padding: var(--pad); padding-bottom: 40px; }
h1 { font-size: 19px; margin-bottom: 12px; }
h1 code { font-size: 17px; }
.note, .empty { color: var(--dim); font-size: 12.5px; margin-bottom: 14px; }
.empty { padding: 28px 0; text-align: center; }
.more { margin-top: 16px; text-align: center; }
.more a { color: var(--accent); font-size: 13px; }

.list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }

/* --- 상태 / 태그 ---
   상태는 배경 없는 색 글자로만 둔다. 알약 배경은 목록에서 시선을 과하게 끌고,
   카드 왼쪽 스트라이프가 이미 같은 정보를 색으로 주고 있어 중복이다. */
.status {
  display: flex; flex-direction: column; align-items: flex-end; gap: 1px;
  text-align: right; white-space: nowrap;
  font-size: 13px; font-weight: 600; color: var(--dim);
}
.status small { font-size: 11px; font-weight: 400; opacity: .75; }
.status.s1 { color: var(--accent); }
.status.s2 { color: var(--ok); }
.status.s3, .status.s5 { color: var(--bad); }
.tag { font-size: 12px; color: var(--dim); background: rgba(128,128,150,.12); padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.tag.warn { color: var(--warn); background: rgba(217,164,65,.14); }
.tag.link { color: var(--accent); }
.tag.muted { opacity: .6; }
.summary { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 16px; }

/* --- 썸네일 --- */
.thumb {
  width: 40px; height: 40px; object-fit: cover; border-radius: 6px;
  background: rgba(128,128,150,.12); display: block; flex: none;
}
.thumb.blank { border: 1px dashed var(--line); background: none; }

/* --- 작업 목록 --- */
.task-link { display: flex; align-items: center; gap: 12px; }
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.task-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.task-top b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-top code { color: var(--dim); font-size: 12px; flex: none; }
.task-sub { color: var(--dim); font-size: 12px; }
/* 상태별 좌측 스트라이프 — 목록을 훑을 때 배지를 읽지 않고도 실패가 눈에 띈다. */
.task-card { border-left-width: 3px; }
.task-card.s2 { border-left-color: var(--ok); }
.task-card.s3, .task-card.s5 { border-left-color: var(--bad); }
.task-card.s1 { border-left-color: var(--accent); }

/* --- 로그 뷰어 --- */
.log { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.row {
  display: grid; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; background: var(--card);
  border-left: 3px solid transparent;
}
.row.failed { border-left-color: var(--bad); background: rgba(224,87,107,.07); }
.row b { font-weight: 600; }
.row i { font-style: normal; color: var(--dim); }

.c-time { display: flex; flex-direction: column; }
.c-time b { font-variant-numeric: tabular-nums; font-size: 12.5px; }
.c-time i { font-size: 11px; font-variant-numeric: tabular-nums; }
.c-host { display: flex; flex-direction: column; min-width: 0; }
/* min-width:0 이 없으면 flex 자식은 축소를 거부해 ellipsis가 안 걸리고 행이 삐져나간다. */
.c-host b { font-size: 12.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-host i { font-size: 11px; }
.c-what { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.c-what b { font-size: 13px; }
.c-what i { font-size: 12px; overflow-wrap: anywhere; }
.c-img { display: flex; align-items: center; gap: 5px; }
.c-img .arrow { color: var(--dim); font-size: 11px; }
.c-dur { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }

.paths { margin-top: 2px; }
.paths summary { font-size: 11px; color: var(--dim); cursor: pointer; }
.paths div { font-size: 11px; color: var(--dim); overflow-wrap: anywhere; margin-top: 2px; }

/* --- 사용자 / 정체성 --- */
.user-top, .soul-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.user-stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--dim); margin-bottom: 4px; }
.user-stats .ok b { color: var(--ok); }
.user-stats .bad b { color: var(--bad); }
.user-sub, .soul-sub { color: var(--dim); font-size: 12px; }
.user-sub a { color: var(--accent); }
.muted { opacity: .65; }
.lives { list-style: none; margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.lives li { font-size: 12.5px; display: flex; gap: 8px; flex-wrap: wrap; }
.lives .years { color: var(--dim); font-variant-numeric: tabular-nums; }
.lives .tmpl { color: var(--accent); }

/* ?debug=1 진단 오버레이 — 뷰포트 관련 문제를 추측 대신 숫자로 보기 위한 것. */
#dbg {
  position: fixed; left: 8px; right: 8px; top: 60px; z-index: 99;
  background: rgba(0,0,0,.88); color: #7dff9b; border: 1px solid #2a5;
  border-radius: 8px; padding: 8px 10px; margin: 0;
  font: 11px/1.45 ui-monospace, Menlo, monospace; white-space: pre; pointer-events: none;
}

/* ================= 데스크톱 ================= */
@media (min-width: 768px) {
  :root { --pad: 28px; }
  /* 데스크톱은 문서 스크롤 + 상단 sticky 내비 그대로. display:contents로 셸을
     레이아웃에서 지워 nav/main이 body의 직계 자식처럼 동작하게 한다. */
  .shell { display: contents; }
  .nav {
    position: sticky; top: 0; z-index: 10;
    background: var(--bg); border-bottom: 1px solid var(--line);
    padding: 0 var(--pad);
  }
  .nav-item.on { box-shadow: inset 0 -2px 0 var(--accent); }
  .main { max-width: 1180px; margin: 0 auto; }

  /* 한 줄 테이블: 시각 | 호스트 | 내용 | 썸네일 | 소요 */
  .row { grid-template-columns: 78px 120px 1fr 100px 64px; }
  .c-time { flex-direction: row; align-items: baseline; gap: 6px; }
}

/* ================= 모바일 ================= */
@media (max-width: 767px) {
  /* 같은 요소를 3단 카드로 재배치한다 — 가로 스크롤 없이 전부 보이게. */
  .row {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "time host dur"
      "what what what"
      "img  img  img";
    gap: 4px 10px; padding: 10px 12px;
  }
  .c-time { grid-area: time; flex-direction: row; align-items: baseline; gap: 6px; }
  .c-host { grid-area: host; flex-direction: row; align-items: baseline; gap: 6px; }
  .c-what { grid-area: what; }
  .c-img  { grid-area: img; margin-top: 4px; }
  .c-dur  { grid-area: dur; }
  .c-img .thumb { width: 52px; height: 52px; }

  /* 앱 셸 레이아웃 — position:fixed를 쓰지 않는다.
     iOS 홈 화면 앱에서 fixed 하단 바는 뷰포트 높이가 확정되기 전까지 엉뚱한 데
     앉고, 스크롤 여유가 없는 짧은 페이지에서는 레이아웃 패스가 안 돌아 한 번
     잡아당기기 전까지 바닥에 안 붙는다. body를 세로 flex로 만들고 탭바를 마지막
     항목으로 두면 위치가 레이아웃만으로 정해져 그 재계산을 기다릴 필요가 없다. */
  /* 앱 셸 = 뷰포트 전체. viewport-fit=cover를 쓰지 않으므로 뷰포트가 곧
     안전영역이고 문서마다 달라지지 않는다 — inset:0이 그대로 맞는다.
     (cover를 쓰던 동안은 두 번째 문서부터 뷰포트가 상단 inset만큼 어긋나서
     100dvh·실측 px·inset:0 무엇으로도 맞출 수 없었다.) */
  .shell {
    position: fixed; inset: 0;
    display: flex; flex-direction: column;
  }
  body { overflow: hidden; }       /* 문서 전체가 아니라 .main만 스크롤한다 */
  .nav {
    order: 2; flex: none;
    background: var(--card); border-top: 1px solid var(--line);
  }
  .nav-item { flex: 1; flex-direction: column; gap: 2px; justify-content: center; padding: 9px 0 7px; font-size: 11px; }
  .nav-item.on { color: var(--accent); }

  /* .main만 스크롤한다. viewport-fit=cover를 뺐으므로 뷰포트가 상태바 아래에서
     시작하고, 콘텐츠가 상태바 밑으로 지나가는 효과는 없어졌다 — 탭바 정렬과
     맞바꾼 것이다. 상태바는 theme-color(#0a0a12)로 배경과 같은 색이 된다. */
  .main {
    order: 1; flex: 1 1 auto; min-height: 0;
    overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    padding: var(--pad);
  }
}
