:root {
  --navy: #0d2b4a;
  --navy-2: #143d6b;
  --navy-3: #1e4d82;
  --blue: #2da8e0;
  --blue-soft: #5dbfe8;
  --blue-muted: #3d6c91;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e3e7ee;
  --border-2: #d4dae4;
  --text: #1a2435;
  --muted: #6b7790;
  --danger: #c0392b;
  --queue: #8a93a6;
  --rejected: #c0392b;
  --revision: #eab308;
  --approved: #17895a;
  --shadow: 0 1px 2px rgba(13,43,74,0.06), 0 4px 16px rgba(13,43,74,0.06);
  --shadow-lg: 0 8px 32px rgba(13,43,74,0.18);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Buffer-style thin scrollbars, applied everywhere */
* {
  scrollbar-width: thin;
  scrollbar-color: #c9d2de transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: #c9d2de;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: #a8b5c6; background-clip: padding-box; border: 2px solid transparent; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: var(--navy);
  color: #fff;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 18px; }
.brand-logo { height: 68px; width: auto; display: block; }
.subtitle {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  font-weight: 500;
  padding-left: 18px;
  border-left: 1px solid rgba(255,255,255,0.2);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* User dropdown */
.user-menu-wrap { position: relative; }
.user-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.user-menu-btn:hover { background: rgba(255,255,255,0.16); }
.user-menu-btn svg { opacity: 0.7; }
.user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 140px;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.user-menu button {
  background: transparent;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.user-menu button:hover { background: var(--bg); color: var(--navy); }
.user-menu button.active { background: rgba(45,168,224,0.12); color: var(--navy); font-weight: 600; }

.link-btn {
  background: transparent;
  color: rgba(255,255,255,0.7);
  border: none;
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  font-family: inherit;
}
.link-btn:hover { color: #fff; }

/* Buttons */
.primary-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, transform 0.05s;
}
.primary-btn:hover { background: var(--blue-soft); }
.primary-btn:active { transform: translateY(1px); }

.secondary-btn {
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.secondary-btn:hover { background: var(--navy-2); }

.text-danger {
  background: transparent;
  color: var(--danger);
  border: none;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
  padding: 6px 8px;
}
.text-danger:hover { text-decoration: underline; }

.icon-btn {
  background: transparent;
  border: none;
  width: 30px; height: 30px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--bg); color: var(--navy); }

/* Board */
.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 24px 28px;
  align-items: start;
}
.column {
  background: #eef1f6;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 300px;
  display: flex;
  flex-direction: column;
}
.col-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.col-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  flex: 1;
}
.dot { width: 10px; height: 10px; border-radius: 50%; }
.col-queue .dot { background: var(--queue); }
.col-rejected .dot { background: var(--rejected); }
.col-revision .dot { background: var(--revision); }
.col-approved .dot { background: var(--approved); }
.count {
  background: var(--bg);
  color: var(--muted);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.col-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100px;
  flex: 1;
}
.col-body.drag-over {
  background: rgba(45,168,224,0.08);
  outline: 2px dashed var(--blue);
  outline-offset: -6px;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
  user-select: none;
}
.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(13,43,74,0.12);
}
.card.dragging { opacity: 0.4; }
.card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 5px;
  background: #eef1f6;
  display: block;
}
.card-text {
  font-size: 11px;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  margin-bottom: 4px;
}
.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--muted);
  gap: 6px;
}
.card-meta .icon-inline {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.card-meta .icon-inline svg { width: 11px; height: 11px; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(13,43,74,0.55);
  backdrop-filter: blur(2px);
}
.modal-panel {
  position: relative;
  width: min(1320px, 96vw);
  height: 94vh;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-close {
  position: absolute; top: 10px; right: 14px;
  background: transparent; border: none;
  font-size: 28px; line-height: 1;
  color: var(--muted);
  cursor: pointer;
  z-index: 2;
}
.modal-close:hover { color: var(--text); }
.modal-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 0;
  flex: 1;
  min-height: 0;
}

/* Editor */
.editor {
  padding: 32px 36px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.editor-header h3, .preview-pane h3 {
  margin: 0;
  font-size: 16px;
  color: var(--navy);
  font-weight: 700;
}
#status-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}

/* Buffer-style composer */
.composer {
  border: 1px solid var(--border-2);
  border-radius: 10px;
  background: #fff;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(45,168,224,0.15);
}
.composer.drag-over {
  border-color: var(--blue);
  background: rgba(45,168,224,0.03);
}
#post-content {
  width: 100%;
  min-height: 220px;
  padding: 18px 18px 6px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  resize: none;
  overflow: hidden;
  line-height: 1.6;
  outline: none;
  color: var(--text);
}
.thumb-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 18px 12px;
}
.thumb-strip:empty { padding: 0; }
.thumb-item {
  position: relative;
  width: 130px;
  height: 130px;
  border-radius: 8px;
  overflow: hidden;
  background: #eef1f6;
  border: 1px solid var(--border);
  cursor: zoom-in;
}
.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-item .thumb-x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(13,43,74,0.78);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.thumb-item:hover .thumb-x { opacity: 1; }
.thumb-item .thumb-x:hover { background: var(--danger); }
.thumb-item.uploading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.7) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 50 50'><circle cx='25' cy='25' r='20' fill='none' stroke='%232da8e0' stroke-width='5' stroke-linecap='round' stroke-dasharray='90 150'><animateTransform attributeName='transform' type='rotate' from='0 25 25' to='360 25 25' dur='1s' repeatCount='indefinite'/></circle></svg>") center / 28px no-repeat;
}
.composer-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 10px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.composer-hint { font-size: 12px; color: var(--muted); flex: 1; }
.char-count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  padding: 3px 10px;
  background: #fff;
  min-width: 44px;
  text-align: center;
}

