:root {
  --bg: #0D0D0F;
  --panel: rgba(255, 255, 255, .045);
  --panel-strong: rgba(255, 255, 255, .085);
  --border: rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .18);
  --brand: #DC3B2F;
  --muted2: #9BA3B4;
  --text: #F2F1EF;
  --muted: #8C8C93;
  --ok: #4FB980;
  --warn: #E0A83E;
  --r-card: 20px;
  --r-panel: 22px;
  --r-sheet: 28px;
  --shell: 480px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --glow-brand: 0 8px 26px rgba(220, 59, 47, .40), 0 0 0 1px rgba(220, 59, 47, .35);

  /* 테마별로 갈리는 표면·글자색 — 아래 [data-theme="light"] 에서 통째로 뒤집습니다 */
  --bg-top: #1E1E22;
  --header-bg: rgba(13, 13, 15, .86);
  --surface: #17171A;
  --surface-2: #1B1B1F;
  --surface-3: #1C1C20;
  --overlay: rgba(6, 6, 8, .7);
  --scrim: rgba(13, 13, 15, .74);
  --glass: rgba(255, 255, 255, .10);
  --hover: rgba(255, 255, 255, .07);
  --soft: rgba(255, 255, 255, .075);
  --soft-strong: rgba(255, 255, 255, .12);
  --soft-border: rgba(255, 255, 255, .16);
  --placeholder: #62626B;
  --code-bg: #08080A;
  --code-text: #A2A2AC;
  --invert-bg: #F2F1EF;
  --invert-text: #17171A;
  --av-bg: #2B2B30;
  --thumb-icon: #45454E;
  --lb-bg: #08080A;
  --lb-scrim: rgba(8, 8, 10, .88);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, .4);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, .55);
  --toast-shadow: 0 10px 34px rgba(0, 0, 0, .5);
  --dialog-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}

/* ---------- 라이트 모드 ---------- */
:root[data-theme="light"] {
  --bg: #F5F4F2;
  --bg-top: #FFFFFF;
  --panel: rgba(23, 23, 26, .035);
  --panel-strong: rgba(23, 23, 26, .07);
  --border: rgba(23, 23, 26, .11);
  --border-strong: rgba(23, 23, 26, .22);
  --brand: #C4301F;
  --muted2: #5A6172;
  --text: #17171A;
  --muted: #63636C;
  --ok: #1F7A4D;
  --warn: #97671A;

  --header-bg: rgba(245, 244, 242, .88);
  --surface: #FFFFFF;
  --surface-2: #FFFFFF;
  --surface-3: #E7E5E2;
  --overlay: rgba(28, 28, 32, .42);
  --scrim: rgba(255, 255, 255, .84);
  --glass: rgba(23, 23, 26, .07);
  --hover: rgba(23, 23, 26, .05);
  --soft: rgba(23, 23, 26, .05);
  --soft-strong: rgba(23, 23, 26, .10);
  --soft-border: rgba(23, 23, 26, .16);
  --placeholder: #9A9AA3;
  --code-bg: #F0EEEB;
  --code-text: #55555E;
  --invert-bg: #17171A;
  --invert-text: #F2F1EF;
  --av-bg: #DFDDD9;
  --thumb-icon: #B2AFAA;
  --lb-bg: #EDEBE8;
  --lb-scrim: rgba(237, 235, 232, .92);
  --shadow-sm: 0 4px 16px rgba(23, 23, 26, .14);
  --shadow-lg: 0 18px 44px rgba(23, 23, 26, .16);
  --toast-shadow: 0 10px 34px rgba(23, 23, 26, .22);
  --dialog-shadow: 0 30px 80px rgba(23, 23, 26, .20);
  --glow-brand: 0 8px 26px rgba(196, 48, 31, .32), 0 0 0 1px rgba(196, 48, 31, .28);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  background: var(--bg);
  font: 15px/1.62 "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
        "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-feature-settings: "ss01", "cv01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  word-break: keep-all;
  -webkit-text-size-adjust: 100%;
  letter-spacing: -.015em;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: none;
}

/* 배경 그라디언트는 고정 레이어로 분리 — iOS 의 background-attachment:fixed 스크롤 버그 회피 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(1200px 620px at 50% -220px, var(--bg-top) 0%, var(--bg) 100%);
}

/* 모달이 열려 있는 동안에만 본문 스크롤 잠금 */
body.locked { overflow: hidden; }

.wrap { max-width: var(--shell); margin: 0 auto; padding: 0 16px 120px; }

