/* 재사용 부품: 카드, 버튼, 배지, 입력 묶음, 표, 알림 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px 14px;
  box-shadow: var(--shadow);
  min-width: 0;
  display: flex; flex-direction: column; gap: 10px;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap;
  padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.card-head > div { min-width: 0; }

.stack { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.stack-sm { display: flex; flex-direction: column; gap: 7px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 12px; }
.sub { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; margin-top: 4px; }

/* 버튼 */
.btn {
  min-height: 30px; padding: 0 11px;
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  cursor: pointer; font-weight: 500; line-height: 1.2; font-size: 12px;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn-danger:hover:not(:disabled) { background: var(--bad-bg); }
.btn-armed, .btn-armed:hover { background: var(--bad-bg) !important; color: var(--bad); border-color: var(--bad); }
/* 이미 해 둔 일 (일지 고치기 등) — 채우지 않고 테두리만, 끝난 색으로.
 * 채운 단추(primary)는 "아직 안 한 것" 에만 남겨 둡니다. 멀리서도 둘이 갈립니다. */
.btn-done { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.btn-done:hover:not(:disabled) { background: var(--ok-bg); filter: brightness(0.96); }
/* 아직 남은 일의 개수를 달고 있는 단추 */
.btn-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.btn-warn:hover:not(:disabled) { background: var(--warn-bg); filter: brightness(0.96); }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); font-size: 18px; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* 배지 */
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 2px;
  font-size: 11px; font-weight: 500; line-height: 1.6;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge-info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }

/* 입력 묶음 */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.field-hint { font-size: 11px; color: var(--muted); }

.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg-btn {
  min-height: 30px; padding: 0 11px; cursor: pointer; font-size: 12px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}
