/* SweetStartHome — 기본 스타일 */
:root {
  color-scheme: light;
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --line: #E3E6EA;
  --line-strong: #C3C8D0;
  --text: #1B1D21;
  --on-text: #FFFFFF;       /* var(--text) 바탕 위 글자 (알림, 눌린 단추) */
  --muted: #5B6270;
  --faint: #8A919C;
  --doc-text: #353A44;
  --tile: #EEF1F5;
  --tile-text: #3A4150;
  --logo-bg: #FFFFFF;       /* 사이트 로고 칸: 어두운 로고도 보이게 두 모드 모두 흰색 */
  --logo-line: #E3E6EA;
  --field-bg: #F8F9FA;
  --field-line: #D5D9DF;
  --hover: #F3F5F8;
  --accent: #2F5BEA;        /* 파란 단추 바탕 (흰 글자) */
  --accent-dark: #1F45C4;
  --link: #2F5BEA;          /* 파란 글자 */
  --link-hover: #1F45C4;
  --focus: rgba(47, 91, 234, .45);
  --focus-soft: rgba(47, 91, 234, .18);
  --info-bg: #EAF0FF;
  --info-line: #C9D6FB;
  --info-text: #1E3A8A;
  --drop-bg: #F1F5FF;
  --drop-line: #9DB3F5;
  --danger: #C2312B;
  --danger-line: #EBC3C1;
  --danger-bg: #FDF2F1;
  --shadow: rgba(15, 20, 30, .25);
  --radius: 16px;
  --font: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", sans-serif;
}

/* 다크 모드 (js/theme.js가 html에 data-theme="dark"를 붙임) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121417;
  --surface: #1B1E23;
  --line: #2C3138;
  --line-strong: #4A515C;
  --text: #E6E8EB;
  --on-text: #121417;
  --muted: #A1A8B3;
  --faint: #7A828E;
  --doc-text: #CDD2D9;
  --tile: #2A2F36;
  --tile-text: #D5DAE1;
  --logo-line: #FFFFFF;
  --field-bg: #15181C;
  --field-line: #3A4049;
  --hover: #262A31;
  --link: #8AACFF;
  --link-hover: #B4C9FF;
  --focus: rgba(138, 172, 255, .6);
  --focus-soft: rgba(138, 172, 255, .25);
  --info-bg: #1A2440;
  --info-line: #2F4580;
  --info-text: #C9D6FB;
  --drop-bg: #1A2440;
  --drop-line: #4F6FD0;
  --danger: #FF8A80;
  --danger-line: #5C2A27;
  --danger-bg: #34201F;
  --shadow: rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); }
a:hover { color: var(--link-hover); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* 상단바 */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 14px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex-shrink: 0; }
.brand:hover { color: var(--text); }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }

.search { flex: 1 1 280px; min-width: 0; position: relative; }
.search-icon { position: absolute; left: 14px; top: 13px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 44px; padding: 0 16px 0 42px;
  border: 1px solid var(--field-line); border-radius: 12px; background: var(--field-bg); font-size: 15px;
}
.search input:focus { background: var(--surface); border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--focus-soft); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* 버튼 */
.btn {
  height: 44px; padding: 0 16px; border: 1px solid var(--field-line); border-radius: 12px; background: var(--surface);
  font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text);
}
.btn:hover { background: var(--hover); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-danger { color: var(--danger); border-color: var(--danger-line); }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn-small { height: 36px; padding: 0 12px; font-size: 13px; }
.btn[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--on-text); }
.link-btn { border: none; background: none; color: var(--link); font-weight: 600; cursor: pointer; padding: 6px 4px; text-decoration: underline; }

