/* SweetStartHome — 기본 스타일 */
:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --line: #E3E6EA;
  --line-strong: #C3C8D0;
  --text: #1B1D21;
  --muted: #5B6270;
  --tile: #EEF1F5;
  --tile-text: #3A4150;
  --accent: #2F5BEA;
  --accent-dark: #1F45C4;
  --danger: #C2312B;
  --radius: 16px;
  --font: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", sans-serif;
}

* { 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(--accent); }
a:hover { color: var(--accent-dark); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid rgba(47, 91, 234, .45); 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 #D5D9DF; border-radius: 12px; background: #F8F9FA; font-size: 15px;
}
.search input:focus { background: var(--surface); border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(47, 91, 234, .18); }

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

/* 버튼 */
.btn {
  height: 44px; padding: 0 16px; border: 1px solid #D5D9DF; 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: #F6F7F9; 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: #EBC3C1; }
.btn-danger:hover { background: #FDF2F1; 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: #fff; }
.link-btn { border: none; background: none; color: var(--accent); 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: #F1F3F5; color: var(--text); }

/* 본문 */
main.wrap { padding-top: 28px; padding-bottom: 32px; }
.edit-banner {
  background: #EAF0FF; border: 1px solid #C9D6FB; color: #1E3A8A; 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; }

.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: #8A919C; 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(4, minmax(0, 1fr)); gap: 4px; min-height: 64px; border-radius: 12px; }
.links.drop-into { background: #F1F5FF; outline: 2px dashed #9DB3F5; }
.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: #F4F6F9; 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-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: #fff; 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); }

.no-result { text-align: center; color: var(--muted); padding: 40px 0; }

/* 첫 화면 */
.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; }

/* 하단 */
.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 rgba(15, 20, 30, .25); color: var(--text);
}
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 input[type="text"], dialog select {
  height: 44px; padding: 0 12px; border: 1px solid #D5D9DF; 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 rgba(47, 91, 234, .18); }
.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 rgba(47, 91, 234, .45); outline-offset: 2px; }

/* 알림 */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; 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: #353A44; }
.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; }

@media (max-width: 560px) {
  .topbar-inner, .wrap { padding-left: 16px; padding-right: 16px; }
  .actions { width: 100%; }
  .actions .btn { flex: 1 1 auto; padding: 0 10px; }
  .groups { grid-template-columns: minmax(0, 1fr); }
  .links { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
