/* DESK 화면 스타일: 밝은·어두운 화면 모두
   색: 청록(어두운 화면이 책상 위 바 모니터의 기본 모습). 숫자(시각·기온)는 고정폭 숫자
   카드 안의 크기는 모두 --u의 배수다: app.js fit()이 화면 높이(가로)·폭(세로)에 맞춰 --u를 정한다 → 515px 바 모니터와 휴대폰 가로가 같은 비율로 보인다
   화면 틀·터치·가로 조건은 모든 서비스 공통 규칙 /srv/infra/shared/UX.md */
:root {
  --bg: #eef3f5;
  --card: #ffffff;
  --line: #d6e0e4;
  --text: #10212a;
  --dim: #4b6170;
  --faint: #617684;
  --accent: #0f6e7f;
  --accent-text: #ffffff;
  --accent-soft: #dcedf0;
  --glow: #0f6e7f;
  --good: #1d7a4c;
  --good-soft: #e2f3e9;
  --warn: #8a5300;
  --warn-soft: #fff1dc;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --shadow: 0 1px 2px rgba(10, 30, 40, .05), 0 2px 8px rgba(10, 30, 40, .06);
  --radius: 16px;
  --rail: 56px;
  /* 왼쪽·오른쪽 안전 여백: 아이폰은 가로일 때 아일랜드가 한쪽에만 있어도 양쪽에 같은 폭을 알려 준다.
     common.js가 돌린 방향을 보고 html.island-left/right를 붙이면 반대쪽은 0 */
  --sa-l: env(safe-area-inset-left, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  color-scheme: light dark;
}
html.island-left { --sa-r: 0px; }
html.island-right { --sa-l: 0px; }
/* 어두운 색: 기기 설정이 어둡고 '밝게'를 고르지 않았을 때, 또는 '어둡게'를 골랐을 때 (화면 모드는 theme.js가 <html data-theme>로 붙인다). 두 벌을 같이 고친다 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1a22;
    --card: #142a35;
    --line: #23404d;
    --text: #e8f1f4;
    --dim: #9fb6c1;
    --faint: #8aa2ad;
    --accent: #7fd3e0;
    --accent-text: #082028;
    --accent-soft: #173a47;
    --glow: #f3e6a1;
    --good: #67d29c;
    --good-soft: #13281e;
    --warn: #f0b660;
    --warn-soft: #2d2414;
    --bad: #ff8a80;
    --bad-soft: #321a19;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1a22;
  --card: #142a35;
  --line: #23404d;
  --text: #e8f1f4;
  --dim: #9fb6c1;
  --faint: #8aa2ad;
  --accent: #7fd3e0;
  --accent-text: #082028;
  --accent-soft: #173a47;
  --glow: #f3e6a1;
  --good: #67d29c;
  --good-soft: #13281e;
  --warn: #f0b660;
  --warn-soft: #2d2414;
  --bad: #ff8a80;
  --bad-soft: #321a19;
  --shadow: none;
}
/* 고른 쪽에 맞춰 입력칸·스크롤 막대 같은 브라우저 부품 색도 */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
/* 문서는 튕기지도 스크롤되지도 않는다. 가운데 내용 칸만 움직인다 (UX.md '1. 화면 틀') */
html, body { overscroll-behavior: none; }
/* 누르는 것은 두 번 눌러도 확대되지 않게 (UX.md '7. 터치') */
a, button, summary, label, input, select { touch-action: manipulation; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  word-break: keep-all; overflow-wrap: anywhere; letter-spacing: -.005em; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2 { line-height: 1.3; margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
small, .small { font-size: 13px; }
.muted { color: var(--dim); }
.ic { flex: none; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.top-spacer { flex: 1; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* 아이폰 홈 화면 앱(iOS 26~): 화면 맨 위에 고정된 띠가 없으면 아이폰이 머리줄 위에 뿌연 흐림을 덮는다.
   보이지 않는 고정 띠(.ios-edge, 각 HTML의 body 첫 줄)를 두면 흐림 대신 이 배경색으로 상태 표시줄 자리를 칠한다 (CHECKLIST F10) */
.ios-edge {
  position: fixed; top: 0; left: 0; right: 0; height: 11px; z-index: 2147483647; pointer-events: none;
  background-color: var(--bg); -webkit-background-clip: text; background-clip: text;
}
body.ak .ios-edge { background-color: var(--ak-card); }

/* ---- 화면 틀: 머리줄 · 내용 칸(이 칸만 스크롤) ---- */
body.main-page, body.login-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.top {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, var(--sa-r)) 10px max(16px, var(--sa-l));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.view, .login-page main {
  flex: 1; min-height: 0; min-width: 0; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; outline: none;
  padding: 16px max(16px, var(--sa-r)) calc(32px + env(safe-area-inset-bottom, 0px)) max(16px, var(--sa-l));
}
/* 카드 안 글자는 고르지 않는다 (끌어 넘기다 글자가 잡히지 않게). 입력칸은 그대로 */
.main-page .view { -webkit-user-select: none; user-select: none; }
.main-page input { -webkit-user-select: text; user-select: text; }
#app, #pending { max-width: 520px; margin: 0 auto; }
#app > .ak-install { margin-bottom: 16px; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-height: 44px; }
.brand-mark { display: block; border-radius: 9px; flex: none; }
.brand-text { display: grid; line-height: 1.15; font-weight: 800; font-size: 18px; letter-spacing: .06em; }
.brand-text small { font-size: 12px; font-weight: 500; letter-spacing: 0; color: var(--dim); }
.count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--bad); color: var(--card); font-size: 11px; font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--dim); }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
@media (pointer: coarse) { .btn.small { min-height: 44px; } }
@media (hover: hover) { .btn.ghost:hover { background: var(--accent-soft); color: var(--text); } }
.top-btn { position: relative; white-space: nowrap; }
/* 아주 좁은 화면(320px): 로고 아래 덧글을 숨겨 단추 자리를 남긴다 */
@media (max-width: 359px) { .brand-text small { display: none; } .top { gap: 2px; } }
.round-btn {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer;
}
.round-btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.empty { padding: 14px 16px; border-radius: 12px; border: 1px dashed var(--line); color: var(--dim); font-size: 14px; }
.load-err { display: grid; justify-items: center; gap: 8px; margin: 48px auto; max-width: 360px; padding: 24px 20px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); text-align: center; }
.load-err .ic { color: var(--warn); }
.load-err .btn { margin-top: 8px; }

/* ---- 카드 (크기는 --u의 배수. 기본값은 app.js가 맞추기 전 잠깐 쓰인다) ---- */
.view { --u: 9px; --n: 1; --gap: 12px; }
.board { display: grid; gap: var(--gap); grid-auto-rows: max-content; }
.card {
  display: flex; flex-direction: column; min-width: 0; padding: calc(var(--u) * 2.2) calc(var(--u) * 2.4);
  border-radius: calc(var(--u) * 2.2); background: var(--card); box-shadow: var(--shadow); border: 1px solid var(--line);
  font-size: max(13px, calc(var(--u) * 1.7)); font-variant-numeric: tabular-nums;
}
.card h2 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: max(13px, calc(var(--u) * 1.6)); font-weight: 600; color: var(--dim); margin-bottom: calc(var(--u) * 1); }
.card h2 small { font-size: max(12px, calc(var(--u) * 1.4)); font-weight: 500; color: var(--faint); }
.card-msg { font-size: max(15px, calc(var(--u) * 2)); font-weight: 600; margin-top: calc(var(--u) * 2); }
.card-sub { font-size: max(12px, calc(var(--u) * 1.4)); color: var(--faint); }
.card .ic { width: calc(var(--u) * 2.6); height: calc(var(--u) * 2.6); }
.card .btn { flex: 1; min-width: 0; padding: 0 4px; font-size: max(14px, calc(var(--u) * 1.7)); min-height: max(44px, calc(var(--u) * 5.2)); border-radius: calc(var(--u) * 1.4); }
.card .round-btn { width: max(44px, calc(var(--u) * 5)); height: max(44px, calc(var(--u) * 5)); }