/* Schedule row */
.schedule-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}
.schedule-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.schedule-picker-wrap { position: relative; display: flex; align-items: center; gap: 10px; }
.schedule-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.schedule-btn:hover { border-color: var(--blue); color: var(--navy); }
.schedule-btn svg { color: var(--blue); }
.schedule-picker-wrap .link-btn {
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
}
.schedule-picker-wrap .link-btn:hover { color: var(--danger); text-decoration: underline; }

.schedule-popover {
  position: fixed;
  width: 320px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 14px;
  z-index: 500;
}
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cal-header span {
  font-weight: 700;
  color: var(--navy);
  font-size: 14px;
}
.cal-nav {
  background: transparent;
  border: none;
  width: 28px; height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  color: var(--muted);
  font-family: inherit;
}
.cal-nav:hover { background: var(--bg); color: var(--navy); }
.cal-weekdays, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-weekdays {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
  margin-bottom: 4px;
}
.cal-weekdays span { padding: 4px 0; }
.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.cal-day:hover { background: var(--bg); }
.cal-day.other-month { color: #c7cfdb; }
.cal-day.today { font-weight: 700; color: var(--blue); }
.cal-day.selected { background: var(--blue); color: #fff; font-weight: 700; }
.cal-day.selected:hover { background: var(--blue); }
.cal-day.disabled { opacity: 0.3; cursor: default; }

.time-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.time-block label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.time-input-wrap { position: relative; }
#time-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: #fff;
}
#time-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(45,168,224,0.15);
}
.time-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  max-height: 180px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 5;
}
.time-option {
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}
.time-option:hover, .time-option.highlight { background: rgba(45,168,224,0.12); }
.time-option.selected { background: rgba(45,168,224,0.2); color: var(--navy); font-weight: 600; }

.schedule-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}
.schedule-actions .link-btn { color: var(--muted); text-decoration: none; font-size: 13px; padding: 8px 12px; }
.schedule-actions .link-btn:hover { color: var(--navy); }

.editor-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.spacer { flex: 1; }

/* Comments pane */
.preview-pane {
  padding: 28px;
  background: #f7f9fc;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 14px 0 12px;
  flex: 1;
  min-height: 100px;
}
.thread { display: flex; flex-direction: column; gap: 6px; }
.comment-reply {
  margin-left: 24px;
  position: relative;
  background: #f9fbfd;
}
.comment-reply::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 18px;
  width: 10px;
  height: 1px;
  background: var(--border-2);
}
.comment-reply::after {
  content: "";
  position: absolute;
  left: -14px;
  top: 0;
  bottom: 50%;
  width: 1px;
  background: var(--border-2);
}
.comment {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}
.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.comment-author { font-weight: 700; color: var(--navy); font-size: 13px; }
.comment-time { font-size: 11px; color: var(--muted); }
.comment-body { white-space: pre-wrap; word-wrap: break-word; }
.comment-body[contenteditable="true"] {
  outline: 1px solid var(--blue);
  border-radius: 4px;
  padding: 4px;
  background: #f0f9ff;
}
.comment-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  font-size: 11px;
}
.comment-actions button {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  font-size: 11px;
}
.comment-actions button:hover { color: var(--navy); text-decoration: underline; }
.comment-actions .delete:hover { color: var(--danger); }
.comment-actions .reply:hover { color: var(--blue); }

/* Inline reply composer */
.reply-composer {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.reply-composer textarea {
  width: 100%;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  background: #fff;
}
.reply-composer textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(45,168,224,0.15);
}
.reply-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}
.reply-actions .link-btn { color: var(--muted); text-decoration: none; font-size: 12px; }
.reply-actions .link-btn:hover { color: var(--navy); text-decoration: underline; }
.reply-actions .primary-btn { padding: 6px 14px; font-size: 12px; }

.comment-composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
#comment-input {
  flex: 1;
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  background: #fff;
}
#comment-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(45,168,224,0.15);
}

/* Gate */
.gate {
  position: fixed;
  inset: 0;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.gate-card {
  background: #fff;
  padding: 40px 48px;
  border-radius: 14px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.gate-logo { height: 112px; margin-bottom: 22px; }
.gate-card h1 { font-size: 20px; margin: 0 0 6px; color: var(--navy); }
.gate-card p { margin: 0 0 20px; color: var(--muted); }
.identity-buttons { display: flex; gap: 12px; justify-content: center; }
.identity-buttons button {
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 10px 28px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.identity-buttons button:hover { background: var(--blue); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 300;
  box-shadow: var(--shadow-lg);
}

/* Confirm dialog */
.confirm {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13,43,74,0.6);
}
.confirm-panel {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 24px 26px;
  width: min(440px, 92vw);
  box-shadow: var(--shadow-lg);
}
.confirm-panel h3 {
  margin: 0 0 8px;
  font-size: 17px;
  color: var(--navy);
  font-weight: 700;
}
.confirm-panel p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 95vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.lightbox-close {
  position: absolute;
  top: 16px; right: 20px;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255,255,255,0.25); }

/* Responsive */
@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; }
  .modal-grid { grid-template-columns: 1fr; }
  .editor { border-right: none; border-bottom: 1px solid var(--border); }
}
