:root {
  --accent: #ff6b4a;
  --accent-dark: #e8502f;
  --accent-soft: #fff0eb;
  --sun: #ffbe32;
  --sky: #4aa8ff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e7e5e4;
  --bg: #fffaf6;
  --card: #ffffff;
  --danger: #e5484d;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "PingFang SC", "Malgun Gothic",
          "Microsoft YaHei", "Noto Sans CJK KR", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }

/* ---------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px;
  padding: 0 28px; height: 64px; background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; white-space: nowrap; }
.brand-dot { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--sun)); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 8px 14px; border-radius: 999px; font-weight: 600; color: var(--muted); }
.nav a:hover { background: var(--accent-soft); color: var(--ink); }
.nav a.active { background: var(--ink); color: #fff; }
.me { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.admin-btn { gap: 6px; color: var(--muted); }
.admin-btn:hover { color: var(--ink); border-color: var(--ink); }
.role-badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; }

main { max-width: 1320px; margin: 0 auto; padding: 28px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.page-head .sub { color: var(--muted); margin-top: 2px; }

/* ---------- buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #cfcac6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.input, select.input, textarea.input {
  height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; outline: none; width: 100%;
}
textarea.input { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); cursor: pointer; white-space: nowrap; }

/* ---------- toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.search { position: relative; flex: 1 1 280px; }
.search .input { height: 46px; padding-left: 42px; font-size: 16px; border-radius: 12px; }
.search::before { content: ""; position: absolute; left: 15px; top: 15px; width: 12px; height: 12px; border: 2px solid var(--muted); border-radius: 50%; }
.search::after { content: ""; position: absolute; left: 27px; top: 28px; width: 7px; height: 2px; background: var(--muted); transform: rotate(45deg); }
.toolbar select.input, .toolbar input[type=date].input { width: auto; height: 46px; border-radius: 12px; }

/* ---------- stats */
.stats { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; min-width: 140px; }
.stat b { display: block; font-size: 24px; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.hot b { color: var(--accent); }

/* ---------- photo grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.tile { position: relative; border-radius: var(--radius); overflow: hidden; background: #f1ede9; cursor: pointer; aspect-ratio: 4 / 3; }
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s, opacity .3s; opacity: 0; }
.tile img.loaded, .kid .cover img.loaded { opacity: 1; }
.tile:hover img { transform: scale(1.04); }
.tile .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 10px 8px; color: #fff; font-size: 13px; font-weight: 600;
  background: linear-gradient(transparent, rgba(0,0,0,.6)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile .noimg { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-weight: 700; }
.tile .sel {
  position: absolute; top: 10px; left: 10px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff;
  background: rgba(0,0,0,.25); display: none;
}
.selecting .tile .sel { display: block; }
.tile.selected { outline: 4px solid var(--accent); outline-offset: -4px; }
.tile.selected .sel { background: var(--accent); border-color: var(--accent); }
.tile.selected .sel::after { content: ""; position: absolute; left: 7px; top: 3px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.more { text-align: center; padding: 26px; color: var(--muted); }
.empty { text-align: center; padding: 70px 20px; color: var(--muted); background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty b { display: block; font-size: 18px; color: var(--ink); margin-bottom: 4px; }

.bulkbar {
  position: sticky; top: 72px; z-index: 15; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 14px; background: var(--ink); color: #fff; border-radius: var(--radius);
}
.bulkbar .count { font-weight: 700; margin-right: auto; }
.bulkbar .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); height: 34px; }
.bulkbar .btn.danger { color: #ffb4b4; }

/* ---------- children */
.kids { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.kid { background: #fff; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; transition: box-shadow .2s, transform .2s; }
.kid:hover { box-shadow: 0 10px 30px rgba(31,36,48,.1); transform: translateY(-2px); }
.kid .cover { aspect-ratio: 4 / 3; background: #f1ede9; }
.kid .cover img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s; }
.kid .body { padding: 12px 14px 14px; }
.kid .name { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.kid .alt { color: var(--muted); font-size: 13px; }
.kid .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #f3f1ef; color: #57534e; }
.pill.group { background: #e8f4ff; color: #1f6fbf; }
.pill.count { background: var(--accent-soft); color: var(--accent-dark); }

.profile { display: grid; grid-template-columns: 340px 1fr; gap: 26px; margin-bottom: 30px; }
.profile .photo { border-radius: 20px; overflow: hidden; background: #f1ede9; aspect-ratio: 4 / 3; }
.profile .photo img { width: 100%; height: 100%; object-fit: cover; }
.profile h1 { margin: 0; font-size: 34px; letter-spacing: -0.02em; }
.profile .alt { color: var(--muted); font-size: 16px; margin-bottom: 14px; }
table.info { border-collapse: collapse; width: 100%; background: #fff; border-radius: 12px; overflow: hidden; }
table.info th, table.info td { border: 1px solid var(--line); padding: 10px 14px; text-align: left; vertical-align: top; }
table.info th { width: 120px; background: #faf8f6; color: var(--muted); font-weight: 600; font-size: 14px; }
.section-title { font-size: 20px; font-weight: 800; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.back { display: inline-block; color: var(--muted); font-weight: 600; margin-bottom: 14px; }
.back:hover { color: var(--ink); }

/* ---------- tables (users) */
table.list { border-collapse: collapse; width: 100%; background: #fff; }
table.list th, table.list td { border: 1px solid var(--line); padding: 10px 12px; text-align: left; }
table.list th { background: #faf8f6; color: var(--muted); font-size: 13px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }

/* ---------- upload */
.upload-layout { display: grid; grid-template-columns: 360px 1fr; gap: 22px; align-items: start; }
.drop {
  border: 2.5px dashed #f3b8a8; background: var(--accent-soft); border-radius: 20px; padding: 46px 20px; text-align: center; transition: .15s;
}
.drop.over { border-color: var(--accent); background: #ffe3da; }
.drop b { display: block; font-size: 20px; margin-bottom: 6px; }
.drop .btns { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.queue { margin-top: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.qitem { position: relative; border-radius: 10px; overflow: hidden; background: #f1ede9; aspect-ratio: 4 / 3; font-size: 12px; }
.qitem img { width: 100%; height: 100%; object-fit: cover; }
.qitem .st { position: absolute; left: 6px; bottom: 6px; padding: 2px 8px; border-radius: 999px; background: rgba(0,0,0,.6); color: #fff; font-weight: 700; }
.qitem.done .st { background: #23a26d; }
.qitem.err .st { background: var(--danger); }
.progress { height: 10px; border-radius: 999px; background: #eee; overflow: hidden; margin: 10px 0 4px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--sun)); width: 0; transition: width .2s; }

/* ---------- child picker */
.picker { position: relative; }
.picker .chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.picker .chips:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.picker .chips input { border: 0; outline: 0; flex: 1; min-width: 100px; height: 28px; padding: 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 6px 0 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; font-size: 13px; }
.chip a.chip-link:hover { text-decoration: underline; }
.chip button { border: 0; background: none; cursor: pointer; color: inherit; font-size: 16px; line-height: 1; padding: 0 4px; }
.chip.static { padding-right: 10px; }
.picker .dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60; max-height: 260px; overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.12);
}
.picker .opt { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.picker .opt:hover, .picker .opt.hl { background: var(--accent-soft); }
.picker .opt small { color: var(--muted); }
.picker .opt.new { color: var(--accent-dark); font-weight: 700; border-top: 1px solid var(--line); }

/* ---------- modal & lightbox */
.modal-bg { position: fixed; inset: 0; z-index: 100; background: rgba(20,22,28,.5); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: #fff; border-radius: 20px; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; padding: 26px; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.modal.narrow { max-width: 420px; }
.modal h2 { margin: 0 0 18px; font-size: 22px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.modal .actions .left { margin-right: auto; }

.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(12,13,17,.94); display: grid; grid-template-columns: 1fr 380px; }
.lb-stage { position: relative; display: flex; align-items: center; justify-content: center; padding: 30px 70px; min-width: 0; }
.lb-stage img { max-width: 100%; max-height: calc(100vh - 60px); object-fit: contain; border-radius: 8px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 24px; cursor: pointer; }
.lb-nav:hover { background: rgba(255,255,255,.25); }
.lb-prev { left: 14px; } .lb-next { right: 14px; }
.lb-close { position: absolute; top: 14px; left: 14px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 20px; cursor: pointer; }
.lb-side { background: #fff; overflow: auto; padding: 24px; }
.lb-side h3 { margin: 0 0 4px; font-size: 20px; }
.lb-side .muted { color: var(--muted); font-size: 13px; }
.lb-side .row { margin-top: 16px; }
.lb-side .row > .k { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.lb-side .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lb-side .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- login */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: linear-gradient(140deg, var(--accent) 0%, #ff9a5a 55%, var(--sun) 100%); color: #fff; padding: 60px; display: flex; flex-direction: column; justify-content: flex-end; position: relative; overflow: hidden; }
.auth-hero h1 { font-size: 46px; line-height: 1.15; margin: 0 0 12px; letter-spacing: -0.03em; }
.auth-hero p { font-size: 18px; opacity: .92; margin: 0; }
.bubble { position: absolute; border-radius: 50%; background: rgba(255,255,255,.18); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px; background: #fff; }
.auth-form form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.auth-form h2 { margin: 0 0 6px; font-size: 26px; }
.auth-form .btn { height: 48px; font-size: 16px; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; }

#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); z-index: 200; background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600; opacity: 0; transition: .25s; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--danger); }

@media (max-width: 900px) {
  .topbar { padding: 0 14px; gap: 10px; height: auto; min-height: 58px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  main { padding: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .kids { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .profile, .upload-layout { grid-template-columns: 1fr; }
  .lightbox { grid-template-columns: 1fr; grid-template-rows: 55vh 1fr; }
  .lb-stage { padding: 10px 50px; }
  .lb-stage img { max-height: 52vh; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { padding: 36px 28px; min-height: 220px; }
  .auth-hero h1 { font-size: 32px; }
  .form-grid { grid-template-columns: 1fr; }
  .bulkbar { top: 110px; }
}
