:root {
  --bg: #f4f6f9; --panel: #fff; --text: #1d2430; --muted: #5f6b7a; --line: #dde3ea;
  --blue: #2a7de1; --blue-bg: #e7f1fd; --green: #138a4c; --green-bg: #e3f6ec; --amber: #a86400; --amber-bg: #fff3dc;
  --red: #c62f2f; --red-bg: #fde8e8; --gray: #6b7480; --gray-bg: #eef0f3; --purple: #6a3fc2; --purple-bg: #f0eafc;
  --radius: 12px; --side: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 19px; margin: 0 0 12px; }
h3 { font-size: 17px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.nowrap { white-space: nowrap; }
.hidden, [hidden] { display: none !important; }

/* 배너 */
.banner { padding: 12px 20px; font-weight: 600; text-align: center; }
.banner-red { background: var(--red); color: #fff; }
.banner-amber { background: #ffcf70; color: #4a3000; }

/* 레이아웃 */
.layout { display: flex; min-height: 100vh; }
.side { width: var(--side); background: #18212f; color: #cdd6e3; flex-shrink: 0; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side .brand { padding: 20px 20px 16px; font-weight: 800; font-size: 18px; color: #fff; }
.side .brand small { display: block; font-weight: 500; font-size: 13px; color: #8a97a8; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 13px 20px; color: #cdd6e3; text-decoration: none; font-size: 16px; border-left: 4px solid transparent; }
.side nav a:hover { background: #222d3e; }
.side nav a.on { background: #263449; color: #fff; border-left-color: var(--blue); font-weight: 700; }
.side .num { width: 22px; height: 22px; border-radius: 50%; background: #2c3a50; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.side .foot { margin-top: auto; padding: 16px 20px; font-size: 13px; color: #8a97a8; }
.side .foot button { background: none; border: 1px solid #3a475a; color: #cdd6e3; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.main { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.topbar .title { flex: 1; min-width: 160px; }
.btn.menu-btn { display: none; }
.content { padding: 24px; max-width: 1400px; }

/* 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 10px; padding: 9px 16px; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 42px; white-space: nowrap; }
.btn:hover { background: #f2f5f8; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #1f6bc5; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #a92626; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 34px; padding: 5px 11px; font-size: 14px; border-radius: 8px; }
.btn-lg { min-height: 50px; padding: 12px 22px; font-size: 17px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* 카드 */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .k { font-size: 14px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 20px; font-weight: 800; margin-top: 4px; }
.stat .d { font-size: 14px; color: var(--muted); margin-top: 2px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* 상태 표시 */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.b-green { background: var(--green-bg); color: var(--green); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-gray { background: var(--gray-bg); color: var(--gray); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-purple { background: var(--purple-bg); color: var(--purple); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status-hero { display: flex; align-items: center; gap: 18px; padding: 20px 22px; border-radius: var(--radius); margin-bottom: 20px; border: 2px solid; flex-wrap: wrap; }
.status-hero .lbl { font-size: 26px; font-weight: 900; }
.status-hero ul { margin: 4px 0 0; padding-left: 20px; }
.st-ok { background: var(--green-bg); border-color: #9fd9b9; color: #0d5a32; }
.st-partial, .st-flood { background: var(--amber-bg); border-color: #f2c77a; color: #6b4000; }
.st-paused { background: #fff6d6; border-color: #e8c650; color: #5b4500; }
.st-reauth, .st-outage { background: var(--red-bg); border-color: #efa3a3; color: #7d1717; }
.st-unknown { background: var(--gray-bg); border-color: #c4cad2; color: #3d4550; }
.status-pill { padding: 6px 14px; border-radius: 999px; font-weight: 800; font-size: 15px; border: 2px solid; }

/* 목록 행 */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 14px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; flex-wrap: wrap; }
.row:hover { border-color: #b8c4d2; }
.row .main-col { flex: 1; min-width: 220px; }
.row .name { font-weight: 800; font-size: 17px; }
.row .meta { color: var(--muted); font-size: 14px; }
.when { font-size: 18px; font-weight: 800; }
.thumb { width: 68px; height: 68px; border-radius: 10px; object-fit: cover; background: var(--gray-bg); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; position: relative; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .cnt { position: absolute; right: 4px; bottom: 4px; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; padding: 0 6px; border-radius: 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--gray-bg); border-radius: 8px; padding: 2px 9px; font-size: 14px; }
.chip.err { background: var(--red-bg); color: var(--red); }
.linkish { background: none; border: none; color: var(--blue); cursor: pointer; padding: 0; font: inherit; font-weight: 600; text-decoration: underline; }

/* 콘텐츠 카드 */
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.ccard { border: 1px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden; display: flex; flex-direction: column; }
.ccard.sel { outline: 3px solid var(--blue); }
.ccard .img { aspect-ratio: 16/10; background: var(--gray-bg); display: flex; align-items: center; justify-content: center; color: var(--muted); position: relative; overflow: hidden; }
.ccard .img img { width: 100%; height: 100%; object-fit: cover; }
.ccard .img .cnt { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.65); color: #fff; padding: 1px 8px; border-radius: 8px; font-size: 13px; }
.ccard .img .pick { position: absolute; left: 8px; top: 8px; width: 26px; height: 26px; }
.ccard .body { padding: 12px 14px; flex: 1; }
.ccard .body .name { font-weight: 800; }
.ccard .body .snip { color: var(--muted); font-size: 14px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ccard .acts { padding: 10px 12px; border-top: 1px solid var(--line); display: flex; gap: 6px; flex-wrap: wrap; }

/* 폼 */
label.f { display: block; font-weight: 700; margin: 14px 0 6px; }
label.f .muted { font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=url], input[type=search], input[type=email], select, textarea {
  width: 100%; border: 1px solid #c9d2dc; border-radius: 10px; padding: 10px 12px; background: #fff; min-height: 44px; font-size: 16px; }
textarea { min-height: 200px; resize: vertical; font-family: inherit; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 3px; flex-shrink: 0; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline > input, .inline > select { width: auto; flex: 1; min-width: 120px; }
.toolbar { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.toolbar button { min-width: 38px; height: 36px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-weight: 700; }
.err-box { background: var(--red-bg); color: var(--red); border-radius: 10px; padding: 10px 14px; margin: 10px 0; font-weight: 600; }
.warn-box { background: var(--amber-bg); color: #6b4000; border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.info-box { background: var(--blue-bg); color: #164d8f; border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.ok-box { background: var(--green-bg); color: #0d5a32; border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.err-box ul, .warn-box ul { margin: 4px 0; padding-left: 20px; }
.counter { font-size: 14px; color: var(--muted); text-align: right; }
.counter.over { color: var(--red); font-weight: 800; }

/* 드래그 업로드 */
.drop { border: 2px dashed #b4c0cd; border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; background: #fafbfc; }
.drop.over { border-color: var(--blue); background: var(--blue-bg); }
.media-list { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.media-item { width: 112px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.media-item img { width: 112px; height: 84px; object-fit: cover; display: block; }
.media-item .ma { display: flex; justify-content: space-between; padding: 2px; }
.media-item .ma button { border: none; background: none; cursor: pointer; font-size: 15px; padding: 4px 6px; }

/* 텔레그램 미리보기 */
.editor { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 20px; align-items: start; }
.tg { background: #c9d9c3 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Ccircle cx='20' cy='20' r='1.5' fill='%23b5c9ad'/%3E%3C/svg%3E"); border-radius: 14px; padding: 16px; min-height: 300px; position: sticky; top: 90px; }
.tg-note { background: rgba(255,255,255,.85); border-radius: 8px; padding: 6px 10px; font-size: 13px; margin-bottom: 12px; color: #3c4a3a; }
.bubble { background: #fff; border-radius: 14px 14px 14px 4px; max-width: 420px; margin-bottom: 10px; box-shadow: 0 1px 1px rgba(0,0,0,.12); overflow: hidden; }
.bubble .who { color: #2a7de1; font-weight: 700; font-size: 14px; padding: 8px 12px 0; }
.bubble .txt { padding: 6px 12px 8px; white-space: pre-wrap; word-wrap: break-word; font-size: 15px; }
.bubble .step { font-size: 12px; color: #fff; background: #4a7a3e; display: inline-block; padding: 1px 8px; border-radius: 0 0 8px 0; }
.bubble .album { display: grid; gap: 2px; }
.bubble .album img { width: 100%; height: 100%; object-fit: cover; display: block; max-height: 300px; }
.bubble .album.n1 { grid-template-columns: 1fr; }
.bubble .album.n2, .bubble .album.n4 { grid-template-columns: 1fr 1fr; }
.bubble .album.n3, .bubble .album.n5, .bubble .album.n6, .bubble .album.n7, .bubble .album.n8, .bubble .album.n9, .bubble .album.n10 { grid-template-columns: 1fr 1fr 1fr; }
.bubble .album.multi img { height: 120px; }
.bubble blockquote { border-left: 3px solid #2a7de1; margin: 4px 0; padding: 2px 8px; background: #eef5fd; border-radius: 4px; }
.bubble tg-spoiler { background: #9aa4ae; color: transparent; border-radius: 3px; }
.bubble code, .bubble pre { font-family: Consolas, monospace; background: #f1f3f5; border-radius: 4px; padding: 0 3px; }
.bubble pre { padding: 6px; white-space: pre-wrap; }
.bubble .time { text-align: right; font-size: 12px; color: #8a96a3; padding: 0 10px 6px; }

/* 표 */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; background: #fff; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; font-size: 15px; }
.tbl th { background: #f7f9fb; font-size: 14px; color: var(--muted); white-space: nowrap; }
.tbl tr:hover td { background: #fafcfe; }
.tbl input[type=checkbox] { width: 19px; height: 19px; }

/* 탭·단계 */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 700; font-size: 15px; }
.tabs button.on { background: var(--text); color: #fff; border-color: var(--text); }
.steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.steps .s { flex: 1; min-width: 140px; padding: 12px 14px; border-radius: 12px; background: #fff; border: 2px solid var(--line); font-weight: 700; color: var(--muted); }
.steps .s.on { border-color: var(--blue); color: var(--blue); background: var(--blue-bg); }
.steps .s.done { border-color: #9fd9b9; color: var(--green); }
.kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.kind { border: 2px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; background: #fff; text-align: left; }
.kind.on { border-color: var(--blue); background: var(--blue-bg); }
.kind b { display: block; font-size: 16px; }
.kind span { font-size: 13px; color: var(--muted); }
.wd { display: flex; gap: 6px; flex-wrap: wrap; }
.wd button { width: 48px; height: 44px; border-radius: 10px; border: 2px solid var(--line); background: #fff; cursor: pointer; font-weight: 800; }
.wd button.on { border-color: var(--blue); background: var(--blue); color: #fff; }
.pick-list { max-height: 460px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; }
.pick-item { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pick-item:last-child { border-bottom: none; }
.pick-item.on { background: var(--blue-bg); }
.pick-item input { width: 20px; height: 20px; }
.summary dt { font-weight: 800; margin-top: 10px; }
.summary dd { margin: 2px 0 0; }

/* 달력 */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .h { text-align: center; font-weight: 800; color: var(--muted); padding: 6px; }
.cal .d { min-height: 104px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px; font-size: 13px; overflow: hidden; }
.cal .d.other { background: #f6f7f9; color: #a0a8b2; }
.cal .d.today { border: 2px solid var(--blue); }
.cal .d .n { font-weight: 800; }
.cal .ev { background: var(--blue-bg); border-radius: 5px; padding: 1px 5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .ev.past { background: var(--gray-bg); }

/* 모달·토스트 */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 22, 33, .55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 16px; max-width: 620px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 24px; }
.modal h2 { margin-bottom: 14px; }
.modal .btns { justify-content: flex-end; margin-top: 18px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: #1d2430; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.2); font-weight: 600; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

/* 로그인 */
.login { max-width: 420px; margin: 8vh auto; background: #fff; border-radius: 16px; padding: 30px; border: 1px solid var(--line); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.qr svg { width: 240px; height: 240px; }
.disconnected .status-pill, .disconnected .stat .v { opacity: .45; }

@media (max-width: 1000px) {
  .editor, .two { grid-template-columns: 1fr; }
  .tg { position: static; }
}
@media (max-width: 760px) {
  :root { --side: 260px; }
  .side { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .btn.menu-btn { display: inline-flex; }
  .content { padding: 14px; }
  .topbar { padding: 10px 14px; }
  .topbar .title h1 { font-size: 20px; }
  .card { padding: 14px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .cal .d { min-height: 70px; font-size: 11px; }
  .status-hero .lbl { font-size: 22px; }
}