/* 시계 */
.clock-time { text-align: center; font-size: calc(var(--u) * 9.5); font-weight: 700; line-height: 1.05; color: var(--glow); letter-spacing: -.02em; white-space: nowrap; }
.clock-time small { font-size: calc(var(--u) * 2.6); font-weight: 500; margin-left: calc(var(--u) * .6); opacity: .75; letter-spacing: 0; }
.clock-date { text-align: center; font-size: max(14px, calc(var(--u) * 2.1)); color: var(--dim); margin: calc(var(--u) * .6) 0 calc(var(--u) * 1.4); }
.world { flex: 1; display: flex; flex-direction: column; justify-content: space-around; }
.world-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding: calc(var(--u) * 1) 0; }
.world-name { display: grid; min-width: 0; line-height: 1.25; }
.world-name b { font-size: max(14px, calc(var(--u) * 2)); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.world-name small { font-size: max(12px, calc(var(--u) * 1.35)); color: var(--faint); }
.world-time { flex: none; font-size: calc(var(--u) * 4); font-weight: 600; line-height: 1.1; }

/* 날씨 */
.wx { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.wx-now { display: flex; align-items: center; gap: calc(var(--u) * 1.6); }
.wx-temp { font-size: calc(var(--u) * 8.5); font-weight: 300; line-height: 1.05; letter-spacing: -.03em; }
.wx-now > .ic { width: calc(var(--u) * 6); height: calc(var(--u) * 6); color: var(--glow); stroke-width: 1.6; }
.wx-text { display: grid; min-width: 0; line-height: 1.3; }
.wx-text b { font-size: max(15px, calc(var(--u) * 2.2)); }
.wx-text span { font-size: max(12px, calc(var(--u) * 1.45)); color: var(--dim); }
.wx-days { flex: 1; display: flex; flex-direction: column; justify-content: space-around; margin-top: calc(var(--u) * 1); }
.wx-day { display: grid; grid-template-columns: 3em auto minmax(0, 1fr) 2.6em 2.6em; align-items: center; gap: calc(var(--u) * 1); border-top: 1px solid var(--line); padding: calc(var(--u) * .7) 0; font-size: max(13px, calc(var(--u) * 1.8)); }
.wx-pop { font-size: max(12px, calc(var(--u) * 1.35)); color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-hi, .wx-lo { text-align: right; }
.wx-lo { color: var(--faint); }
.wx-at { text-align: right; }
.wx-at.old { color: var(--warn); }

/* 달력 */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: calc(var(--u) * .8); }
.cal-title { flex: 1; min-height: 44px; border: 0; background: none; color: var(--text); font: inherit; font-size: max(16px, calc(var(--u) * 2.6)); font-weight: 700; cursor: pointer; }
.cal-grid { flex: 1; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(calc(var(--u) * 4.4), 1fr); text-align: center; font-size: max(13px, calc(var(--u) * 1.9)); }
.cal-grid > div { display: grid; place-items: center; }
.cal-dow { font-size: max(12px, calc(var(--u) * 1.4)); color: var(--faint); }
.cal-grid .sun { color: var(--bad); }
.cal-grid .sat { color: var(--accent); }
.cal-day.today span { display: grid; place-items: center; width: calc(var(--u) * 4); height: calc(var(--u) * 4); border-radius: 50%; background: var(--accent); color: var(--accent-text); font-weight: 700; }

/* 할 일 */
.todo-add { display: flex; gap: 8px; margin-bottom: calc(var(--u) * .8); }
.todo-add input {
  flex: 1; min-width: 0; min-height: max(44px, calc(var(--u) * 5)); padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font: inherit; font-size: max(16px, calc(var(--u) * 1.8)); font-weight: 400;
}
.todo-list { list-style: none; margin: 0; padding: 0; outline: none; }
.todo-list li { display: flex; align-items: stretch; border-top: 1px solid var(--line); min-width: 0; }
.todo-list li:first-child { border-top: 0; }
.todo-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: calc(var(--u) * 1.2); min-height: max(44px, calc(var(--u) * 5)); padding: 4px 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.todo-box { flex: none; display: grid; place-items: center; width: calc(var(--u) * 2.8); height: calc(var(--u) * 2.8); min-width: 22px; min-height: 22px; border: 2px solid var(--faint); border-radius: 7px; }
.todo-box .ic { width: 80%; height: 80%; stroke-width: 3; }
.todo-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-list .done .todo-text { text-decoration: line-through; color: var(--faint); }
.todo-list .done .todo-box { background: var(--good); border-color: var(--good); color: var(--card); }
.todo-del { flex: none; display: grid; place-items: center; width: 44px; min-height: 44px; border: 0; background: none; color: var(--faint); cursor: pointer; }
.todo-del .ic { width: 20px; height: 20px; }
.todo-empty { padding: calc(var(--u) * 1.6) 0; color: var(--faint); border-top: 0; }
@media (hover: hover) { .todo-del:hover { color: var(--bad); } }

/* 타이머 */
.timer-time { flex: 1; display: grid; place-items: center; padding: calc(var(--u) * 2) 0; font-size: calc(var(--u) * 11); font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.timer-time.end { color: var(--bad); }
.timer-row { display: flex; gap: 8px; margin-top: 8px; }

/* ---- 로그인·가입 신청 ---- */
.login-page main { padding-top: 8vh; }
.login-page main > * { max-width: 420px; margin-left: auto; margin-right: auto; }
.login-head { text-align: center; margin-bottom: 20px; display: grid; justify-items: center; gap: 6px; }
.login-head .brand-mark { border-radius: 14px; }
.login-head h1 { font-size: 26px; letter-spacing: .08em; }
.login-page .card { display: block; padding: 16px; border-radius: var(--radius); border: 0; font-size: 16px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg); margin-bottom: 16px; }
.tabs button { min-height: 44px; border: 0; border-radius: 9px; background: none; color: var(--dim); font: inherit; font-weight: 600; cursor: pointer; }
.tabs button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.form { display: grid; gap: 14px; }
.form label, .pw-field { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
.form label small { font-weight: 400; color: var(--dim); }
.form input {
  width: 100%; min-width: 0; min-height: 48px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font: inherit; font-size: 16px; font-weight: 400;
}
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 72px; }
.pw-eye { position: absolute; right: 2px; top: 50%; margin-top: -22px; min-width: 60px; min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--accent); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.msg { margin: 12px 0 0; font-size: 14px; color: var(--bad); }
.msg:empty { display: none; }
/* 터치 기기에서는 폭과 상관없이 입력칸 글자 16px 이상 (아이폰이 화면을 확대하지 않게. UX.md '6. 입력칸') */
@media (pointer: coarse) { input, select, textarea { font-size: 16px; } }

/* ==== 가로 화면 (바 모니터·휴대폰 가로·PC): 머리줄은 왼쪽 세로 줄로, 카드는 화면 높이를 다 쓰고 옆으로 넘긴다 ====
   내용 칸(.view) 하나만 스크롤되는 것은 같다: 세로 화면은 위아래, 가로 화면은 옆으로 */
@media (orientation: landscape) {
  body.main-page { flex-direction: row; --ak-rail-l: var(--rail); }
  .main-page .top {
    flex-direction: column; gap: 4px; width: calc(var(--rail) + var(--sa-l)); border-bottom: 0; border-right: 1px solid var(--line);
    padding: max(8px, env(safe-area-inset-top)) 6px max(8px, env(safe-area-inset-bottom)) calc(6px + var(--sa-l));
  }
  .main-page .brand-text, .main-page .top-text { display: none; }
  .main-page .brand { min-width: 44px; justify-content: center; }
  .main-page .top-btn { width: 44px; min-height: 44px; padding: 0; }
  .main-page .top-btn .count { position: absolute; top: 2px; right: 0; margin: 0; }
  .main-page .view {
    overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-padding-inline: var(--gap); scrollbar-width: none;
    /* 오른쪽 여백은 여기 두지 않는다: 옆으로 미는 칸은 끝 여백이 스크롤 끝에 붙지 않는다 → 카드 줄 끝의 빈 칸(.board::after)으로 준다 */
    --pr: max(var(--gap), var(--sa-r));
    padding: max(var(--gap), env(safe-area-inset-top)) 0 max(var(--gap), env(safe-area-inset-bottom)) var(--gap);
  }
  .main-page .view::-webkit-scrollbar { display: none; }
  .main-page .view.dragging { scroll-snap-type: none; cursor: grabbing; }
  .main-page #app { max-width: none; height: 100%; }
  /* 설치 안내는 가로 화면에서 카드 높이를 깎으므로 숨긴다 ('내 계정' 창에 설치 단추가 있다) */
  .main-page #app > .ak-install { display: none; }
  .main-page .board { display: flex; height: 100%; }
  .main-page .board::after { content: ""; flex: 0 0 var(--pr); margin-left: calc(var(--gap) * -1); }
  .main-page .card { flex: 0 0 calc((100% - var(--pr) - (var(--n) - 1) * var(--gap)) / var(--n)); scroll-snap-align: start; overflow: hidden; }
  .main-page .load-err, .main-page .board > .empty { margin: auto; }
  /* 할 일이 카드보다 길면 목록만 그 안에서 밀린다 */
  .main-page .todo-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: none; }
  .main-page .todo-list::-webkit-scrollbar { display: none; }
  .main-page .timer-time { padding: 0; }
}

/* ==== 휴대폰 가로 화면 (모든 서비스가 같은 조건. UX.md '5. 가로 모드 조건'): 로그인은 로고 왼쪽·카드 오른쪽 ==== */
@media (orientation: landscape) and (max-height: 520px) and (min-width: 560px) {
  .login-page main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 20px; align-items: start; padding-top: 16px; }
  .login-page main > * { max-width: 420px; margin: 0; width: 100%; }
  .login-head { margin-bottom: 0; justify-self: end; align-self: center; }
  .login-page .card { padding: 12px; }
  .login-page .tabs { margin-bottom: 10px; }
  .login-page .form { gap: 8px; }
  .login-page .form input { min-height: 44px; }
}