.icon-btn {
  width: 44px; height: 44px; border: none; border-radius: 10px; background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

/* 다크 모드 단추 (시작 페이지 위쪽 끝). 밝을 때는 달, 어두울 때는 해 */
.theme-btn { width: 44px; padding: 0; flex-shrink: 0; }
.theme-btn[aria-pressed="true"] { background: var(--surface); border-color: var(--field-line); color: var(--text); }
.theme-btn:hover { background: var(--hover); }
.theme-btn .i-sun { display: none; }
[data-theme="dark"] .theme-btn .i-moon { display: none; }
[data-theme="dark"] .theme-btn .i-sun { display: block; }

/* 본문 */
main.wrap { padding-top: 28px; padding-bottom: 32px; }
.edit-banner {
  background: var(--info-bg); border: 1px solid var(--info-line); color: var(--info-text); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 20px; font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
}


.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; align-items: start; }

/* 한 줄에 놓을 그룹 개수 (편집 중 안내줄에서 고름). 좁은 화면에서는 아래 미디어 쿼리가 줄임 */
body.cols-2 .groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.cols-3 .groups { grid-template-columns: repeat(3, minmax(0, 1fr)); }
body.cols-4 .groups { grid-template-columns: repeat(4, minmax(0, 1fr)); }
body.cols-5 .groups { grid-template-columns: repeat(5, minmax(0, 1fr)); }
body.cols-4 .wrap, body.cols-4 .topbar-inner,
body.cols-5 .wrap, body.cols-5 .topbar-inner { max-width: 1600px; }
@media (max-width: 1100px) {
  body.cols-4 .groups, body.cols-5 .groups { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  body.cols-3 .groups, body.cols-4 .groups, body.cols-5 .groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.group {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.group.drop-before { box-shadow: -4px 0 0 var(--accent); }
.group.dragging { opacity: .45; }
.group-head { display: flex; align-items: center; gap: 6px; }
.group-handle { color: var(--faint); cursor: grab; display: inline-flex; padding: 4px; }
.group-title { margin: 0; font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.group-count { font-size: 13px; color: var(--muted); flex-shrink: 0; }
.group-head .spacer { flex: 1; }

.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 4px; min-height: 64px; border-radius: 12px; }
.links.drop-into { background: var(--drop-bg); outline: 2px dashed var(--drop-line); }
.links-empty { grid-column: 1 / -1; margin: 0; padding: 14px 8px; text-align: center; color: var(--muted); font-size: 13px; }

.link {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 10px 4px; border-radius: 12px; text-decoration: none; color: var(--text); min-width: 0;
}
.link:hover { background: var(--hover); color: var(--text); }
.link.drop-before { box-shadow: inset 3px 0 0 var(--accent); }
.link.dragging { opacity: .4; }
.link-icon {
  width: 48px; height: 48px; border-radius: 14px; background: var(--tile); color: var(--tile-text);
  display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; overflow: hidden; flex-shrink: 0;
}
.link-icon img { width: 26px; height: 26px; object-fit: contain; }
.link-icon.has-logo { background: var(--logo-bg); box-shadow: inset 0 0 0 1px var(--logo-line); }
.link-icon:not(.has-logo) { position: relative; }
.link-icon:not(.has-logo) img { position: absolute; opacity: 0; pointer-events: none; }

/* 아이콘 색 12가지 (흰 글자와 대비 4.5:1 이상) — 바로가기 칸과 색 고르기 동그라미에 함께 씀 */
.tone-0 { background: #C62828; color: #fff; }
.tone-1 { background: #C2410C; color: #fff; }
.tone-2 { background: #A16207; color: #fff; }
.tone-3 { background: #4D7C0F; color: #fff; }
.tone-4 { background: #15803D; color: #fff; }
.tone-5 { background: #0F766E; color: #fff; }
.tone-6 { background: #0E7490; color: #fff; }
.tone-7 { background: #1D4ED8; color: #fff; }
.tone-8 { background: #4338CA; color: #fff; }
.tone-9 { background: #7E22CE; color: #fff; }
.tone-10 { background: #BE185D; color: #fff; }
.tone-11 { background: #475569; color: #fff; }
.link-name { font-size: 13px; line-height: 1.3; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-edit-mark {
  position: absolute; top: 4px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--text); color: var(--on-text); display: none; align-items: center; justify-content: center;
}
body.editing .link-edit-mark { display: flex; }
body.editing .link { cursor: pointer; outline: 1px dashed var(--line-strong); outline-offset: -2px; }

.add-group-tile {
  min-height: 160px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: transparent;
  font-size: 15px; font-weight: 500; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; cursor: pointer;
}
.add-group-tile:hover { background: var(--surface); color: var(--text); }


/* 첫 화면 */
.empty {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 40px 28px; text-align: center; margin-bottom: 24px;
}
.empty h1 { margin: 0 0 8px; font-size: 24px; letter-spacing: -0.02em; }
.empty p { margin: 0; color: var(--muted); }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 24px 0 16px; }
.empty .note { font-size: 13px; }

/* 오늘의 팁 (시작 페이지 아래쪽, 운영자가 쓴 짧은 팁) */
.daily-tip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; margin: 28px 0 32px; }
.tip-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.daily-tip h2 { margin: 0; font-size: 16px; }
.tip-next { font-size: 13px; }
.tip-text { margin: 10px 0 12px; color: var(--doc-text); line-height: 1.6; }
.tip-links { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; font-weight: 600; }

/* 하단 */
.footer { border-top: 1px solid var(--line); padding-top: 20px; padding-bottom: 40px; display: flex; flex-wrap: wrap; gap: 20px; font-size: 13px; }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--text); text-decoration: underline; }

/* 대화상자 */
dialog {
  border: none; border-radius: 18px; padding: 0; width: min(440px, calc(100vw - 32px));
  box-shadow: 0 20px 60px var(--shadow); color: var(--text); background: var(--surface);
}
dialog::backdrop { background: rgba(15, 20, 30, .45); }
dialog form, .dlg-body { padding: 24px; display: flex; flex-direction: column; gap: 8px; }
#dlg-data { width: min(520px, calc(100vw - 32px)); }
dialog h2 { margin: 0 0 8px; font-size: 19px; }
dialog label { font-size: 14px; font-weight: 600; margin-top: 6px; }
dialog .hint { font-weight: 400; color: var(--muted); }
dialog .field-label { font-size: 14px; font-weight: 600; margin-top: 6px; }
.dlg-note { margin: 0 0 4px; color: var(--muted); font-size: 14px; }

/* 아이콘 색 고르기 */
.tone-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.tone-opt { position: relative; display: inline-flex; margin: 0; font-weight: 400; cursor: pointer; }
.tone-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tone-swatch {
  width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px transparent;
}
.tone-auto .tone-swatch { width: auto; padding: 0 12px; border-radius: 16px; background: var(--tile); color: var(--tile-text); font-size: 13px; font-weight: 600; }
.tone-opt input:checked + .tone-swatch { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.tone-opt input:focus-visible + .tone-swatch { outline: 3px solid var(--focus); outline-offset: 4px; }
dialog input[type="text"], dialog select {
  height: 44px; padding: 0 12px; border: 1px solid var(--field-line); border-radius: 10px; background: var(--surface); width: 100%;
}
dialog input[type="text"]:focus, dialog select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--focus-soft); }
.field-error { margin: 0; color: var(--danger); font-size: 13px; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }
.dlg-actions .spacer { flex: 1; }
.move-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; font-weight: 600; }
.move-row span { margin-right: 4px; }
#confirm-msg { margin: 0; font-size: 15px; white-space: pre-line; }

.data-block { border-top: 1px solid var(--line); padding: 14px 0 4px; }
.data-block:first-of-type { border-top: none; padding-top: 4px; }
.data-block h3 { margin: 0 0 4px; font-size: 15px; }
.data-block p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.file-btn { position: relative; overflow: hidden; margin-top: 0; font-weight: 500; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

/* 알림 */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--on-text); padding: 12px 18px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 안내 페이지 */
.doc { max-width: 760px; margin: 0 auto; padding: 32px 24px 48px; }
.doc h1 { font-size: 28px; letter-spacing: -0.02em; margin: 0 0 8px; }
.doc h2 { font-size: 20px; margin: 36px 0 10px; }
.doc h3 { font-size: 16px; margin: 20px 0 6px; }
.doc p, .doc li { color: var(--doc-text); }
.doc ol, .doc ul { padding-left: 22px; }
.doc li { margin: 4px 0; }
.doc .lead { color: var(--muted); margin-top: 0; }
.doc kbd { background: var(--surface); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; font-size: 13px; font-family: inherit; }
.doc .box { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.doc .box > :first-child { margin-top: 0; }
.doc .box > :last-child { margin-bottom: 0; }
.back { display: inline-flex; margin-bottom: 20px; font-size: 14px; }
.doc .mail-box { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.doc .mail-addr { font-weight: 600; word-break: break-all; }

@media (max-width: 560px) {
  .topbar-inner, .wrap { padding-left: 16px; padding-right: 16px; }
  /* 휴대폰: 다크 모드 단추는 사이트 이름 줄 오른쪽 끝, 검색창은 그다음 줄 */
  .theme-btn { order: 1; margin-left: auto; }
  .search { order: 2; flex-basis: 100%; }
  .actions { order: 3; }
  .actions { width: 100%; }
  .actions .btn { flex: 1 1 auto; padding: 0 10px; }
  .groups, body[class*="cols-"] .groups { grid-template-columns: minmax(0, 1fr); }

  /* 휴대폰용 설정이 2개일 때: 카드와 아이콘을 조금 작게 해서 한 줄에 2개 */
  body.mcols-2 .groups { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  body.mcols-2 .group { padding: 10px 8px 12px; gap: 6px; border-radius: 14px; }
  body.mcols-2 .group-handle, body.mcols-2 .group-count { display: none; }
  body.mcols-2 .group-title { font-size: 15px; padding-left: 4px; }
  body.mcols-2 .icon-btn { width: 32px; height: 32px; }
  body.mcols-2 .links { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); min-height: 0; }
  body.mcols-2 .link { padding: 6px 2px; gap: 5px; }
  body.mcols-2 .link-icon { width: 40px; height: 40px; border-radius: 12px; font-size: 16px; }
  body.mcols-2 .link-icon img { width: 22px; height: 22px; }
  body.mcols-2 .link-name { font-size: 12px; }
}

/* 사용 팁 (tips/) */
.doc .post-meta { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.doc .post-list { list-style: none; padding: 0; margin: 24px 0 0; }
.doc .post-list li { border-top: 1px solid var(--line); padding: 18px 0; margin: 0; }
.doc .post-list a { font-size: 18px; font-weight: 600; }
.doc .post-list p { margin: 6px 0; }
.doc .post-list time { color: var(--muted); font-size: 13px; }

/* 사용 안내: 누르면 펼쳐지는 그림 */
.doc details.shot { margin: 6px 0 2px; }
.doc details.shot summary { display: inline-block; cursor: pointer; color: var(--link); font-size: 14px; font-weight: 600; list-style: none; padding: 2px 0; }
.doc details.shot summary::-webkit-details-marker { display: none; }
.doc details.shot summary::before { content: "▸ "; }
.doc details.shot[open] summary::before { content: "▾ "; }
.doc details.shot summary:hover { color: var(--link-hover); }
.doc details.shot img { display: block; max-width: 100%; height: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; }
.doc details.shot img + img { margin-top: 10px; }
.doc code { background: var(--tile); color: var(--tile-text); border-radius: 6px; padding: 1px 6px; font-size: 14px; word-break: break-all; }