/* ---------- 헤더 ---------- */
header.top { position: sticky; top: 0; z-index: 20; background: var(--header-bg); backdrop-filter: blur(14px); }
header.top .bar {
  max-width: var(--shell); margin: 0 auto; padding: 16px 16px 12px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; row-gap: 6px;
}
header.top h1 { flex: 0 1 auto; min-width: 0; }
.owner { flex: none; }
header.top h1 { font-size: 19px; margin: 0; font-weight: 800; letter-spacing: -.03em; }
header.top .spacer { flex: 1; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 12px 2px rgba(220, 59, 47, .8); flex: none; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .18em; color: var(--muted); text-transform: uppercase; }

.badge {
  font-size: 10.5px; font-weight: 800; letter-spacing: .04em; padding: 4px 9px; border-radius: 999px;
  background: rgba(220, 59, 47, .16); color: var(--brand); border: 1px solid rgba(220, 59, 47, .3);
}
.badge.ghost { background: var(--panel); color: var(--muted); border-color: var(--border); }

/* ---------- 세그먼트 탭 ---------- */
.tabs {
  display: flex; gap: 4px; max-width: var(--shell); margin: 0 auto; padding: 0 16px 14px;
}
.tabs .seg {
  display: flex; gap: 4px; width: 100%; padding: 4px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
}
.tabs button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: 9px 6px; border-radius: 10px; font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: background .15s, color .15s;
}
.tabs button[aria-selected="true"] { background: var(--invert-bg); color: var(--invert-text); }

