/* 머티리얼 Dark on Light: 회색 바탕 + 그림자로 띄운 흰 카드, 색은 슬레이트·코랄·초록 셋만.
   강좌 머리 = 원본 표 배지 색(courses.js의 color → --c), 아이디어 모음 머리 = 슬레이트, 카드가 놓이는 바닥 = 연회색 */
:root {
  --bg: #E3E7EA;
  --lane: #EEF1F3;
  --surface: #FFFFFF;
  --fill: #ECEEEF;
  --fill-2: #E2E5E7;
  --line: #D5D9DC;
  --ink: #2B3238;
  --text: #4A5258;
  --muted: #7A8288;
  --slate: #47525A;
  --slate-2: #5D6A73;
  --coral: #D46A6A;
  --green: #3E8446;
  --green-2: #5AAE61;
  --e1: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.20);
  --e2: 0 3px 6px rgba(0,0,0,.14), 0 3px 6px rgba(0,0,0,.18);
  --e3: 0 10px 20px rgba(0,0,0,.16), 0 6px 6px rgba(0,0,0,.20);
  --r: 6px;
  --slab: "Roboto Slab", Rockwell, Cambria, "Malgun Gothic", serif;
  --sans: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--slab); color: var(--ink); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
.muted { color: var(--muted); margin: 4px 0 12px; }
.eyebrow, .label { font-size: 11px; font-weight: 700; color: var(--green); letter-spacing: .04em; }
hr { border: 0; border-top: 1px solid var(--fill-2); margin: 16px 0; }
.row { display: flex; align-items: center; }
.row.gap { gap: 12px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; gap: 8px; }
.stack { display: grid; gap: 10px; }

