/* 세 페이지가 함께 쓰는 모양 */
:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --ink: #1d2230;
  --muted: #6a7184;
  --line: #e2e6ee;
  --accent: #4f5bd5;
  --accent-ink: #ffffff;
  --accent-soft: #eceefd;
  --ok: #1d936a;
  --ok-soft: #e3f5ee;
  --bad: #cf3f45;
  --bad-soft: #fcebec;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 28, 50, .06), 0 4px 16px rgba(20, 28, 50, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  word-break: keep-all; overflow-wrap: anywhere;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .6em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-wrap; }
.hidden { display: none !important; }

/* 머리 · 바탕 */
.top {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-in { max-width: 1040px; margin: 0 auto; padding: 10px 18px; display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 800; font-size: 1.05rem; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand small { font-weight: 600; color: var(--muted); margin-left: 6px; font-size: .8rem; }
.top .grow { flex: 1; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 20px 18px 60px; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 0 40px; }
.foot a, .foot .link { color: var(--muted); }
.link { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.auth { max-width: 380px; margin: 40px auto; }
.notice { background: var(--accent-soft); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; white-space: pre-wrap; }
.banner { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.banner.warn { background: var(--warn-soft); color: #7a4f0e; }
.banner.bad { background: var(--bad-soft); color: #8c2328; }
.banner.ok { background: var(--ok-soft); color: #11603f; }
.empty { color: var(--muted); text-align: center; padding: 28px 10px; }

/* 단추 · 입력 */
.btn {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 7px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  display: inline-block; text-decoration: none;
}
.btn:hover { border-color: #c7cddb; background: #fafbfd; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.danger.solid, .dlg .btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { padding: 3px 9px; font-size: .85rem; border-radius: 8px; }
.btn.wide { width: 100%; padding: 10px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
input, textarea, select {
  font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; background: #fff; min-width: 0;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { width: 100%; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field input, .field textarea, .field select { width: 100%; }
.field input[type=checkbox], .field input[type=radio] { width: auto; }
.check { white-space: nowrap; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.msg { color: var(--bad); min-height: 1.2em; font-size: .9rem; margin: 4px 0 10px; }

/* 세그먼트 · 탭 */
.seg { display: flex; background: #e6e9f0; border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 7px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button {
  border: 0; background: transparent; padding: 10px 14px; font: inherit; font-weight: 700; color: var(--muted);
  cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 1.4em; padding: 0 6px; border-radius: 99px; background: var(--bad); color: #fff; font-size: .75rem; line-height: 1.4em; text-align: center; margin-left: 4px; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--bg); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.acc { background: var(--accent-soft); color: var(--accent); }

/* 표 */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .8rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
table.list tr:last-child td { border-bottom: 0; }

/* 알림 · 대화상자 */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  background: #222838; color: #fff; padding: 10px 18px; border-radius: 99px; box-shadow: var(--shadow);
  transition: opacity .4s; max-width: calc(100% - 32px);
}
.toast.bad { background: var(--bad); }
.toast.out { opacity: 0; }
.dlg { border: 0; border-radius: var(--radius); padding: 22px; width: min(420px, calc(100% - 32px)); box-shadow: 0 10px 40px rgba(0, 0, 0, .2); }
.dlg::backdrop { background: rgba(20, 24, 36, .45); }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ── 방문자: 위키 목록 ── */
.hero { text-align: center; padding: 26px 0 10px; }
.hero h1 { font-size: 1.8rem; }
.search { width: 100%; max-width: 420px; padding: 10px 14px; border-radius: 99px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-top: 20px; }
.wcard {
  display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
}
.wcard:hover { transform: translateY(-2px); box-shadow: 0 6px 22px rgba(20, 28, 50, .1); }
.wcard .pic { aspect-ratio: 4 / 3; background: linear-gradient(135deg, #e6e9fb, #f4e9f7); display: flex; align-items: center; justify-content: center; font-size: 2.2rem; font-weight: 800; color: #a3a9d9; }
.wcard .pic img { width: 100%; height: 100%; object-fit: cover; }
.wcard .txt { padding: 12px 14px 14px; }
.wcard .txt b { display: block; font-size: 1.02rem; }
.wcard .txt span { color: var(--muted); font-size: .85rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── 방문자: 위키 한 곳 ── */
.whead { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--accent-soft); flex: none; display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--accent); font-size: 1.5rem; }
.whead h1 { margin: 0; }
.prof { display: grid; grid-template-columns: minmax(0, 280px) 1fr; gap: 22px; align-items: start; }
.prof .big { width: 100%; border-radius: var(--radius); display: block; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: 14px; }
.facts dt, .facts dd { margin: 0; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.facts dt { background: var(--bg); font-weight: 700; font-size: .9rem; }
.facts dt:nth-last-of-type(1), .facts dd:last-child { border-bottom: 0; }

.cal-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 12px; }
.cal-nav b { font-size: 1.1rem; min-width: 110px; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-h { text-align: center; font-size: .8rem; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-h:first-child { color: var(--bad); } .cal-h:nth-child(7) { color: var(--accent); }
.cal-cell { min-height: 78px; border-radius: 9px; background: var(--card); border: 1px solid var(--line); padding: 4px 5px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
button.cal-cell { font: inherit; color: inherit; text-align: left; cursor: pointer; }
button.cal-cell:hover { border-color: #c7cddb; }
.cal-cell.picked { background: var(--accent-soft); border-color: var(--accent); }
.ev-day { margin: 0 0 4px; }
.cal-cell.blank { background: transparent; border-color: transparent; }
.cal-cell.today { outline: 2px solid var(--accent); }
.cal-day { font-size: .8rem; font-weight: 700; color: var(--muted); }
.cal-ev { font-size: .74rem; background: var(--accent); color: #fff; border-radius: 5px; padding: 0 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-more { font-size: .72rem; color: var(--muted); }
.ev-list { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.ev { display: flex; gap: 14px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.ev .d { flex: none; width: 112px; font-weight: 700; }
.ev .d small { display: block; color: var(--muted); font-weight: 600; }
.ev.past { opacity: .6; }

.kitem { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-bottom: 8px; }
.kitem .mark { flex: none; width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); margin-top: 2px; display: flex; align-items: center; justify-content: center; font-size: .8rem; color: #fff; }
.kitem.done .mark { background: var(--ok); border-color: var(--ok); }
.kitem.done .t { text-decoration: line-through; color: var(--muted); }
.kitem .t { font-weight: 700; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }

.rcard { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: #fff; margin-bottom: 14px; }
.rrow { display: grid; grid-template-columns: minmax(80px, 34%) 1fr 64px; gap: 10px; align-items: center; padding: 5px 0; }
.rbar { height: 12px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.rbar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.rrow .p { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

/* ── 내 위키: 줄 편집기 ── */
.rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; }
.cell { display: flex; flex-direction: column; gap: 2px; flex: 1 1 140px; }
.cell.s { flex: 0 1 130px; } .cell.xs { flex: 0 1 90px; } .cell.l { flex: 2 1 220px; }
.cell .lab { font-size: .75rem; color: var(--muted); font-weight: 600; }
.cell.check { flex: 0 0 auto; flex-direction: row; padding-bottom: 8px; }
.row-tools { display: flex; gap: 4px; padding-bottom: 2px; }
.tabbar { position: sticky; top: 51px; z-index: 5; background: var(--bg); display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line); margin-bottom: 18px; padding-top: 4px; }
.tabbar .tabs { flex: 1; border-bottom: 0; margin: 0; }
.tabbar .dirty { color: var(--warn); font-weight: 600; font-size: .85rem; }
.menu-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; border: 1px solid var(--line);
  background: #fff; border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; font: inherit; cursor: pointer; }
.menu-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.menu-item span { color: var(--muted); font-size: .85rem; }
.menu-item.bad b { color: var(--bad); }
.menu-item.bad:hover { border-color: var(--bad); background: var(--bad-soft); }
.imgbox { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.imgbox img, .imgbox .none { width: 120px; height: 120px; object-fit: cover; border-radius: 12px; background: var(--bg); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .85rem; }
.sum { font-weight: 700; }
.sum.bad { color: var(--bad); }

/* ── 관리 ── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: .85rem; }
.app-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; background: #fff; }
.app-card .meta { color: var(--muted); font-size: .85rem; }

@media (max-width: 640px) {
  .prof { grid-template-columns: 1fr; }
  .cal-cell { min-height: 54px; }
  .cal-ev { font-size: 0; height: 6px; padding: 0; }
  .ev { flex-direction: column; gap: 2px; }
  .ev .d { width: auto; }
  .rrow { grid-template-columns: 1fr 56px; }
  .rrow .rbar { grid-column: 1 / -1; grid-row: 2; }
}

/* 기념일 · 하루 종일 · 별점 · 장르 */
.cal-ev.an { background: #e0569b; }
.ev.an { border-color: #f4c3dc; background: #fdf1f7; }
.ev.an .d { color: #c23d80; }
.pill.an { background: #fdf1f7; color: #c23d80; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.cal-nav .check input { padding: 3px 6px; }
.stars { display: flex; gap: 1px; padding-bottom: 6px; }
.star { border: 0; background: none; padding: 0 1px; font-size: 1.25rem; line-height: 1; color: #d6dae3; cursor: pointer; }
.star.on { color: #f2b01e; }
.star:hover { transform: scale(1.15); }
.stars-view { color: #d6dae3; letter-spacing: 1px; white-space: nowrap; }
.stars-view .on { color: #f2b01e; }
.dlg.wide { width: min(560px, calc(100% - 32px)); }
.genre-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 12px; font: inherit; font-size: .9rem; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.recover-code { font: 700 1.4rem/1.4 ui-monospace, Consolas, monospace; letter-spacing: .06em; text-align: center; background: var(--bg); border-radius: 10px; padding: 12px; margin: 10px 0; user-select: all; }
.chip-wrap { display: inline-flex; align-items: center; }
.chip-wrap .chip { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.chip-x { border: 1px solid var(--line); border-left: 0; background: #fff; border-radius: 0 99px 99px 0; padding: 4px 9px; font: inherit; font-size: .9rem; color: var(--bad); cursor: pointer; }
.chip-x:hover { background: var(--bad-soft); }

/* 관리 탭: 반원 막대(교사용 웹앱과 같은 모양) */
.usage-site { background: #f8f9fb; }
.usage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.usage-grid > .banner { grid-column: 1 / -1; }
.gauge { appearance: none; font: inherit; color: inherit; cursor: pointer; display: grid; gap: 4px; justify-items: center; align-content: start;
  text-align: center; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.gauge:hover { border-color: var(--accent); }
.gauge.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.gauge-title { font-weight: 700; }
.gauge-box { position: relative; width: 100%; max-width: 220px; }
.gauge-arc { display: block; width: 100%; }
.gauge-text { position: absolute; left: 0; right: 0; bottom: 2%; display: grid; line-height: 1.15; }
.gauge-text strong { font-size: 1.6rem; }
.gauge-text span { font-size: .82rem; color: var(--muted); }
.usage-detail { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 12px; }
.usage-rows { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.usage-rows li { display: grid; gap: 4px; }
.usage-rows li.other { color: var(--muted); }
.usage-num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.usage-bar { display: block; height: 8px; border-radius: 999px; background: #eef0f4; overflow: hidden; }
.usage-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.usage-rows li.other .usage-bar > span { background: #9aa4b5; }
.usage-list { margin: 8px 0 0; padding-left: 1.2rem; display: grid; gap: 2px; }

/* 맨 아래 저작권 */
.credit { margin: 6px 0 0; font-size: .78rem; color: var(--muted); }
.credit + .credit { margin-top: 2px; }
.chip.add { border-style: dashed; color: var(--accent); }
