/* 세계 시계 화면 스타일 — 모든 언어 페이지가 함께 쓴다 */
:root {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --text: #151a2d;
  --muted: #6a7089;
  --line: #e2e5ee;
  --primary: #2e408c;
  --primary-text: #ffffff;
  --accent: #ff6a3d;
  --danger: #d9434b;
  --shadow: 0 1px 2px rgba(21, 26, 45, .05), 0 8px 24px rgba(21, 26, 45, .06);

  /* 시계 문자판 (낮) */
  --face-day: #ffffff;
  --face-day-ring: #dfe3ee;
  --ink-day: #1a2140;
  --tick-day: #aab1c7;
  /* 시계 문자판 (밤) */
  --face-night: #1b2340;
  --face-night-ring: #2c3760;
  --ink-night: #eef1fa;
  --tick-night: #5d6a98;

  --radius: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d111c;
    --surface: #151b2b;
    --surface-2: #1b2235;
    --text: #eef1f8;
    --muted: #939ab3;
    --line: #252d44;
    --primary: #6f86ff;
    --primary-text: #0d111c;
    --danger: #ff6b72;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
    --face-day: #f4f6fb;
    --face-day-ring: #3a4466;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
/* 한자는 언어마다 글꼴 모양이 달라서 일본어 · 중국어는 그 언어 글꼴을 먼저 쓴다 */
html:lang(ja) body { font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, "Segoe UI", "Noto Sans JP", Roboto, sans-serif; }
html:lang(zh-Hant) body { font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Segoe UI", "Noto Sans TC", Roboto, sans-serif; }
html:lang(zh-Hans) body { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", "Noto Sans SC", Roboto, sans-serif; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }   /* .btn 등 display 지정 요소도 hidden 속성으로 숨김 */

.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 20px 40px; }

/* ---------- 헤더 ---------- */
header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; margin-right: auto; }
.brand img { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.brand h1 { font-size: 22px; line-height: 1.2; margin: 0; letter-spacing: -.02em; }
.brand p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
/* 버전 배지 - 값은 APP_VERSION 에서 채운다 (단일 출처) */
.brand .ver {
  display: inline-block; vertical-align: middle; margin-left: 6px;
  padding: 1px 7px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
  font-size: 11.5px; font-weight: 700; line-height: 1.5; letter-spacing: 0;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.brand .ver:empty { display: none; }

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

.seg {
  display: inline-flex; padding: 3px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
}
.seg button {
  border: 0; background: transparent; padding: 7px 12px; border-radius: 999px;
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface);
  padding: 9px 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: transform .1s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }
.count { font-variant-numeric: tabular-nums; opacity: .8; font-weight: 500; }
a.btn { text-decoration: none; }

/* ---------- 시간 맞추기 ---------- */
.planner {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 12px 16px 8px; margin-bottom: 18px;
}
.plan-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; min-height: 30px; }
.plan-head h2 { margin: 0; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.plan-head h2 svg { width: 16px; height: 16px; color: var(--primary); }
.plan-text { flex: 1 1 220px; min-width: 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.plan-reset { margin-left: auto; padding: 5px 12px; font-size: 13px; }
#planRange { display: block; width: 100%; margin: 8px 0 4px; accent-color: var(--primary); cursor: pointer; }
.planning .plan-text { color: var(--text); font-weight: 600; }
.planning .card { border-color: var(--primary); }
.planning .digital .sec, .planning .hand.sec { display: none; }   /* 옮겨 본 시각은 멈춰 있다 */

/* ---------- 카드 그리드 ---------- */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.card {
  position: relative;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 20px 18px;
  display: flex; flex-direction: column; align-items: center;
}
.card.new { animation: pop .25s ease; }
/* 순서 바꾸기 손잡이 — 카드 위 가운데 */
.grip {
  position: absolute; top: 1px; left: 50%; transform: translateX(-50%);
  width: 44px; height: 18px; padding: 0; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); opacity: .35;
  display: grid; place-items: center; cursor: grab; touch-action: none;
}
.grip svg { width: 22px; height: 11px; }
.card:hover .grip, .grip:focus-visible { opacity: 1; }
.grip:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
@media (hover: none) { .grip { opacity: .6; } }
.card.dragging { opacity: .55; outline: 2px dashed var(--primary); outline-offset: 2px; }
body.sorting, body.sorting * { cursor: grabbing !important; -webkit-user-select: none; user-select: none; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card-head { width: 100%; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.city { min-width: 0; }
.city h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.city .sub { margin-top: 2px; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.remove {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
}
.remove:hover:not(:disabled) { background: var(--surface-2); color: var(--danger); }
.remove:disabled { opacity: .3; cursor: not-allowed; }
.remove svg { width: 16px; height: 16px; }

.analog { width: min(100%, 210px); aspect-ratio: 1; margin: 14px 0 10px; }
.analog svg { width: 100%; height: 100%; display: block; overflow: visible; }

.face { fill: var(--face-day); stroke: var(--face-day-ring); stroke-width: 2; transition: fill .6s ease; }
.tick { stroke: var(--tick-day); stroke-linecap: round; }
.tick.major { stroke: var(--ink-day); }
.num { fill: var(--ink-day); font-size: 15px; font-weight: 600; text-anchor: middle; dominant-baseline: central; }
.hand { stroke: var(--ink-day); stroke-linecap: round; }
.hand.sec { stroke: var(--accent); }
.pin { fill: var(--accent); }
.pin-in { fill: var(--face-day); }

.card.night .face { fill: var(--face-night); stroke: var(--face-night-ring); }
.card.night .tick { stroke: var(--tick-night); }
.card.night .tick.major, .card.night .hand { stroke: var(--ink-night); }
.card.night .hand.sec { stroke: var(--accent); }
.card.night .num { fill: var(--ink-night); }
.card.night .pin-in { fill: var(--face-night); }

.digital {
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
  font-size: 38px; font-weight: 700; letter-spacing: -.02em; line-height: 1;
  display: flex; align-items: baseline; gap: 6px;
}
.digital .ampm { font-size: 15px; font-weight: 600; color: var(--muted); }
.digital .sec { font-size: 20px; font-weight: 600; color: var(--muted); }
.digital.ampm-after .ampm { order: 3; }   /* en · es · fr 은 3:05 PM */

.meta {
  margin-top: 12px; width: 100%;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
  border-top: 1px dashed var(--line); padding-top: 12px;
}
.meta .date { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.meta .date svg { width: 14px; height: 14px; }
.meta .diff { white-space: nowrap; font-variant-numeric: tabular-nums; }
.sun {
  margin-top: 8px; width: 100%; display: flex; justify-content: center; gap: 14px;
  font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.sun span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.sun svg { width: 15px; height: 15px; }
.sun .sunrise svg { color: var(--accent); }
.badge {
  font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--text);
}

footer { margin-top: 28px; text-align: center; font-size: 12px; color: var(--muted); }
footer p { margin: 0 0 6px; }
footer .about { max-width: 640px; margin: 10px auto; line-height: 1.6; }
footer .langs { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-top: 12px; }
footer .langs a { color: var(--muted); text-decoration: none; }
footer .langs a:hover { color: var(--text); text-decoration: underline; }
footer .langs a[aria-current] { color: var(--text); font-weight: 600; }

/* ---------- 언어 ---------- */
.lang-btn { padding: 9px 12px; }
.lang-tip {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 8px 12px 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 14px;
}
.lang-tip span { min-width: 0; line-height: 1.35; }
.lang-tip .btn { flex: none; padding: 6px 14px; font-size: 13px; white-space: nowrap; }
.lang-tip .remove { width: 28px; height: 28px; }
dialog.lang-dlg { width: min(360px, calc(100vw - 32px)); }
.lang-dlg .dlg-title { margin-bottom: 0; }
.lang-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.lang-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px; border-radius: 12px; color: var(--text); text-decoration: none; font-size: 15px; font-weight: 600;
}
.lang-item:hover, .lang-item:focus-visible { background: var(--surface-2); outline: none; }
.lang-item .code { font-size: 12px; color: var(--muted); }
.lang-item[aria-current] { color: var(--primary); }
.lang-item[aria-current] .code::before { content: "✓ "; }

/* ---------- 도시 추가 대화상자 ---------- */
dialog {
  width: min(520px, calc(100vw - 32px)); max-height: min(640px, calc(100vh - 48px));
  padding: 0; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(10, 14, 28, .45); backdrop-filter: blur(2px); }
.dlg-head { padding: 18px 18px 12px; border-bottom: 1px solid var(--line); }
.dlg-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dlg-title h3 { margin: 0; font-size: 17px; }
.search {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 15px; outline: none;
}
.search:focus { border-color: var(--primary); }
.results { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.results li button {
  width: 100%; text-align: left; border: 0; background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 12px; border-radius: 12px;
}
.results li button:hover:not(:disabled), .results li button:focus-visible { background: var(--surface-2); outline: none; }
.results li button:disabled { opacity: .45; cursor: default; }
.r-name { font-weight: 600; font-size: 15px; }
.r-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.r-time { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); white-space: nowrap; text-align: right; }
.r-section { font-size: 12px; color: var(--muted); padding: 10px 12px 4px; font-weight: 600; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- 설치 안내 대화상자 ---------- */
dialog.guide { width: min(420px, calc(100vw - 32px)); }
.guide-body { padding: 20px 20px 6px; overflow-y: auto; }
.guide-body h3 { margin: 0 0 12px; font-size: 17px; }
.guide-body p { margin: 0 0 10px; font-size: 14.5px; line-height: 1.55; }
.guide-url {
  font-size: 13px; padding: 8px 10px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  word-break: break-all; -webkit-user-select: all; user-select: all;
}
.steps { list-style: none; margin: 4px 0 10px; padding: 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; line-height: 1.5; }
.steps .no {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: var(--primary-text); font-size: 12px; font-weight: 700;
}
.ico { width: 17px; height: 17px; vertical-align: -3px; }
.guide-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px 8px; padding: 12px 20px 18px; }
.guide-mute {
  margin-right: auto; display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted); cursor: pointer; -webkit-user-select: none; user-select: none;
}
.guide-mute input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.guide-btns { display: flex; gap: 8px; margin-left: auto; }   /* 좁으면 버튼 묶음째 다음 줄로 */

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-size: 14px; transition: all .25s ease; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* 새 버전 알림 — 누를 때까지 남는다 */
.update {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 10; display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  padding: 7px 7px 7px 16px; border-radius: 999px; background: var(--text); color: var(--bg);
  font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.update .btn { padding: 6px 14px; font-size: 13px; white-space: nowrap; }

@media (max-width: 560px) {
  .wrap { padding: 18px 16px 32px; }
  header { margin-bottom: 18px; }
  .actions { width: 100%; }
  .actions .btn.primary { margin-left: auto; flex: 1 1 auto; justify-content: center; }   /* 남는 폭을 채움 — 줄이 넘어가도 어색하지 않게 */
  .lang-tip { font-size: 13px; }
  .brand { flex: 1 1 0; }   /* 언어 버튼과 같은 줄에 남도록 */
  #installBtn .label, .lang-btn .label { display: none; }
  #installBtn, .lang-btn { padding: 9px 11px; }
  .planner { padding: 10px 12px 6px; margin-bottom: 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .card { padding: 18px 12px 12px; }
  .sun { gap: 8px; margin-top: 6px; font-size: 11.5px; }
  .sun svg { width: 13px; height: 13px; }
  .city h2 { font-size: 15px; }
  .analog { margin: 8px 0 6px; }
  .num { display: none; }
  .digital { font-size: 26px; gap: 4px; }
  .digital .sec { font-size: 14px; }
  .digital .ampm { font-size: 12px; }
  .meta { flex-direction: column; align-items: center; gap: 4px; font-size: 12px; padding-top: 8px; margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .card.new { animation: none; }
}