/* 단추: 떠 있는 것 = 누르는 것 */
.btn {
  font: 600 13px var(--sans); color: var(--ink); background: var(--surface);
  border: 0; border-radius: 999px; padding: 8px 16px; box-shadow: var(--e1);
  cursor: pointer; white-space: nowrap; transition: box-shadow .15s, transform .05s;
}
.btn:hover { box-shadow: var(--e2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--slate); color: #fff; }
.btn.danger { color: var(--coral); }
.btn.small { padding: 5px 12px; font-size: 12px; }
.btn.wide { width: 100%; padding: 11px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 999px; }
.icon-btn:hover { background: var(--fill); color: var(--ink); }
:focus-visible { outline: 2px solid var(--slate); outline-offset: 2px; }

/* 입력: 회색 채움 + 밑줄 = 적는 것 */
.field { display: grid; gap: 2px; background: var(--fill); border-radius: 4px 4px 0 0; border-bottom: 2px solid var(--line); padding: 6px 10px 4px; }
.field:focus-within { border-bottom-color: var(--slate); background: var(--fill-2); }
.field > span { font-size: 11px; color: var(--muted); font-weight: 600; }
.field input, .field textarea { border: 0; background: none; font: 14px/1.45 var(--sans); color: var(--ink); padding: 2px 0; outline: none; resize: none; width: 100%; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.error { color: var(--coral); min-height: 1.4em; margin: 6px 0; font-size: 13px; }

/* 로그인 */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border-radius: var(--r); box-shadow: var(--e2); padding: 28px 24px; display: grid; gap: 12px; }
.login-card h1 { font-size: 24px; }

/* 보드 레이아웃: 화면 높이 안에서 강좌(위)와 아이디어 모음(아래)을 함께 본다 */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--surface); box-shadow: var(--e1); z-index: 2; flex-wrap: wrap; }
.facts { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.facts li { background: var(--fill); color: var(--text); font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.spacer { flex: 1; }
.people { display: flex; gap: 4px; }
.person { position: relative; font-size: 12px; font-weight: 600; padding: 3px 10px 3px 18px; border-radius: 999px; background: var(--fill); color: var(--muted); }
.person::before { content: ""; position: absolute; left: 7px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--line); }
.person.on { color: var(--ink); }
.person.on::before { background: var(--green-2); }

.board { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 14px; padding: 14px 20px 16px; }
.courses { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: auto minmax(0, 1fr); column-gap: 14px; row-gap: 6px; }
.day { grid-row: 1; display: flex; align-items: center; gap: 8px; font: 700 13px var(--slab); color: var(--ink); }
.day::after { content: ""; flex: 1; height: 2px; background: #C5CCD1; border-radius: 1px; }
.day.d1 { grid-column: 1 / span 2; }
.day.d2 { grid-column: 3 / span 2; }

.course { grid-row: 2; min-height: 0; display: flex; flex-direction: column; background: var(--lane); border-radius: var(--r); box-shadow: var(--e2); overflow: hidden; }
.course-head { padding: 12px 14px 11px; background: var(--c, var(--slate)); color: #fff; }
.course-head .label { color: rgba(255,255,255,.88); }
.course-head .label { display: flex; gap: 6px; align-items: center; }
.course-head .no { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: #fff; color: var(--c, var(--slate)); font: 700 11px var(--slab); }
.course-head h3 { font-size: 15px; margin-top: 4px; color: #fff; }
.course-head .sub { color: rgba(255,255,255,.72); font-size: 12px; }
.syllabus { margin-top: 6px; font-size: 12px; }
.syllabus summary { cursor: pointer; color: rgba(255,255,255,.88); font-weight: 600; list-style: none; }
.syllabus summary::-webkit-details-marker { display: none; }
.syllabus summary::before { content: "▸ "; }
.syllabus[open] summary::before { content: "▾ "; }
.syllabus ul { margin: 4px 0 0; padding-left: 16px; color: rgba(255,255,255,.85); }
.meter { margin-top: 8px; display: grid; gap: 3px; }
.meter .nums { display: flex; justify-content: space-between; font-size: 11px; color: rgba(255,255,255,.72); }
.meter .nums b { font: 700 13px var(--slab); color: #fff; }
.meter .bar { height: 5px; background: rgba(255,255,255,.18); border-radius: 3px; overflow: hidden; }
.meter .bar i { display: block; height: 100%; background: #fff; border-radius: 3px; }
.meter.over .bar i { background: #fff; background-image: repeating-linear-gradient(45deg, transparent 0 4px, rgba(0,0,0,.35) 4px 7px); }
.meter.over .nums span:last-child { background: #fff; color: var(--coral); font-weight: 700; padding: 0 7px; border-radius: 999px; }

.lane { position: relative; }
.course .lane { flex: 1; min-height: 80px; overflow-y: auto; padding: 24px 10px 10px; display: flex; flex-direction: column; gap: 14px; }
.lane:empty::after { content: attr(data-empty); position: absolute; inset: 12px; display: grid; place-items: center; text-align: center; border: 2px dashed #C5CCD1; border-radius: var(--r); color: var(--muted); font-size: 12px; padding: 8px; pointer-events: none; }

.pool { flex: 0 0 auto; height: 34vh; min-height: 200px; display: flex; flex-direction: column; background: var(--lane); border-radius: var(--r); box-shadow: var(--e2); overflow: hidden; }
.pool-head { display: flex; gap: 16px; align-items: flex-end; padding: 12px 14px; background: var(--slate); flex-wrap: wrap; }
.pool-head .label { color: #A9DBAE; }
.pool-head h2 { font-size: 15px; color: #fff; }
.pool-head .field { background: rgba(255,255,255,.94); border-bottom-color: rgba(0,0,0,.18); }
.pool-head .field:focus-within { background: #fff; border-bottom-color: var(--slate); }
.add { flex: 1; display: flex; gap: 8px; align-items: flex-end; min-width: 300px; }
.add .grow { flex: 1; }
.add .min { width: 86px; }
.pool-lane { flex: 1; min-height: 0; overflow-y: auto; padding: 24px 14px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px 12px; align-content: start; }

/* 인덱스 카드: 위에 작성자 탭이 튀어나온 카드 */
.card { position: relative; background: var(--surface); border-radius: 0 var(--r) var(--r) var(--r); box-shadow: var(--e1); cursor: grab; user-select: none; transition: box-shadow .15s; }
.card:hover { box-shadow: var(--e2); }
.card .tab { position: absolute; left: 0; top: -15px; height: 15px; max-width: 70%; padding: 0 9px; border-radius: 5px 5px 0 0; background: #C9D0D5; color: var(--ink); font-size: 10.5px; font-weight: 700; line-height: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; box-shadow: 0 -1px 2px rgba(0,0,0,.06); }
.card.mine .tab { background: var(--slate); color: #fff; }
.card .inner { display: flex; gap: 8px; padding: 9px 10px 8px; border-top: 2px solid #C9D0D5; border-radius: 0 var(--r) 0 0; }
.card.mine .inner { border-top-color: var(--slate); }
.card .num { flex: 0 0 auto; display: none; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--fill); color: var(--slate); font: 700 12px var(--slab); }
.course .card .num { display: inline-grid; color: var(--c, var(--slate)); }
.card .main { flex: 1; min-width: 0; }
.card .text { margin: 0; color: var(--ink); white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; gap: 10px; align-items: center; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.card .meta .mins { font-weight: 700; color: var(--slate-2); }
.card .meta .cm { display: inline-flex; gap: 3px; align-items: center; }
.card .meta .cm.has { color: var(--green); font-weight: 700; }
.card.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--green-2), var(--e2); } 100% { box-shadow: var(--e1); } }
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: var(--e3); }
.sortable-drag { cursor: grabbing; }

/* 대화상자 */
.dlg { border: 0; padding: 0; border-radius: 8px; box-shadow: var(--e3); width: min(560px, calc(100% - 32px)); max-height: calc(100% - 48px); color: var(--text); }
.dlg.wide { width: min(980px, calc(100% - 32px)); }
.dlg::backdrop { background: rgba(43,50,56,.45); }
.dlg-body { padding: 20px 22px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.detail-text { white-space: pre-wrap; word-break: break-word; color: var(--ink); font-size: 15px; margin: 10px 0 6px; }
.detail-meta { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.move-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 4px; }
.pill { border: 0; background: var(--fill); color: var(--text); font: 600 12px var(--sans); padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.pill:hover { background: var(--fill-2); }
.pill.on { background: var(--slate); color: #fff; cursor: default; }
.comments { display: grid; gap: 8px; margin: 10px 0; }
.comment { background: var(--fill); border-radius: var(--r); padding: 8px 10px; }
.comment .who { font-size: 12px; font-weight: 700; color: var(--ink); display: flex; gap: 8px; align-items: center; }
.comment .who time { font-weight: 400; color: var(--muted); }
.comment .who .icon-btn { margin-left: auto; font-size: 12px; padding: 0 6px; }
.comment p { margin: 2px 0 0; white-space: pre-wrap; word-break: break-word; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; }
.comment-form .field { flex: 1; }

.table-wrap { overflow: auto; max-height: 55vh; margin: 12px 0 16px; border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--fill-2); }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.table-wrap th, .table-wrap td { border: 1px solid var(--fill-2); padding: 6px 8px; text-align: left; vertical-align: top; white-space: pre-wrap; }
.table-wrap td:nth-child(-n+3), .table-wrap td:nth-child(5), .table-wrap td:nth-child(6), .table-wrap th { white-space: nowrap; }
.table-wrap th { background: var(--fill); color: var(--ink); position: sticky; top: 0; }
.reset-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; background: var(--fill); padding: 6px 10px; border-radius: var(--r); }
.reset-row code { font: 700 13px ui-monospace, Consolas, monospace; color: var(--coral); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--slate); color: #fff; padding: 10px 18px; border-radius: 999px; box-shadow: var(--e3); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--coral); }

/* 좁은 화면: 한 줄씩 쌓고 문서 전체를 스크롤 */
@media (max-width: 1100px) {
  .courses { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: none; }
  .day.d1, .day.d2 { grid-column: 1 / -1; grid-row: auto; }
  .course { grid-row: auto; }
  .app { height: auto; min-height: 100%; }
  .board { flex: none; }
  .courses { flex: none; }
  .course .lane { max-height: 60vh; }
  .pool { height: auto; }
  .pool-lane { max-height: 70vh; }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .facts { display: none; }
  .board { padding: 12px 16px; }
  .courses { grid-template-columns: minmax(0, 1fr); }
  .pool-head { flex-direction: column; align-items: stretch; }
  .add { min-width: 0; flex-wrap: wrap; }
  .add .min { flex: 1; }
  .add .grow { flex-basis: 100%; }
  .pool-lane { grid-template-columns: minmax(0, 1fr); }
}

/* 좁은 화면에서도 '1일차 → 1·2강좌 → 2일차 → 3·4강좌' 순으로 쌓이게 */
.day.d1 { order: 0; } .course.k1 { order: 1; } .day.d2 { order: 2; } .course.k2 { order: 3; }