/* ---------- 폼 요소 ---------- */
input, select, textarea {
  width: 100%; padding: 13px 15px; border: 1px solid var(--border); border-radius: 15px;
  background: var(--panel); color: var(--text); font: inherit; font-size: 15px;
}
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: rgba(220, 59, 47, .55); background: var(--panel-strong);
  box-shadow: 0 0 0 3px rgba(220, 59, 47, .13);
}
/* 실제 select 는 값 보관용으로만 두고 화면에서는 감춥니다 */
.sel select { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
textarea { min-height: 96px; resize: vertical; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12.5px; font-weight: 600; letter-spacing: -.01em; color: var(--muted); margin-bottom: 8px; }
input[type="file"] { padding: 10px 12px; font-size: 13px; color: var(--muted); }
input[type="file"]::file-selector-button {
  border: 1px solid var(--border); background: var(--panel-strong); color: var(--text);
  padding: 7px 12px; border-radius: 9px; font: inherit; font-size: 13px; font-weight: 700; margin-right: 10px; cursor: pointer;
}

button, .btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 12px 17px; border-radius: 15px; font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .1s, background .15s, opacity .15s;
}
button:active, .btn:active { transform: scale(.975); }
button.primary { background: var(--brand); border-color: transparent; color: #fff; box-shadow: 0 6px 20px rgba(220, 59, 47, .3); }
button.secondary { background: var(--soft); border-color: var(--soft-border); color: var(--text); }
button.ghost { background: var(--panel); color: var(--text); }
button.danger { background: rgba(220, 59, 47, .1); border-color: rgba(220, 59, 47, .32); color: var(--brand); }
button.sm { padding: 8px 12px; font-size: 12.5px; border-radius: 10px; }
button:disabled { opacity: .45; cursor: not-allowed; }

.toolbar { display: flex; gap: 8px; align-items: center; margin: 4px 0 14px; }
.toolbar input[type="search"] { flex: 1; }
.toolbar select { width: auto; flex: none; font-size: 13.5px; padding: 12px 32px 12px 13px; }

/* ---------- BJ 카드 그리드 ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  padding: 0; border: 1px solid var(--border); background: var(--panel); border-radius: var(--r-card);
  overflow: hidden; display: block; text-align: left; width: 100%;
}
.card .thumb {
  position: relative; aspect-ratio: 1 / 1; background: var(--surface-3) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; font-size: 34px; color: var(--thumb-icon);
}
.card .thumb::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(8, 8, 10, .38) 0%, transparent 40%);
}
.badge-exp {
  position: absolute; top: 8px; left: 8px; z-index: 1;
  font-size: 10px; font-weight: 800; letter-spacing: .02em; padding: 4px 8px; border-radius: 999px;
  background: var(--brand); color: #fff; box-shadow: 0 3px 10px rgba(220, 59, 47, .45);
}
.badge-exp.new { background: var(--scrim); color: var(--text); border: 1px solid var(--border-strong); box-shadow: none; backdrop-filter: blur(6px); }
.card .meta { padding: 10px 11px 12px; }
.card .nm { font-weight: 800; font-size: 14.5px; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .age { color: var(--muted); font-size: 12px; margin-top: 2px; }

.empty { text-align: center; color: var(--muted); padding: 56px 16px; font-size: 13.5px; line-height: 1.7; }
.hint { color: var(--muted); font-size: 12.5px; }
.err { color: var(--brand); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; z-index: 30;
  bottom: calc(22px + env(safe-area-inset-bottom));
  right: max(18px, calc(50% - var(--shell) / 2 + 18px));
  width: 58px; height: 58px; border-radius: 50%; padding: 0;
  background: var(--brand); border: 0; color: #fff; font-size: 28px; font-weight: 400; line-height: 1;
  box-shadow: var(--glow-brand);
}

/* ---------- 바텀시트 ---------- */
.modal[hidden] { display: none !important; }
.modal {
  position: fixed; inset: 0; z-index: 50; background: var(--overlay);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal .sheet {
  width: 100%; max-width: var(--shell); max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-bottom: 0;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  padding: 10px 18px calc(30px + env(safe-area-inset-bottom));
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  animation: sheetUp .26s cubic-bezier(.22, .9, .3, 1);
}
@keyframes sheetUp { from { transform: translateY(6%); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet .grip { width: 40px; height: 4px; border-radius: 99px; background: var(--border-strong); margin: 4px auto 16px; }
.sheet h2 { margin: 0 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -.03em; }
.sheet .sub { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }

.photos {
  display: flex; gap: 10px; overflow-x: auto; margin: 16px -18px 4px; padding: 0 18px 4px;
  scroll-snap-type: x mandatory; scrollbar-width: none;
}
.photos::-webkit-scrollbar { display: none; }
.photos img {
  width: 78%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 16px; flex: 0 0 auto;
  scroll-snap-align: center; background: var(--surface-3); border: 1px solid var(--border);
}
/* ---------- 사진 캐러셀 ---------- */
.carousel { position: relative; margin: 16px 0 4px; }
.carousel .photos { margin: 0 -18px; padding: 0 18px 4px; }
.carousel .nav {
  position: absolute; top: calc(50% - 26px); transform: translateY(-50%);
  width: 38px; height: 38px; padding: 0; border-radius: 50%;
  background: var(--scrim); border: 1px solid var(--border-strong);
  color: var(--text); font-size: 22px; line-height: 1; backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm); z-index: 2;
}
.carousel .nav.prev { left: 6px; padding-right: 3px; }
.carousel .nav.next { right: 6px; padding-left: 3px; }
.carousel .nav:disabled { opacity: .28; }
.carousel.single .nav, .carousel.single .dots, .carousel.single .counter { display: none; }

.carousel .dots { display: flex; justify-content: center; gap: 7px; margin-top: 12px; }
.carousel .dot-btn {
  width: 7px; height: 7px; padding: 0; border-radius: 50%; border: 0;
  background: var(--border-strong); transition: background .18s, width .18s;
}
.carousel .dot-btn.on { background: var(--brand); width: 20px; border-radius: 99px; }

.carousel .counter {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  background: var(--scrim); border: 1px solid var(--border);
  color: var(--text); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 4px 10px; border-radius: 999px; backdrop-filter: blur(8px);
}

.kv { display: grid; grid-template-columns: 82px 1fr; gap: 10px 12px; font-size: 14px; margin: 18px 0 0; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.stamp {
  color: var(--muted); font-size: 11.5px; margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--border); display: flex; gap: 12px; flex-wrap: wrap;
}
.sheet-acts { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.sheet-acts button { flex: 1 1 104px; }

.pill { font-size: 10.5px; font-weight: 800; padding: 3px 9px; border-radius: 999px; }
.pill.yes { background: rgba(220, 59, 47, .16); color: var(--brand); border: 1px solid rgba(220, 59, 47, .3); }
.pill.no { background: var(--panel); color: var(--muted); border: 1px solid var(--border); }

/* ---------- 링크 / 로그 ---------- */
.list { display: flex; flex-direction: column; gap: 12px; }
.row { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-panel); padding: 15px; }
.row .head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row .title { font-weight: 800; font-size: 15px; letter-spacing: -.02em; }
.row .url {
  font-family: var(--mono); font-size: 11px; color: var(--code-text); line-height: 1.5;
  word-break: break-all; margin-top: 11px; background: var(--code-bg);
  border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px;
}
.row .memo-input { margin-top: 10px; font-size: 14px; padding: 10px 13px; }
.row .acts { display: flex; gap: 7px; margin-top: 11px; flex-wrap: wrap; }
.row .acts button { flex: 1; min-width: 88px; }
.row .foot { margin-top: 11px; font-size: 11.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }

.tag { font-size: 10.5px; font-weight: 800; padding: 4px 9px; border-radius: 999px; border: 1px solid transparent; }
.tag.unlimited { background: var(--hover); color: var(--text); border-color: var(--soft-border); }
.tag.onetime { background: rgba(224, 168, 62, .14); color: var(--warn); border-color: rgba(224, 168, 62, .3); }
.tag.live { background: rgba(79, 185, 128, .15); color: var(--ok); border-color: rgba(79, 185, 128, .32); }
.tag.spent { background: rgba(224, 168, 62, .14); color: var(--warn); border-color: rgba(224, 168, 62, .3); }
.tag.dead { background: var(--panel); color: var(--muted); border-color: var(--border); }
.tag.blocked { background: rgba(220, 59, 47, .14); color: var(--brand); border-color: rgba(220, 59, 47, .3); }
.tag.ok { background: rgba(79, 185, 128, .15); color: var(--ok); border-color: rgba(79, 185, 128, .32); }

.log {
  display: flex; gap: 9px; align-items: center; flex-wrap: wrap; font-size: 13px;
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; margin-bottom: 8px;
}
.log .when { color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: -.02em; }
.log .who { font-weight: 700; font-size: 13px; }

/* ---------- 사진 썸네일 (등록 폼) ---------- */
.thumbs { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 10px; }
.thumbs figure { margin: 0; position: relative; }
.thumbs img { width: 76px; height: 76px; object-fit: cover; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-3); }
.thumbs button {
  position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; border-radius: 50%;
  padding: 0; background: var(--brand); color: #fff; border: 2px solid var(--surface); font-size: 13px; line-height: 1;
}

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--invert-bg); color: var(--invert-text); padding: 12px 20px; border-radius: 999px;
  font-size: 13px; font-weight: 700; z-index: 80; box-shadow: var(--toast-shadow);
  max-width: calc(100% - 36px); text-align: center;
}
.toast[hidden] { display: none; }

