/* 연비서(連) 데모 콘솔 — 빌드 없음, 외부 폰트·CDN 없음.
   두 색 틀이 화면의 주장을 대신한다: 회청 = 개인 비서 창(개인 계층), 크림 = 공용 게시판·교환 띠(팀 계층). */

:root {
  --ink: #1b2430;
  --muted: #52606d;
  --faint: #8a949e;
  --accent: #b4650f;
  --accent-dark: #8d4e0b;
  --page: #f4f5f3;

  --win-bg: #f5f8fb;
  --win-head: #e6edf3;
  --win-line: #c9d4de;
  --win-user: #dfe7ef;

  --team-bg: #fbf7ee;
  --team-head: #f6efdf;
  --team-line: #e3d9c4;
  --team-soft: #f1ebdd;
  --team-day: #fffdf8;

  --pro-bg: #fff4e6;
  --pro-strong: #fde0bd; /* 개인 메모 패널(--pro-bg) 안에서 한 단계 더 진한 강조 */
  --pro-line: #ecd3b3;
  --ok-bg: #e3f0e8;
  --ok-ink: #2f6f4f;
  --no-bg: #f4dede;
  --no-ink: #9b2c2c;
  --wait-bg: #fbe9d2;
  --wait-ink: #9a5408;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", Roboto, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── 상단 바 ─────────────────────────────────────────────────────────── */
.topbar {
  height: 54px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid #dcdfe2;
}
.brand { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.brand h1 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin: 0; white-space: nowrap; flex: 0 0 auto; }
.brand p { margin: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; }
#clock {
  white-space: nowrap;
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.topbar-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.legend { display: flex; align-items: center; gap: 12px; font-size: 11.5px; color: var(--muted); margin-right: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch.personal { background: var(--win-head); border: 1px solid var(--win-line); }
.swatch.team { background: var(--team-head); border: 1px solid var(--team-line); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--win-line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  background: #fff;
  color: var(--ink);
  white-space: nowrap;
}
.chip:hover { border-color: var(--accent); }
.chip.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.chip.primary:hover { background: var(--accent-dark); }
.chip.tall { height: 36px; padding: 0 14px; }
.chip.flash { box-shadow: 0 0 0 3px rgba(180, 101, 15, 0.28); }
.chip.pulse { border-color: var(--accent); color: var(--accent); font-weight: 700; animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(180, 101, 15, 0.35); }
  50% { box-shadow: 0 0 0 5px rgba(180, 101, 15, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .chip.pulse { animation: none; box-shadow: 0 0 0 3px rgba(180, 101, 15, 0.28); }
}
.linkish {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chip[disabled] { opacity: 0.5; cursor: default; }
.chip[aria-pressed="false"] { color: var(--faint); }
.chip[aria-pressed="false"] svg { opacity: 0.6; }

.kv { font-size: 11.5px; color: var(--muted); }

/* ── 본문 3열 ────────────────────────────────────────────────────────── */
.console {
  flex: 1 1 auto;
  display: flex;
  gap: 14px;
  padding: 14px 20px 0;
  min-height: 0;
}
.col { width: 350px; flex: 0 0 auto; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.tabs { display: none; gap: 6px; padding: 8px 20px 0; }

/* ── 개인 비서 창 ────────────────────────────────────────────────────── */
.win {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  background: var(--win-bg);
  border: 1px solid var(--win-line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(20, 24, 30, 0.06);
  min-height: 0;
}
.win.playing { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(180, 101, 15, 0.12); }
.win.awaiting { box-shadow: 0 0 0 3px rgba(180, 101, 15, 0.3); }
.w-step { color: var(--accent); font-weight: 700; }
.win-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--win-line);
  background: var(--win-head);
}
.win-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.win-title b { font-size: 13px; }
.memo-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: none;
  padding: 2px 4px;
  font-size: 11.5px;
  color: var(--muted);
  border-radius: 6px;
}
.memo-toggle[aria-expanded="true"] { color: var(--accent); font-weight: 700; }
.memo-toggle svg { transition: transform 0.15s ease; }
.memo-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }

.memo {
  flex: 0 0 auto;
  padding: 8px 12px;
  background: var(--pro-bg);
  border-bottom: 1px dashed var(--pro-line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* 대화를 가리지 않는 선. 메모는 자체 스크롤을 갖고, 대화는 늘 최근 몇 개가 보인다. */
  max-height: min(30%, 140px);
  overflow-y: auto;
}
.memo-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.memo h3 { margin: 0; font-size: 11px; font-weight: 700; color: var(--accent); }
.memo-close {
  border: 0;
  background: none;
  padding: 0 2px;
  font-size: 11px;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}
.memo p { margin: 0; font-size: 12px; line-height: 1.45; }
.memo p.fresh { background: var(--pro-strong); border-radius: 5px; padding: 2px 4px; margin: -2px -4px; }
.memo .kv { display: block; }

.log {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  overflow-y: auto;
  min-height: 110px; /* 메모를 펼쳐도 최근 메시지 서넛은 보인다 */
}
.msg {
  font-size: 12.5px;
  line-height: 1.5;
  padding: 7px 10px;
  border-radius: 10px;
  max-width: 92%;
  white-space: pre-line;
  word-break: break-word;
}
.msg.user { align-self: flex-end; background: var(--win-user); }
.msg.assistant { align-self: flex-start; background: #fff; border: 1px solid #d3dce5; }
.msg.proactive { align-self: flex-start; background: var(--pro-bg); border: 1px solid var(--pro-line); }
.msg.notice { align-self: center; background: var(--wait-bg); color: var(--wait-ink); font-size: 12px; }

.win-buttons { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.win-form { display: flex; gap: 8px; padding: 0 12px 10px; }
.win-form input {
  flex: 1 1 auto;
  height: 36px;
  border: 1px solid var(--win-line);
  background: #fff;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 12.5px;
  color: var(--ink);
  min-width: 0;
}
.win-form input::placeholder { color: var(--faint); }
.win-form input.prefilled { border-color: var(--accent); background: var(--pro-bg); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── 공용 게시판 ─────────────────────────────────────────────────────── */
.board {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  background: var(--team-bg);
  border: 1px solid var(--team-line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(20, 24, 30, 0.06);
  min-width: 0;
}
.board-head, .strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--team-line);
  background: var(--team-head);
}
.board-head h2, .strip-head h2 { margin: 0; font-size: 13px; font-weight: 700; }
.board-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  overflow-y: auto;
  min-height: 0;
}
.counters { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.bcard {
  background: #fff;
  border: 1px solid var(--team-line);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.bcard.tight { gap: 2px; }
.bcard.current { border-color: var(--accent); }
.bh { font-size: 11px; font-weight: 700; color: #7a5a2a; letter-spacing: 0.05em; }
.num { font-size: 20px; font-weight: 700; }
.num.warn { color: var(--wait-ink); }
.card-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-title b { font-size: 13px; }
.requests { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 6px;
  background: #ece6d8;
  color: var(--muted);
  white-space: nowrap;
}
.tag.ok { background: var(--ok-bg); color: var(--ok-ink); }
.tag.wait { background: var(--wait-bg); color: var(--wait-ink); }
.tag.done { background: var(--accent); color: #fff; }

.grid { display: grid; gap: 4px; margin-top: 2px; }
.cell { min-height: 26px; display: flex; align-items: center; justify-content: center; font-size: 12px; border-radius: 6px; padding: 2px 4px; text-align: center; }
.cell.ok { background: var(--ok-bg); color: var(--ok-ink); }
.cell.no { background: var(--no-bg); color: var(--no-ink); font-weight: 700; }
.cell.pending { background: var(--wait-bg); color: var(--wait-ink); }
.cell.hd { background: transparent; color: var(--muted); font-size: 11px; }
.cell.hd.left { justify-content: flex-start; }
.rows { display: flex; flex-direction: column; gap: 3px; font-size: 12px; margin-top: 2px; }
.rows .row { display: flex; justify-content: space-between; gap: 8px; }
.rows .line { display: flex; gap: 8px; }
.rows .when { width: 68px; flex: 0 0 auto; }

.week { display: flex; gap: 6px; }
.day {
  flex: 1 1 0;
  border: 1px solid var(--team-line);
  border-radius: 8px;
  padding: 6px 7px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  background: var(--team-day);
}
.ev { font-size: 11px; line-height: 1.3; padding: 3px 5px; border-radius: 5px; background: var(--team-soft); }
.ev.warn { background: var(--wait-bg); }
.ev.new { background: var(--accent); color: #fff; font-weight: 700; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 10px; }

/* ── 교환 띠 ─────────────────────────────────────────────────────────── */
.strip {
  flex: 0 0 auto;
  margin: 12px 20px 14px;
  background: var(--team-bg);
  border: 1px solid var(--team-line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(20, 24, 30, 0.06);
}
.strip-body { display: flex; gap: 8px; padding: 9px 14px; overflow-x: auto; align-items: stretch; min-height: 62px; }
.xcard {
  flex: 1 1 0;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--team-line);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.xcard.last { background: var(--pro-bg); border-color: var(--accent); }

/* hidden 속성은 어떤 display 규칙보다 우선한다 — .backdrop{display:flex} 가 [hidden] 을 덮어 모달이 닫힌 뒤에도 클릭을 가로챘다. */
[hidden] { display: none !important; }

/* ── 모달 ────────────────────────────────────────────────────────────── */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 30, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--win-line);
  padding: 20px 22px;
  max-width: 520px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal h2 { margin: 0; font-size: 15px; }
.modal p { margin: 0; font-size: 13px; line-height: 1.6; white-space: pre-line; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
#modal-extra:empty { display: none; }
#modal-extra textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--win-line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink);
}
#modal-extra textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#modal-extra .counter { text-align: right; margin-top: 4px; }
.popover {
  position: absolute;
  top: 50px;
  right: 20px;
  z-index: 25;
  width: 400px;
  max-width: calc(100vw - 40px);
  background: #fff;
  border: 1px solid var(--win-line);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(20, 24, 30, 0.16);
}
.popover h2 { margin: 0 0 6px; font-size: 12px; font-weight: 700; color: var(--accent); }
.popover p { margin: 0; font-size: 12.5px; line-height: 1.65; color: var(--muted); }

.banner {
  flex: 0 0 auto;
  margin: 0 20px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--wait-bg);
  color: var(--wait-ink);
  font-size: 12.5px;
}

/* ── 좁은 화면: 창 4개를 탭으로, 게시판을 아래로 ─────────────────────── */
@media (max-width: 1199px) {
  body { overflow: auto; }
  .tabs { display: flex; }
  .console { flex-direction: column; padding: 8px 20px 0; }
  .col { width: auto; flex: 0 0 auto; }
  .win { display: none; min-height: 380px; }
  .win.tab-active { display: flex; }
  .board { min-height: 620px; }
  .counters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .week { flex-wrap: wrap; }
  .day { flex: 1 1 30%; }
  .legend { display: none; }
}
