:root {
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #182033;
  background: #f5f7fa;
  font-synthesis: none;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #e4e9f0;
  --line-strong: #d5dce7;
  --text: #182033;
  --muted: #697386;
  --muted-2: #8a94a6;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --danger: #dc2626;
  --danger-soft: #fff1f2;
  --shadow: 0 12px 36px rgba(30, 41, 59, .07);
  --shadow-dialog: 0 24px 70px rgba(15, 23, 42, .22);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; background: #f5f7fa; color: var(--text); }
body.modal-open { overflow: hidden; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(37, 99, 235, .2); outline-offset: 2px; }

.topbar { background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); }
.topbar-inner { width: min(1180px, calc(100% - 40px)); min-height: 86px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-block; color: var(--text); text-decoration: none; font-size: 24px; line-height: 1.1; font-weight: 760; letter-spacing: -.03em; }
.brand-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.topbar-link { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 650; }
.topbar-link:hover { color: var(--primary); }

.public-main, .manage-main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.public-main { padding: 32px 0 44px; }
.manage-main { padding: 48px 0 56px; }

.hero-banner { margin-bottom: 30px; overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.hero-banner img { display: block; width: 100%; height: clamp(140px, 20vw, 220px); object-fit: cover; object-position: center; }

.portfolio-intro { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 28px; padding: 8px 2px 26px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
.portfolio-intro h1, .manage-heading h1 { margin: 0; font-size: clamp(28px, 4vw, 38px); line-height: 1.15; letter-spacing: -.04em; }
.portfolio-intro p:not(.eyebrow), .manage-heading p:not(.eyebrow) { margin: 9px 0 0; color: var(--muted); line-height: 1.6; font-size: 14px; }
.portfolio-count { flex: none; color: var(--muted-2); font-size: 13px; padding-bottom: 3px; }

.program-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.program-card { min-width: 0; height: 100%; padding: 0; overflow: hidden; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: inherit; text-align: left; cursor: pointer; box-shadow: 0 2px 10px rgba(15, 23, 42, .025); transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.program-card:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.program-thumb { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #eef1f5; border-bottom: 1px solid var(--line); }
.program-card-body { min-height: 190px; padding: 16px 16px 15px; display: flex; flex-direction: column; }
.program-title { min-height: 2.8em; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; color: var(--text); font-size: 17px; font-weight: 730; line-height: 1.4; letter-spacing: -.015em; }
.program-description { min-height: 4.65em; margin-top: 7px; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; color: var(--muted); font-size: 13px; line-height: 1.55; }
.program-date { margin-top: auto; padding-top: 13px; color: var(--muted-2); font-size: 11px; line-height: 1; }
.thumb-placeholder { display: grid; place-items: center; background: #eef1f5; color: #9aa4b4; font-size: 12px; }

.empty { margin: 0; padding: 86px 0; color: var(--muted); text-align: center; }
.pagination { margin-top: 30px; display: flex; justify-content: center; align-items: center; gap: 7px; }
.page-button { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); cursor: pointer; }
.page-button:hover:not(:disabled) { border-color: #bfd0f7; color: var(--primary); }
.page-button.active { border-color: var(--primary); background: var(--primary); color: #fff; font-weight: 700; }
.page-button:disabled { opacity: .38; cursor: default; }

.site-footer { margin-top: 52px; padding: 22px 2px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.7; }
.footer-title strong { color: #465064; font-weight: 700; }
.footer-links { margin-top: 3px; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--primary); text-decoration: underline; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: rgba(15, 23, 42, .56); backdrop-filter: blur(5px); }
.modal[hidden] { display: none; }
.dialog { position: relative; width: min(820px, 100%); max-height: min(90vh, 900px); overflow: auto; border: 1px solid rgba(255,255,255,.6); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-dialog); }
.icon-button { border: 0; background: transparent; color: #697386; cursor: pointer; }
.close { position: absolute; z-index: 2; top: 14px; right: 16px; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 9px; font-size: 27px; line-height: 1; }
.close:hover { background: #f1f4f8; color: var(--text); }
.program-dialog { padding: 28px; }
.program-dialog-grid { display: grid; grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr); gap: 28px; align-items: start; }
.program-dialog-media { min-width: 0; }
.modal-thumb { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border: 1px solid var(--line); border-radius: 12px; background: #eef1f5; }
.program-dialog-content { min-width: 0; padding: 8px 36px 0 0; }
.program-dialog-content h2 { margin: 0; font-size: 24px; line-height: 1.3; letter-spacing: -.025em; }
.modal-date { margin: 8px 0 0; color: var(--muted-2); font-size: 12px; }
.modal-description { margin: 22px 0 0; color: #4f596b; font-size: 14px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.file-meta { margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.actions { display: flex; align-items: center; gap: 10px; }
.modal-actions { margin-top: 24px; flex-wrap: wrap; }
.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 15px; border: 1px solid transparent; border-radius: 9px; text-decoration: none; font-weight: 650; font-size: 13px; cursor: pointer; transition: background .15s ease, border-color .15s ease, color .15s ease; }
.button.primary { background: var(--primary); color: #fff; }
.button.primary:hover { background: #1d4ed8; }
.button.secondary { border-color: var(--line); background: #f8fafc; color: #465064; }
.button.secondary:hover { background: #eef2f7; }
.button.link { border-color: #c7d2fe; background: #eef2ff; color: #3156d3; }
.button.link:hover { background: #dfe8ff; border-color: #aebefc; color: #2447bb; }
.button.danger-outline { border-color: #fecdd3; background: #fff; color: var(--danger); }
.button.danger-outline:hover:not(:disabled) { background: var(--danger-soft); }
.button:disabled { opacity: .45; cursor: default; }

/* Manage */
.manage-heading { min-height: 96px; display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.add-button { min-width: 86px; }
.manage-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.search-field { width: min(420px, 100%); }
.search-field input { height: 46px; font-size: 14px; }
.toolbar-actions { display: flex; align-items: center; gap: 10px; }
.view-switch { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #f6f8fb; }
.view-button { min-width: 74px; height: 38px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 650; cursor: pointer; }
.view-button.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 5px rgba(15,23,42,.08); }
.selection-summary { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 13px; }
.check-label { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; color: var(--muted); }
.check-label input, .item-select { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }

.manage-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.manage-card { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.manage-card.selected { border-color: #8fb3ff; box-shadow: 0 0 0 1px #8fb3ff inset; }
.manage-card-check { position: absolute; z-index: 2; top: 9px; left: 9px; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid rgba(213,220,231,.9); border-radius: 8px; background: rgba(255,255,255,.94); box-shadow: 0 2px 8px rgba(15,23,42,.06); }
.manage-thumb { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #eef1f5; border-bottom: 1px solid var(--line); }
.manage-card-body { min-height: 172px; padding: 15px; display: flex; flex-direction: column; }
.manage-card-body > .title-open-button { min-height: 2.7em; }
.manage-card-body > p { margin: 8px 0 0; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; color: var(--muted); font-size: 12px; line-height: 1.55; }
.manage-card-body > small { margin-top: 10px; color: var(--muted-2); font-size: 11px; }
.manage-card-actions { margin-top: auto; padding-top: 11px; display: flex; gap: 12px; border-top: 1px solid var(--line); }
.text-button { padding: 0; border: 0; background: none; color: var(--primary); font-size: 13px; font-weight: 650; cursor: pointer; }
.text-button.danger { color: var(--danger); }

.manage-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.manage-table { width: 100%; min-width: 820px; border-collapse: collapse; font-size: 13px; }
.manage-table th { padding: 12px 13px; background: #f7f9fc; color: var(--muted); font-weight: 650; text-align: left; white-space: nowrap; }
.manage-table td { padding: 11px 13px; border-top: 1px solid var(--line); color: #4f596b; vertical-align: middle; }
.manage-table tr.selected td { background: var(--primary-soft); }
.manage-table strong { color: var(--text); font-weight: 650; }
.check-column { width: 42px; }
.action-column { width: 110px; }
.table-thumb { width: 76px; aspect-ratio: 16 / 9; object-fit: cover; border: 1px solid var(--line); border-radius: 7px; background: #eef1f5; }
.table-description { max-width: 400px; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; color: var(--muted); line-height: 1.45; }
.nowrap { white-space: nowrap; }
.manage-table .text-button + .text-button { margin-left: 12px; }

input, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; color: var(--text); padding: 11px 12px; font: inherit; font-size: 14px; }
input { min-height: 40px; }
textarea { min-height: 132px; resize: vertical; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: #a2aabb; }
label { display: grid; gap: 7px; color: #465064; font-size: 13px; font-weight: 650; }

.editor-dialog { width: min(820px, 100%); padding: 26px; }
.dialog-heading { padding-right: 50px; margin-bottom: 20px; }
.dialog-heading h2 { margin: 0; font-size: 22px; letter-spacing: -.025em; }
.dialog-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.editor-form { display: grid; gap: 14px; }
.editor-columns { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 22px; }
.editor-assets, .editor-fields { display: grid; align-content: start; gap: 14px; }
.current-asset { padding: 10px; display: flex; align-items: center; flex-wrap: wrap; gap: 9px; border: 1px solid var(--line); border-radius: 9px; background: #f8fafc; }
.current-asset[hidden] { display: none; }
.current-asset-label { width: 100%; color: var(--muted); font-size: 11px; font-weight: 700; }
.current-asset img { width: 112px; aspect-ratio: 16 / 9; object-fit: cover; border: 1px solid var(--line); border-radius: 7px; background: #eef1f5; }
.current-asset strong { font-size: 12px; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 12px; }
.status { min-height: 20px; margin: 0; color: var(--muted); font-size: 13px; }
.editor-actions { justify-content: flex-end; padding-top: 6px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 1000px) {
  .program-grid, .manage-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topbar-inner, .public-main, .manage-main { width: min(100% - 28px, 1180px); }
  .topbar-inner { min-height: 76px; }
  .public-main { padding-top: 38px; }
  .portfolio-intro, .manage-heading { align-items: flex-start; flex-direction: column; }
  .program-grid, .manage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .program-dialog-grid, .editor-columns { grid-template-columns: 1fr; }
  .program-dialog-content { padding-right: 34px; }
  .manage-toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .toolbar-actions { justify-content: space-between; }
}

@media (max-width: 520px) {
  .brand { font-size: 21px; }
  .program-grid, .manage-grid { grid-template-columns: 1fr; }
  .program-card-body { min-height: 174px; }
  .modal { padding: 12px; }
  .program-dialog, .editor-dialog { padding: 20px; border-radius: 14px; }
  .program-dialog-grid { gap: 18px; }
  .toolbar-actions { align-items: stretch; flex-direction: column; }
  .view-switch { width: 100%; }
  .view-button { flex: 1; }
  .button.danger-outline { width: 100%; }
  .selection-summary { align-items: flex-start; flex-direction: column; padding: 10px 0; }
  .footer-links { row-gap: 3px; }
}


.manage-heading h1 { margin: 0; font-size: clamp(30px, 4vw, 40px); line-height: 1.15; letter-spacing: -.04em; }
.manage-heading p:not(.eyebrow) { margin: 10px 0 0; color: var(--muted); line-height: 1.65; font-size: 15px; }
.item-open-button, .thumb-open-button, .title-open-button { padding: 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; }
.thumb-open-button { display: block; width: 100%; }
.title-open-button { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; line-height: 1.4; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.title-open-button:hover { color: var(--primary); }
.table-open-button { display: inline-block; }
.manage-card .thumb-open-button .manage-thumb { border-bottom: 1px solid var(--line); }
.manage-card .thumb-open-button:hover .manage-thumb, .table-open-button:hover .table-thumb { filter: brightness(.985); }
.manage-card-body .title-open-button { margin: 0; }
.manage-table .title-open-button strong { font-size: 14px; font-weight: 700; }
@media (max-width: 760px) {
  .public-main { padding-top: 24px; }
  .hero-banner { margin-bottom: 22px; border-radius: 18px; }
}

/* Public search */
.public-search { display: flex; justify-content: flex-end; margin: 0 0 22px; }
.public-search-field { position: relative; display: block; width: min(420px, 100%); }
.public-search-field input { height: 44px; padding: 10px 14px 10px 42px; border-radius: 11px; background: var(--surface); font-size: 14px; box-shadow: 0 1px 3px rgba(15, 23, 42, .025); }
.public-search-field input:focus { border-color: #a9bff5; }
.search-icon { position: absolute; z-index: 1; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted-2); font-size: 21px; line-height: 1; pointer-events: none; }

/* Program image viewer */
.modal-thumb-button { display: block; width: 100%; padding: 0; border: 0; border-radius: 12px; background: none; cursor: zoom-in; }
.modal-thumb-button .modal-thumb { transition: filter .15s ease, transform .15s ease; }
.modal-thumb-button:hover .modal-thumb { filter: brightness(.97); }
.modal-thumb-button:focus-visible { outline: 3px solid rgba(37, 99, 235, .25); outline-offset: 3px; }
.image-viewer { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 36px; background: rgba(7, 12, 24, .9); backdrop-filter: blur(8px); }
.image-viewer[hidden] { display: none; }
.image-viewer img { display: block; max-width: 96vw; max-height: 92vh; width: auto; height: auto; object-fit: contain; border-radius: 8px; box-shadow: 0 24px 80px rgba(0, 0, 0, .38); }
.image-viewer-close { position: fixed; z-index: 101; top: 18px; right: 22px; width: 44px; height: 44px; padding: 0; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.22); border-radius: 12px; background: rgba(15, 23, 42, .66); color: #fff; font-size: 30px; line-height: 1; cursor: pointer; }
.image-viewer-close:hover { background: rgba(30, 41, 59, .92); }

@media (max-width: 760px) {
  .public-search { justify-content: stretch; }
  .public-search-field { width: 100%; }
  .image-viewer { padding: 18px; }
  .image-viewer-close { top: 10px; right: 10px; }
}