/* ---------- 로그인 / 안내 화면 ---------- */
.console {
  max-width: var(--shell); margin: 0 auto; padding: 22vh 22px 40px;
}
.console .mark { display: flex; align-items: center; gap: 9px; margin-bottom: 20px; }
.console h1 { font-size: 30px; line-height: 1.22; font-weight: 800; letter-spacing: -.045em; margin: 0 0 10px; }
.console p.lead { color: var(--muted); font-size: 14px; margin: 0 0 30px; }
.console form, .console .panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-panel); padding: 20px;
}
.console button[type="submit"] { width: 100%; padding: 14px; font-size: 15px; }

/* =========================================================
   반응형 — 태블릿(≥768px) / 데스크톱(≥1100px)
   모바일 레이아웃은 위 기본 스타일을 그대로 사용합니다.
   ========================================================= */

.fab-label { display: none; }

@media (hover: hover) and (pointer: fine) {
  button:hover, .btn:hover { background: var(--panel-strong); }
  button.primary:hover { background: #E75345; box-shadow: 0 8px 26px rgba(220, 59, 47, .42); }
  /* 라이트 모드에선 밝아지는 대신 짙어져야 흰 글씨가 계속 읽힙니다 */
  :root[data-theme="light"] button.primary:hover { background: #A82718; box-shadow: 0 8px 26px rgba(196, 48, 31, .34); }
  :root[data-theme="light"] .fab:hover { background: #A82718; }
  button.secondary:hover { background: var(--soft-strong); }
  button.danger:hover { background: rgba(220, 59, 47, .18); }
  .tabs button:hover { color: var(--text); }
  .tabs button[aria-selected="true"]:hover { background: var(--invert-bg); color: var(--invert-text); }
  .card { transition: transform .16s ease, border-color .16s ease; }
  .card:hover { transform: translateY(-3px); border-color: var(--border-strong); }
  .fab:hover { background: #E75345; }
  .log:hover { border-color: var(--border-strong); }
}

/* ---------- 태블릿 이상 ---------- */
@media (min-width: 768px) {
  :root { --shell: 720px; }

  .wrap { padding: 0 24px 90px; }
  header.top .bar { padding: 22px 24px 14px; }
  header.top h1 { font-size: 22px; }
  .tabs { padding: 0 24px 18px; }
  .tabs .seg { width: auto; max-width: 380px; }
  .tabs button { padding: 9px 20px; }

  .toolbar { gap: 10px; margin-bottom: 18px; }
  .toolbar input[type="search"] { max-width: 320px; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }

  /* 바텀시트 → 가운데 다이얼로그 */
  .modal { align-items: center; padding: 28px 20px; }
  .modal .sheet {
    max-width: 620px; max-height: 86vh; max-height: 86dvh; border-radius: var(--r-sheet);
    border-bottom: 1px solid var(--border); padding: 24px 26px 28px;
    box-shadow: var(--dialog-shadow);
    animation: dialogIn .2s cubic-bezier(.22, .9, .3, 1);
  }
  @keyframes dialogIn { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
  .sheet .grip { display: none; }
  .sheet h2 { font-size: 24px; }
  .carousel { margin: 18px 0 4px; }
  .carousel .photos { margin: 0; padding: 0 0 4px; }
  .carousel .nav { width: 42px; height: 42px; font-size: 24px; }
  .carousel .nav.prev { left: 10px; }
  .carousel .nav.next { right: 10px; }
  .photos img { width: 46%; border-radius: 18px; }
  .sheet-acts { justify-content: flex-end; }
  .sheet-acts button { flex: 0 0 auto; min-width: 116px; }

  /* FAB → 라벨이 있는 알약 버튼 */
  .fab {
    width: auto; height: 52px; border-radius: 999px; padding: 0 24px;
    gap: 8px; font-size: 15px; font-weight: 800; bottom: calc(28px + env(safe-area-inset-bottom));
  }
  .fab-plus { font-size: 21px; font-weight: 400; line-height: 1; }
  .fab-label { display: inline; }

  .console { padding: 0 24px; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; }
  .console > * { width: 100%; max-width: 420px; margin-left: auto; margin-right: auto; }
  .console h1 { font-size: 36px; }
}

/* ---------- 데스크톱 ---------- */
@media (min-width: 1100px) {
  :root { --shell: 1080px; }

  .wrap { padding: 0 32px 110px; }
  header.top .bar { padding: 26px 32px 16px; gap: 11px; }
  header.top h1 { font-size: 24px; }
  .tabs { padding: 0 32px 22px; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
  .card .meta { padding: 13px 14px 15px; }
  .card .nm { font-size: 15.5px; }
  .card .age { font-size: 12.5px; }

  /* 링크 카드 2열 */
  .list { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-content: start; }
  .row { padding: 18px; }
  .row .url { font-size: 11.5px; }

  /* 로그는 한 줄에 넉넉하게 */
  .log { padding: 14px 18px; gap: 12px; }
  .log .when { font-size: 12px; }
  .log .who { font-size: 13.5px; }

  .console { padding: 0 32px; }
  .console > * { max-width: 440px; }
  .console h1 { font-size: 42px; }
  .console p.lead { font-size: 15px; }

  .toast { bottom: 34px; font-size: 13.5px; }
}

/* ---------- 와이드 데스크톱 ---------- */
@media (min-width: 1500px) {
  :root { --shell: 1240px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* ---------- 상단 통계 ---------- */
.stats { display: flex; gap: 8px; margin: 2px 0 14px; }
.stat {
  flex: 1; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 13px 12px; text-align: center;
}
.stat .num { display: block; font-size: 22px; font-weight: 800; letter-spacing: -.04em; line-height: 1.15; }
.stat .lbl { display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin-top: 3px; }
.stat.lead { background: rgba(220, 59, 47, .12); border-color: rgba(220, 59, 47, .3); }
.stat.lead .num { color: var(--brand); }
.stat.lead .lbl { color: var(--brand); opacity: .85; }

.tag.scope { background: rgba(79, 185, 128, .15); color: var(--ok); border-color: rgba(79, 185, 128, .32); }

@media (min-width: 768px) {
  .stats { gap: 12px; max-width: 520px; }
  .stat { padding: 16px 14px; }
  .stat .num { font-size: 26px; }
}

/* ---------- 월 달력 ---------- */
.cal { margin-bottom: 8px; }
.cal-head { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.cal-head button { padding: 7px 12px; font-size: 16px; line-height: 1; }
.cal-title {
  font-size: 17px; font-weight: 800; letter-spacing: -.03em;
  display: flex; align-items: baseline; gap: 8px; margin: 0 2px;
}
.cal-sub { font-size: 11.5px; font-weight: 700; color: var(--brand); }
.cal-head .cal-today { margin-left: auto; font-size: 12.5px; padding: 7px 13px; }

.cal-week {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 6px;
}
.cal-week span {
  text-align: center; font-size: 11px; font-weight: 800; color: var(--muted); padding: 2px 0;
}
.cal-week .sun, .cal-day .d.sun { color: var(--brand); }
.cal-week .sat, .cal-day .d.sat { color: var(--muted2); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day {
  min-height: 74px; padding: 5px 4px 4px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 3px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.cal-day.out { background: transparent; border-color: transparent; cursor: default; min-height: 0; }
.cal-day.today { border-color: var(--brand); background: rgba(220, 59, 47, .09); }
.cal-day.has { background: var(--panel-strong); }
.cal-day .d { font-size: 11.5px; font-weight: 800; color: var(--text); padding-left: 2px; line-height: 1.2; }
.cal-day.today .d { color: var(--brand); }

.chips { display: flex; flex-direction: column; gap: 3px; }
.chip {
  display: flex; align-items: center; gap: 4px; width: 100%;
  padding: 2px 4px 2px 2px; border-radius: 8px; border: 0;
  background: rgba(220, 59, 47, .16); overflow: hidden; justify-content: flex-start;
}
.chip .t {
  font-family: var(--mono); font-size: 9.5px; font-weight: 700; color: var(--brand);
  letter-spacing: -.05em; white-space: nowrap;
}
.av {
  width: 18px; height: 18px; border-radius: 50%; object-fit: cover; flex: none;
  background: var(--av-bg); display: inline-flex; align-items: center; justify-content: center;
  font-size: 9.5px; font-weight: 800; color: var(--text);
}
.av.ph { border: 1px solid var(--border-strong); }
.more {
  border: 0; background: transparent; color: var(--muted);
  font-size: 10px; font-weight: 800; padding: 1px 4px; justify-content: flex-start;
}

/* 하루치 목록 */
.day-list { display: flex; flex-direction: column; gap: 8px; margin: 16px 0 4px; }
.day-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: 14px; background: var(--panel);
  border: 1px solid var(--border); border-left: 3px solid var(--brand);
}
.av.lg { width: 40px; height: 40px; border-radius: 12px; font-size: 15px; }
.day-row .col { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.day-row .nm { font-size: 14.5px; font-weight: 800; letter-spacing: -.02em; }
.day-row .tx { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-row .tm {
  font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--brand);
  font-variant-numeric: tabular-nums; flex: none;
}

.sec-title {
  margin: 22px 0 -4px; font-size: 11px; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
}

@media (min-width: 768px) {
  .cal-title { font-size: 20px; }
  .cal-grid { gap: 6px; }
  .cal-week { gap: 6px; }
  .cal-day { min-height: 104px; padding: 7px 6px 6px; border-radius: 14px; }
  .cal-day .d { font-size: 13px; }
  .chip { gap: 6px; padding: 3px 7px 3px 3px; border-radius: 10px; }
  .chip .t { font-size: 11px; }
  .av { width: 22px; height: 22px; font-size: 11px; }
  .more { font-size: 11px; }
}
@media (min-width: 1100px) {
  .cal-day { min-height: 128px; }
  .av { width: 26px; height: 26px; }
  .chip .t { font-size: 11.5px; }
}

/* ---------- 전체화면 사진 뷰어 ---------- */
.photos img { cursor: zoom-in; }

.lightbox[hidden] { display: none !important; }
.lightbox {
  position: fixed; inset: 0; z-index: 90;
  background: var(--lb-bg);
  display: flex; flex-direction: column;
}
.lb-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(to bottom, var(--lb-scrim), transparent);
}
.lb-count {
  font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
  background: var(--glass); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 999px;
}
.lightbox.single .lb-count, .lightbox.single .lb-nav { display: none; }
.lb-close {
  width: 38px; height: 38px; padding: 0; border-radius: 50%;
  background: var(--glass); border: 1px solid var(--border);
  color: var(--text); font-size: 15px;
}

.lb-track {
  flex: 1; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scrollbar-width: none;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.lb-track::-webkit-scrollbar { display: none; }
.lb-track figure {
  margin: 0; flex: 0 0 100%; width: 100%; height: 100%;
  scroll-snap-align: center; display: flex; align-items: center; justify-content: center;
  padding: 58px 12px calc(28px + env(safe-area-inset-bottom));
}
.lb-track img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 6px; cursor: zoom-out;
}

.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 44px; height: 44px; padding: 0; border-radius: 50%;
  background: var(--glass); border: 1px solid var(--border);
  color: var(--text); font-size: 26px; line-height: 1;
}
.lb-nav.prev { left: 10px; padding-right: 3px; }
.lb-nav.next { right: 10px; padding-left: 3px; }
.lb-nav:disabled { opacity: .25; }

@media (min-width: 768px) {
  .lb-track figure { padding: 72px 60px 40px; }
  .lb-nav { width: 52px; height: 52px; font-size: 30px; }
  .lb-nav.prev { left: 18px; }
  .lb-nav.next { right: 18px; }
}

/* ---------- 이데아레이블 브랜드 헤더 ---------- */
.logo { height: 19px; width: auto; display: block; }
.logo.lg { height: 26px; }

header.top .brandrow {
  max-width: var(--shell); margin: 0 auto;
  padding: 15px 16px 0; display: flex; align-items: center; gap: 10px;
}
header.top .bar { padding: 11px 16px 12px; }
header.top h1 { font-size: 16.5px; font-weight: 800; }
.owner { color: var(--muted); font-size: 14px; font-weight: 700; letter-spacing: -.02em; }

.console .brandmark { margin-bottom: 26px; }
.console .brandmark .logo { height: 30px; }

@media (min-width: 768px) {
  .logo { height: 22px; }
  header.top .brandrow { padding: 22px 24px 0; }
  header.top .bar { padding: 12px 24px 14px; }
  header.top h1 { font-size: 20px; }
  .owner { font-size: 15px; }
  .console .brandmark .logo { height: 34px; }
}
@media (min-width: 1100px) {
  header.top .brandrow { padding: 26px 32px 0; }
  header.top .bar { padding: 14px 32px 16px; }
  header.top h1 { font-size: 22px; }
}

/* ---------- 커스텀 셀렉트 ---------- */
.sel { position: relative; }
.sel-btn {
  width: 100%; justify-content: space-between; gap: 10px;
  padding: 13px 15px; border-radius: 15px; font-weight: 500; font-size: 15px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  transition: border-color .16s ease, background .16s ease;
}
.sel-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-btn .caret {
  width: 9px; height: 9px; flex: none; margin-right: 2px;
  border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted);
  border-radius: 1px; transform: translateY(-2px) rotate(45deg);
  transition: transform .2s ease;
}
.sel.open .sel-btn { border-color: rgba(220, 59, 47, .5); background: var(--panel-strong); }
.sel.open .sel-btn .caret { transform: translateY(1px) rotate(-135deg); }

.sel-menu[hidden] { display: none; }
.sel-menu {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; right: 0;
  max-height: 244px; overflow-y: auto; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 16px; box-shadow: var(--shadow-lg);
  animation: selIn .16s ease;
  overscroll-behavior: contain;
}
@keyframes selIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.sel-opt {
  width: 100%; justify-content: space-between; gap: 10px;
  padding: 11px 13px; border-radius: 11px; border: 0; background: transparent;
  color: var(--text); font-size: 14.5px; font-weight: 500; text-align: left;
}
.sel-opt span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-opt .tick { color: var(--brand); font-size: 13px; opacity: 0; flex: none; }
.sel-opt.on { background: rgba(220, 59, 47, .13); color: var(--text); font-weight: 600; }
.sel-opt.on .tick { opacity: 1; }

.toolbar .sel { flex: none; min-width: 132px; }
.toolbar .sel-btn { padding: 13px 15px; font-size: 14px; }

@media (hover: hover) and (pointer: fine) {
  .sel-btn:hover { background: var(--panel-strong); border-color: var(--border-strong); }
  .sel-opt:hover { background: var(--hover); }
  .sel-opt.on:hover { background: rgba(220, 59, 47, .18); }
}

/* ---------- 모바일 터치 환경 ---------- */
@media (pointer: coarse) {
  /* iOS 사파리는 16px 미만 입력에 포커스하면 화면을 자동 확대합니다 */
  input, textarea, .sel-btn, .toolbar .sel-btn, .sel-opt { font-size: 16px; }
  /* 손가락으로 누를 수 있는 최소 크기 확보 */
  button.sm { min-height: 40px; }
  .row .acts button { min-height: 42px; }
  .sel-opt { padding: 13px 13px; }
  .card, .meet-card, .day-row, .chip, .cal-day { touch-action: manipulation; }
}

/* 좁은 화면(≈430px 이하)에서는 달력 칩을 세로로 쌓아 시간이 잘리지 않게 */
@media (max-width: 430px) {
  .cal-day { min-height: 86px; padding: 5px 3px 5px; }
  .chips { gap: 4px; }
  .chip {
    flex-direction: column; align-items: center; justify-content: center;
    gap: 1px; padding: 3px 2px; border-radius: 9px;
  }
  .chip .t { font-size: 9px; letter-spacing: -.06em; }
  .av { width: 20px; height: 20px; font-size: 10px; }
  .more { align-self: center; font-size: 9.5px; padding: 0 2px; }
  .cal-grid, .cal-week { gap: 3px; }
}

/* ---------- 라이트/다크 전환 버튼 ---------- */
header.top .brandrow { justify-content: space-between; }
.console .brandmark { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.theme-toggle {
  flex: none; gap: 6px; padding: 8px 14px 8px 11px; border-radius: 999px;
  background: var(--panel-strong); border: 1px solid var(--border-strong); color: var(--text);
  font-size: 12.5px; font-weight: 800; letter-spacing: -.02em; line-height: 1;
  transition: background .16s ease, border-color .16s ease, transform .1s;
}
.theme-toggle svg { width: 15px; height: 15px; display: block; flex: none; }
.theme-toggle .lbl { white-space: nowrap; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="light"] .theme-toggle .i-moon { display: block; }
:root[data-theme="light"] .theme-toggle .i-sun { display: none; }

@media (hover: hover) and (pointer: fine) {
  .theme-toggle:hover { background: var(--soft-strong); border-color: var(--brand); }
}
@media (pointer: coarse) {
  .theme-toggle { min-height: 40px; }
}
@media (min-width: 768px) {
  .theme-toggle { padding: 9px 16px 9px 13px; font-size: 13px; }
  .theme-toggle svg { width: 16px; height: 16px; }
}

/* ---------- 일정 옮기기 (드래그 & 이동 시트) ---------- */
.cal-hint {
  margin: 12px 2px 0; font-size: 11.5px; line-height: 1.55; color: var(--muted);
}
.cal.movable .chip { cursor: grab; }
.cal.movable .chip.dragging { opacity: .3; }

/* 드래그 중에는 글자가 잡히거나 화면이 딸려 움직이지 않게 */
body.dragging-meet { cursor: grabbing; user-select: none; -webkit-user-select: none; }
body.dragging-meet .cal.movable .chip { cursor: grabbing; }

.cal-day.drop {
  border-color: var(--brand);
  background: rgba(220, 59, 47, .16);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 95; pointer-events: none;
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 5px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--brand);
  box-shadow: var(--shadow-lg); will-change: transform;
  font-size: 12.5px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap;
}
.drag-ghost .t {
  font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--brand);
  font-variant-numeric: tabular-nums;
}
.drag-ghost .n { max-width: 132px; overflow: hidden; text-overflow: ellipsis; }

.move-now {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--border);
}
.move-now .lbl { font-size: 11.5px; font-weight: 800; letter-spacing: .06em; color: var(--muted); flex: none; }
.move-now .val { font-size: 13.5px; font-weight: 700; letter-spacing: -.02em; text-align: right; }

.move-quick { display: flex; gap: 6px; margin: 12px 0 0; }
.move-quick button { flex: 1; padding: 9px 6px; font-size: 12.5px; border-radius: 11px; }

/* ---------- 스케줄 표 (미팅 전용 링크 화면) ---------- */
.sched {
  margin-top: 12px; border: 1px solid var(--border); border-radius: var(--r-panel);
  overflow: hidden; background: var(--panel);
}
.sched-table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.sched-table th {
  text-align: left; padding: 10px 12px; background: var(--panel-strong);
  border-bottom: 1px solid var(--border);
  font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.sched-table td { padding: 11px 12px; border-top: 1px solid var(--border); vertical-align: middle; overflow: hidden; }
.sched-table tbody tr:first-child td { border-top: 0; }
.sched-table tbody.past tr:first-child td { border-top: 1px solid var(--border); }
.sched-table tr[data-mid] { cursor: pointer; }

.sched-table .dt, .sched-table th:first-child { width: 74px; }
.sched-table .tm, .sched-table th:nth-child(2) { width: 62px; }
.sched-table .dt { white-space: nowrap; }
.sched-table .dt b { font-size: 14px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.sched-table .dt span { font-size: 11px; font-weight: 700; color: var(--muted); margin-left: 4px; }
.sched-table .tm {
  font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--brand);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.sched-table .nm { display: block; font-size: 14px; font-weight: 800; letter-spacing: -.02em; }
.sched-table .tx {
  display: block; font-size: 12px; color: var(--muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sched-table tr.today td { background: rgba(220, 59, 47, .1); }
.sched-table tr.today .dt b { color: var(--brand); }
.sched-table tbody.past td { opacity: .55; }
.sched-table tr.none td { padding: 26px 12px; text-align: center; color: var(--muted); font-size: 13px; }

.sched-more {
  width: 100%; padding: 12px; border: 0; border-top: 1px solid var(--border); border-radius: 0;
  background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 700;
}

@media (hover: hover) and (pointer: fine) {
  .sched-table tr[data-mid]:hover td { background: var(--hover); }
  .sched-more:hover { background: var(--hover); color: var(--text); }
}
@media (min-width: 768px) {
  .sched-table .dt, .sched-table th:first-child { width: 96px; }
  .sched-table .tm, .sched-table th:nth-child(2) { width: 76px; }
  .sched-table td { padding: 13px 16px; }
  .sched-table th { padding: 11px 16px; }
}
