:root {
  --primary-blue: #1e3a8a;
  --accent-blue: #3b82f6;
  --bg-color: #f1f5f9;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Noto Sans KR', sans-serif;
  background-color: var(--bg-color);
  margin: 0; padding: 0; color: var(--text-main);
  display: flex; flex-direction: column; min-height: 100vh;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button, input, select, textarea { font-family: inherit; }

.container { width: 100%; max-width: 900px; margin: 0 auto; padding: 40px 20px; flex: 1; }
.header { text-align: center; margin-bottom: 60px; }
.main-title {
  font-size: clamp(2.5rem, 8vw, 3.5rem); font-weight: 900; margin: 0;
  background: linear-gradient(135deg, var(--primary-blue), var(--accent-blue));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  letter-spacing: -1.5px;
}
.sub-title { font-size: 0.85rem; letter-spacing: 4px; color: var(--text-muted); margin-top: 8px; }

.category-section { margin-bottom: 45px; transition: opacity 0.3s; min-width: 0; }
.category-section.is-hidden .banner-grid, .category-section.is-hidden .category-title-text { opacity: 0.5; }
.category-title {
  font-size: 1.3rem; font-weight: 800; color: var(--primary-blue);
  margin-bottom: 15px; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; min-width: 0;
}
.category-title-text { display: flex; align-items: center; min-width: 0; flex: 1 1 200px; overflow-wrap: anywhere; word-break: keep-all; }
.category-title-text::before {
  content: ''; display: inline-block; flex: 0 0 4px; width: 4px; height: 20px;
  background-color: var(--accent-blue); margin-right: 10px; border-radius: 2px;
}
.hidden-badge { font-size: 0.75rem; font-weight: 700; color: #b45309; background: #fef3c7; border-radius: 999px; padding: 2px 8px; margin-left: 8px; white-space: nowrap; }

.banner-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; min-height: 20px; }
@media (max-width: 600px) { .banner-grid { grid-template-columns: minmax(0, 1fr); } }

.banner-card-wrapper { position: relative; display: flex; flex-direction: column; min-width: 0; }
.banner-card {
  display: flex; align-items: center; justify-content: center;
  min-height: 75px; padding: 10px 20px; background: var(--card-bg);
  border: 1px solid #e2e8f0; border-radius: 12px; text-decoration: none;
  color: #334155; font-weight: 700; text-align: center;
  word-break: keep-all; overflow-wrap: anywhere; white-space: pre-line; line-height: 1.35;
  transition: all 0.2s ease; box-shadow: 0 2px 4px rgba(0,0,0,0.04); font-size: 1.15rem;
  width: 100%; min-width: 0;
}
.banner-card:hover, .banner-card:focus-visible {
  background-color: var(--primary-blue); color: #ffffff;
  border-color: var(--primary-blue); transform: translateY(-2px);
  box-shadow: 0 8px 15px rgba(30, 58, 138, 0.2); outline: none;
}
.text-small { font-size: 0.95rem; }
.text-xsmall { font-size: 0.85rem; }
.empty-cat { color: var(--text-muted); font-size: 0.9rem; padding: 14px; border: 2px dashed #cbd5e1; border-radius: 12px; text-align: center; grid-column: 1 / -1; }

/* ---------- admin ---------- */
.admin-topbar {
  position: sticky; top: 0; z-index: 900; background: var(--primary-blue); color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 8px 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.admin-topbar-title { font-weight: 800; font-size: 0.95rem; white-space: nowrap; }
.admin-topbar-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.tb-btn { border: none; border-radius: 8px; padding: 8px 12px; min-height: 38px; font-weight: 700; font-size: 0.85rem; cursor: pointer; background: #e0e7ff; color: var(--primary-blue); }
.tb-btn:hover { background: #fff; }
.tb-primary { background: #60a5fa; color: #fff; }
.tb-primary:hover { background: #93c5fd; color: var(--primary-blue); }
.tb-dark { background: #334155; color: #fff; }
.tb-dark:hover { background: #475569; color: #fff; }
.admin-hint { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; border-radius: 10px; padding: 10px 14px; font-size: 0.85rem; margin: -30px 0 30px; overflow-wrap: anywhere; }

.admin-controls { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.ctrl-btn {
  background: #e2e8f0; border: none; border-radius: 6px;
  padding: 4px 9px; min-height: 32px; min-width: 32px; font-size: 0.78rem; font-weight: 700;
  color: #475569; cursor: pointer; transition: 0.2s; touch-action: manipulation;
}
.ctrl-btn:hover { background: var(--accent-blue); color: white; }
.ctrl-btn:disabled { opacity: 0.35; cursor: default; background: #e2e8f0; color: #475569; }
.ctrl-btn-add { background: #dbeafe; color: #1e40af; }
.ctrl-btn-hide { background: #ffed4a; color: #b45309; }
.ctrl-btn-hide:hover { background: #f59e0b; color: white; }
.ctrl-btn-del { background: #fee2e2; color: #dc2626; }
.ctrl-btn-del:hover { background: #ef4444; color: white; }
.drag-handle { cursor: grab; background: transparent; color: #94a3b8; font-size: 1.1rem; padding: 0 6px; touch-action: none; user-select: none; -webkit-user-select: none; }
.drag-handle:hover { background: #e2e8f0; color: var(--primary-blue); }

.is-admin .banner-card-wrapper { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; }
.is-admin .banner-card { border: none; border-radius: 0; box-shadow: none; min-height: 64px; }
.is-admin .banner-card:hover { transform: none; }
.banner-admin-bar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: #f8fafc; border-top: 1px solid #e2e8f0; flex-wrap: wrap; }
.banner-admin-bar .spacer { flex: 1; }
.banner-url { font-size: 0.72rem; color: var(--text-muted); padding: 0 12px 6px; text-align: center; overflow-wrap: anywhere; word-break: break-all; background: #fff; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sortable-ghost { opacity: 0.35; }
.sortable-chosen { box-shadow: 0 10px 20px rgba(30,58,138,0.25); }
.cat-handle { font-size: 1.2rem; }

.add-cat-wrap { text-align: center; margin-top: 40px; }

/* ---------- footer ---------- */
footer {
  background-color: #ffffff; padding: 30px 20px; border-top: 1px solid #e2e8f0;
  text-align: center; color: var(--text-muted); font-size: 0.9rem; overflow-wrap: anywhere;
}
.footer-info { font-weight: 700; margin-bottom: 5px; color: #475569; }
.footer-contact { color: var(--accent-blue); text-decoration: none; }
.footer-copy { margin-top: 15px; font-size: 0.8rem; opacity: 0.5; }
.admin-btn { cursor: pointer; color: #94a3b8; font-size: 0.8rem; transition: 0.2s; font-weight: bold; background: none; border: none; padding: 6px 4px; }
.admin-btn:hover { color: var(--accent-blue); }

/* ---------- modals ---------- */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); align-items: center; justify-content: center; z-index: 2000; padding: 12px;
}
.modal-overlay.open { display: flex; }
.entry-overlay { background: var(--bg-color); z-index: 1500; }
.modal-content {
  background: white; padding: 28px; border-radius: 16px; width: 100%;
  max-width: 420px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
  max-height: 92vh; overflow-y: auto; min-width: 0;
}
.modal-title { font-size: 1.2rem; font-weight: 800; color: var(--primary-blue); margin-bottom: 20px; text-align: center; }
.modal-subtitle { font-size: 1.05rem; font-weight: 800; color: var(--primary-blue); margin-bottom: 6px; text-align: center; }
.input-group { margin-bottom: 15px; }
.input-group label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 5px; color: #475569; }
.input-group small { font-weight: 400; color: var(--text-muted); }
.input-group input, .input-group select, .input-group textarea {
  width: 100%; padding: 10px; border: 1px solid #cbd5e1; border-radius: 8px;
  font-size: 16px; background: #fff; color: var(--text-main);
}
.input-group textarea { resize: vertical; min-height: 64px; }
.input-group input + input, .input-group select + input { margin-top: 8px; }
.input-group input:focus, .input-group select:focus, .input-group textarea:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.form-msg { color: #dc2626; font-size: 0.85rem; min-height: 1.2em; overflow-wrap: anywhere; }
.btn-wrap { display: flex; gap: 10px; margin-top: 20px; }
.btn { flex: 1; padding: 12px; border: none; border-radius: 8px; font-weight: 700; cursor: pointer; transition: 0.2s; font-size: 0.95rem; text-align: center; min-height: 44px; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-submit { background: var(--accent-blue); color: white; }
.btn-submit:hover { background: var(--primary-blue); }
.btn-slate { background: #475569; }
.btn-cancel { background: #e2e8f0; color: #475569; }
.btn-cancel:hover { background: #cbd5e1; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #ef4444; color: #fff; }
.btn-inline { display: inline-block; flex: none; width: auto; padding: 12px 30px; }
.file-btn { display: flex; align-items: center; justify-content: center; }
.full { width: 100%; display: block; }
.mt10 { margin-top: 10px; } .mt20 { margin-top: 20px; }
.center { text-align: center; }
.sep { border: 0; border-top: 1px solid #e2e8f0; margin: 25px 0; }
.muted { color: var(--text-muted); } .small { font-size: 0.82rem; text-align: center; }
.loading { text-align: center; margin-top: 50px; color: var(--text-muted); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #1e293b; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 0.9rem;
  opacity: 0; pointer-events: none; transition: 0.25s; z-index: 3000; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #b91c1c; }

@media (max-width: 600px) {
  .container { padding: 28px 14px; }
  .header { margin-bottom: 40px; }
  .admin-hint { margin: -16px 0 24px; }
  .category-title { font-size: 1.15rem; }
  .banner-card { font-size: 1.05rem; padding: 10px 14px; }
  .banner-card.text-small { font-size: 0.95rem; }
  .banner-card.text-xsmall { font-size: 0.88rem; }
  .modal-content { padding: 22px 18px; }
  .admin-topbar { padding: 8px 10px; }
  .tb-btn { padding: 8px 10px; }
}