.seg-btn:hover { background: var(--surface-2); }
.seg-btn[aria-checked="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.seg-long[aria-checked="true"] { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.seg-short[aria-checked="true"] { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }

/* 수치 카드 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(146px, 1fr)); gap: 8px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; min-width: 0; }
.stat-label { font-size: 11px; color: var(--muted); }
.stat-value { font-size: 19px; font-weight: 600; margin-top: 1px; overflow-wrap: anywhere; letter-spacing: -0.01em; }
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.stat-bad .stat-value { color: var(--bad); }

/* 알림 줄 */
.banner { padding: 8px 11px; border-radius: var(--r-sm); border-left: 3px solid var(--line-strong); background: var(--surface-2); }
.banner-info { background: var(--accent-soft); border-left-color: var(--accent); }
.banner-warn { background: var(--warn-bg); border-left-color: var(--warn); }
.banner-bad { background: var(--bad-bg); border-left-color: var(--bad); }

.empty {
  border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  padding: 22px 18px; text-align: center; background: var(--surface);
  display: flex; flex-direction: column; gap: 7px; align-items: center;
}
.empty p { max-width: 46ch; }

/* 표 */
.table-wrap { overflow-x: auto; max-width: 100%; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 420px; }
.table th, .table td { padding: 6px 9px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.table thead th {
  font-size: 11px; color: var(--muted); font-weight: 600;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.table tbody tr:hover { background: var(--surface-2); }
.table .r { text-align: right; }
.table tbody th { font-weight: 500; }

.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.plain-list li:last-child { border-bottom: 0; }

/* 알림 토스트 */
.toast-host {
  position: fixed; left: 0; right: 0; bottom: env(safe-area-inset-bottom, 0px);
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px));
  display: flex; justify-content: center; pointer-events: none; z-index: 20;
}
.toast {
  pointer-events: auto; max-width: 560px; padding: 10px 14px; border-radius: var(--r-sm);
  background: var(--fg); color: var(--bg); font-size: 13px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.toast-bad { background: var(--bad); color: #fff; }
.toast-ok { background: var(--ok); color: #fff; }
.toast-warn { background: var(--warn); color: #fff; }
:root[data-theme="dark"] .toast-bad, :root[data-theme="dark"] .toast-ok, :root[data-theme="dark"] .toast-warn { color: #0a1020; }
:root[data-theme="dim"] .toast-bad, :root[data-theme="dim"] .toast-ok, :root[data-theme="dim"] .toast-warn { color: #0a1020; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .toast-bad, :root:not([data-theme="light"]) .toast-ok, :root:not([data-theme="light"]) .toast-warn { color: #0a1020; }
}
/* 키 입력칸: 비밀번호 칸이 아니라 글자 칸을 가려서 (브라우저 비밀번호 자동 채우기를 막으려고) */
.secret-input { -webkit-text-security: disc; text-security: disc; font-family: var(--mono, monospace); }

/* ── yaforisk 달력 (ui/datepicker) ─────────────────────── */
.dp-input { font-variant-numeric: tabular-nums; cursor: pointer; padding-right: 34px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a93a0' stroke-width='1.8' stroke-linecap='round'%3E%3Crect x='3.5' y='5' width='17' height='15.5' rx='2.5'/%3E%3Cpath d='M3.5 10h17M8 3v4M16 3v4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 17px; }
.dp-input[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.dp-pop { position: fixed; z-index: 2000; width: 296px; padding: 12px; border-radius: 14px; background: var(--surface); color: var(--fg);
  border: 1px solid var(--line); box-shadow: 0 18px 48px rgba(10, 20, 40, .22), 0 2px 6px rgba(10, 20, 40, .12);
  display: grid; gap: 8px; font-size: 13px; animation: dp-in .14s ease-out; }
@keyframes dp-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .dp-pop { animation: none; } }
.dp-head { display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; gap: 4px; }
.dp-pop :where(button) { all: unset; box-sizing: border-box; cursor: pointer; text-align: center; border-radius: 8px; }
.dp-pop button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.dp-nav { height: 32px; line-height: 32px; font-size: 20px; color: var(--muted); }
.dp-nav:hover { background: var(--surface-2); color: var(--fg); }
.dp-title { height: 32px; line-height: 32px; font-weight: 700; font-size: 15px; letter-spacing: .01em; }
.dp-title:hover { background: var(--surface-2); color: var(--accent); }
.dp-week, .dp-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-wd { text-align: center; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.dp-wd.dp-sat { color: #3b82f6; } .dp-wd.dp-sun { color: #e5484d; }
.dp-day { height: 36px; line-height: 36px; font-variant-numeric: tabular-nums; font-size: 13.5px; position: relative; transition: background .1s; }
.dp-day:hover:not(:disabled) { background: var(--accent-soft); }
.dp-day.dp-sat { color: #3b82f6; } .dp-day.dp-sun { color: #e5484d; }
.dp-day.dp-out { opacity: .38; }
.dp-day.dp-today { box-shadow: inset 0 0 0 1.5px var(--accent); font-weight: 700; }
.dp-day.dp-cursor:not(.dp-on) { background: var(--surface-2); }
.dp-day.dp-on { background: var(--accent); color: var(--accent-fg) !important; font-weight: 700; box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 40%, transparent); }
.dp-day.dp-off, .dp-day:disabled { opacity: .2; cursor: not-allowed; }
.dp-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px 0; }
.dp-month { height: 44px; line-height: 44px; font-weight: 600; background: var(--surface-2); }
.dp-month:hover { background: var(--accent-soft); color: var(--accent); }
.dp-month.dp-today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.dp-month.dp-on { background: var(--accent); color: var(--accent-fg); }
.dp-foot { display: flex; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.dp-quick { padding: 6px 10px; font-size: 12.5px; font-weight: 600; color: var(--accent); background: var(--accent-soft); }
.dp-quick:hover { filter: brightness(1.05); }
.dp-quick:disabled { opacity: .35; cursor: not-allowed; }
.dp-close { margin-left: auto; padding: 6px 10px; font-size: 12.5px; color: var(--muted); }
.dp-close:hover { background: var(--surface-2); color: var(--fg); }
/* 좁은 화면: 아래에서 올라오는 판 */
.dp-pop.dp-sheet { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto; border-radius: 16px 16px 0 0;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px)); animation: dp-up .18s ease-out; }
@keyframes dp-up { from { transform: translateY(100%); } to { transform: none; } }
.dp-sheet .dp-day { height: 44px; line-height: 44px; font-size: 15px; }

/* ── 전에 쓴 말 고르기 (ui/suggest — 브라우저 datalist 대신) ── */
.sg-pop { position: fixed; z-index: 2000; padding: 6px; border-radius: 12px; background: var(--surface); color: var(--fg);
  border: 1px solid var(--line); box-shadow: 0 18px 48px rgba(10, 20, 40, .22), 0 2px 6px rgba(10, 20, 40, .12);
  display: grid; gap: 2px; font-size: 13.5px; animation: dp-in .12s ease-out; }
@media (prefers-reduced-motion: reduce) { .sg-pop { animation: none; } }
.sg-title { padding: 6px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--muted); }
.sg-list { list-style: none; margin: 0; padding: 0; max-height: 288px; overflow-y: auto; display: grid; gap: 1px; }
.sg-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; min-width: 0; }
.sg-item .sg-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-item mark { background: none; color: var(--accent); font-weight: 700; }
.sg-item.sg-on { background: var(--accent-soft); color: var(--accent); }
.sg-count { flex: none; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted); padding: 1px 7px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); }
.sg-item.sg-on .sg-count { color: var(--accent); border-color: transparent; background: var(--surface); }
.sg-hint { padding: 6px 10px 2px; margin-top: 2px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
@media (hover: none) { .sg-hint { display: none; } }

/* ── 강조 (ui/richtext): 굵게 · 밑줄 · 동그라미 · 형광펜 ── */
.rt { white-space: pre-line; }
.rt-b { font-weight: 700; }
.rt-u { text-decoration: underline; text-decoration-color: var(--rt-pen); text-decoration-thickness: 2px; text-underline-offset: .22em; text-decoration-skip-ink: none; }
.rt-o { border: 1.6px solid var(--rt-pen); border-radius: 999px; padding: 0 .32em; margin: 0 .06em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.rt-m { color: inherit; border-radius: .2em; padding: 0 .08em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.rt-m-y { background: linear-gradient(transparent 32%, var(--hl-y) 32%, var(--hl-y) 92%, transparent 92%); }
.rt-m-g { background: linear-gradient(transparent 32%, var(--hl-g) 32%, var(--hl-g) 92%, transparent 92%); }
.rt-m-p { background: linear-gradient(transparent 32%, var(--hl-p) 32%, var(--hl-p) 92%, transparent 92%); }
.rt-m-b { background: linear-gradient(transparent 32%, var(--hl-b) 32%, var(--hl-b) 92%, transparent 92%); }

.rt-wrap { border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); overflow: hidden; min-width: 0; }
.rt-wrap:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
.rt-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.rt-btn { all: unset; box-sizing: border-box; display: inline-grid; place-items: center; min-width: 30px; height: 28px; padding: 0 7px; border-radius: 7px;
  cursor: pointer; font-size: 13.5px; color: var(--muted); transition: background .1s, color .1s; }
.rt-btn:hover { background: var(--surface); color: var(--fg); }
.rt-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.rt-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.rt-btn-b { font-weight: 800; font-family: Georgia, "Times New Roman", serif; font-size: 15px; }
.rt-btn-u { text-decoration: underline; text-decoration-color: var(--rt-pen); text-decoration-thickness: 2px; text-underline-offset: 3px; font-family: Georgia, "Times New Roman", serif; font-size: 15px; }
.rt-ico-o { display: inline-grid; place-items: center; width: 21px; height: 21px; border: 1.6px solid var(--rt-pen); border-radius: 50%; font-size: 11px; font-weight: 600; line-height: 1; }
.rt-swatch { min-width: 28px; padding: 0; }
.rt-dot { width: 15px; height: 15px; border-radius: 50%; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fg) 14%, transparent); }
/* 단추의 색 점은 두 테마 모두 또렷하게 (글 위의 형광펜은 테마마다 옅기가 다름) */
.rt-dot.rt-m-y { background: #f5c518; } .rt-dot.rt-m-g { background: #3fcf6e; }
.rt-dot.rt-m-p { background: #f06aa6; } .rt-dot.rt-m-b { background: #4f9cf5; }
.rt-swatch[aria-pressed="true"] { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--accent); }
.rt-btn-clear { font-size: 12.5px; padding: 0 9px; }
/* 쓰지 않는 칸의 도구 막대는 한 발 물러나 있게 */
.rt-bar { transition: opacity .12s; }
.rt-wrap:not(:focus-within):not(:hover) .rt-bar { opacity: .55; }
.rt-sep { width: 1px; height: 18px; background: var(--line-strong); margin: 0 5px; }
.rt-edit { position: relative; padding: 8px 11px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; outline: none; cursor: text; min-height: 4.5em; }
.rt-edit.rt-serif { font-family: "Noto Serif KR", "Nanum Myeongjo", "AppleMyungjo", Batang, serif; font-size: 15.5px; }
.rt-edit.rt-empty::before { content: attr(data-placeholder); position: absolute; left: 11px; right: 11px; top: 8px; color: var(--muted); opacity: .8; pointer-events: none; }

/* ── 찾기 칸 (kit.search): 돋보기 · 둥근 칸 · 지우기 × ── */
.search { position: relative; display: flex; align-items: center; min-width: 0; }
.search-ico { position: absolute; left: 12px; color: var(--muted); pointer-events: none; transition: color .15s; }
.search .search-input {
  width: 100%; min-height: 36px; padding: 0 34px 0 36px; font-size: 13.5px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid transparent;
}
.search .search-input:hover:not(:focus) { background: color-mix(in srgb, var(--surface-2) 70%, var(--line)); border-color: transparent; }
.search .search-input:focus, .search .search-input:focus-visible {
  background: var(--surface); border-color: color-mix(in srgb, var(--focus) 60%, var(--line-strong));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 12%, transparent);
}
.search:focus-within .search-ico { color: var(--accent); }
.search-clear { all: unset; box-sizing: border-box; position: absolute; right: 7px; display: grid; place-items: center; width: 22px; height: 22px;
  border-radius: 50%; color: var(--muted); background: color-mix(in srgb, var(--fg) 8%, transparent); cursor: pointer; transition: background .12s, color .12s; }
.search-clear:hover { color: var(--fg); background: color-mix(in srgb, var(--fg) 16%, transparent); }
.search-clear:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.search-input:placeholder-shown ~ .search-clear { display: none; }
.search-sm .search-input { min-height: 30px; font-size: 12.5px; padding-left: 32px; }
.search-sm .search-ico { left: 10px; width: 13px; height: 13px; }
.search-lg .search-input { min-height: 42px; font-size: 14.5px; padding-left: 40px; }
.search-lg .search-ico { left: 14px; width: 17px; height: 17px; }

/* 맨 위로 (v183) — 오른쪽 아래, 알림(토스트)보다 위 */
.totop {
  position: fixed; z-index: 900;
  right: calc(20px + env(safe-area-inset-right, 0px)); bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line, #888));
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
  cursor: pointer;
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity .2s ease, transform .2s ease, background .15s ease;
}
.totop.totop-on { opacity: 1; transform: none; pointer-events: auto; }
.totop:hover { background: var(--accent); color: #fff; }
.totop:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 640px) { .totop { right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: 42px; height: 42px; } }
@media (prefers-reduced-motion: reduce) { .totop { transition: none; } }
