:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e4e9;
  --text: #16181d;
  --text-muted: #6b7280;
  --text-faint: #9aa0ac;
  --accent: #16181d;
  --today-bg: #eef2ff;
  --today-border: #c7d2fe;
  --posted-bg: #f7f8f9;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);
  --shadow-hover: 0 4px 10px rgba(16, 24, 40, 0.10), 0 2px 4px rgba(16, 24, 40, 0.06);
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.topbar-inner h1 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.weeks-select-wrap select {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.week-label {
  font-size: 14px;
  color: var(--text-muted);
  min-width: 150px;
  text-align: center;
  font-weight: 500;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--bg); }

.today-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.today-btn:hover { background: var(--bg); }

/* ---------- Board ---------- */

.board {
  max-width: 1500px;
  margin: 0 auto;
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.week-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 900px) {
  .week-row {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }
  .day-col {
    flex: 0 0 78vw;
    scroll-snap-align: start;
  }
}

.day-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.day-col.is-today {
  background: var(--today-bg);
  border-color: var(--today-border);
}

.day-col.drag-over {
  outline: 2px dashed #6366f1;
  outline-offset: -4px;
}

.day-header {
  padding: 7px 10px 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.day-col.is-today .day-header { border-bottom-color: var(--today-border); }

.day-name {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.day-col.is-today .day-name { color: #4338ca; }

.day-date {
  font-size: 12px;
  font-weight: 600;
}

.day-body {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 44px;
}

.day-empty-hint {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  padding: 10px 6px;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

/* ---------- Card ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 7px 8px 7px 4px;
  display: flex;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  touch-action: pan-y;
}

.card:hover { box-shadow: var(--shadow-hover); }

.card.is-posted {
  background: var(--posted-bg);
  opacity: 0.7;
}

.card.is-dragging {
  opacity: 0.35;
}

.drag-handle {
  flex: 0 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 14px;
  cursor: grab;
  touch-action: none;
  border-radius: 6px;
}
.drag-handle:hover { background: var(--bg); color: var(--text-muted); }
.drag-handle:active { cursor: grabbing; }

.card-main {
  flex: 1;
  min-width: 0;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}

.tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 1.5px 6px;
  border-radius: 999px;
  color: #fff;
  white-space: nowrap;
}

.posted-badge {
  font-size: 12px;
  color: #16a34a;
}

.card-title {
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.28;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card.is-posted .card-title { text-decoration: line-through; color: var(--text-muted); }

.card-preview {
  display: none;
}

@media (min-width: 901px) {
  .card-preview {
    display: -webkit-box;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.35;
    margin-top: 3px;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* drag ghost */
.drag-ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  width: 260px;
  transform: translate(-50%, -50%) rotate(-2deg);
  box-shadow: var(--shadow-hover);
  border-radius: 10px;
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 21, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 0;
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
    padding: 20px;
  }
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 18px 18px 22px;
}

@media (min-width: 640px) {
  .modal { border-radius: 16px; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.modal h2 {
  font-size: 18px;
  margin: 0 0 4px;
  line-height: 1.3;
}

.modal-date {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.modal-body {
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin: 0 0 16px;
  max-height: 45vh;
  overflow-y: auto;
}

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

.btn {
  flex: 1;
  min-width: 140px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--text);
  color: #fff;
}
.btn-primary:hover { background: #000; }

.btn-outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

.btn-outline.is-active {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #15803d;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #16181d;
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 100;
  box-shadow: var(--shadow-hover);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(6px); }
