:root {
  --bg: #f5f6f8; --panel: #fff; --line: #e3e6eb; --text: #1b1f27; --muted: #6b7280; --accent: #3b5bdb; --accent-soft: #edf2ff;
  --draft: #868e96; --confirmed: #3b5bdb; --live: #e03131; --completed: #2f9e44; --cancelled: #adb5bd;
  --flash: #ffe066; --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--text); background: var(--bg); font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; }
.mobile-only { display: none; }
[hidden] { display: none !important; }

.btn { border: 1px solid var(--line); background: var(--panel); padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f1f3f5; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger { color: var(--live); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
input[type=text], input[type=email], input[type=url], input[type=date], input[type=time], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; width: 100%;
}
textarea { resize: vertical; }
label.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.empty { color: var(--muted); padding: 16px; text-align: center; }

/* status */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; color: #fff; background: var(--draft); }
.s-draft { --c: var(--draft); } .s-confirmed { --c: var(--confirmed); } .s-live { --c: var(--live); }
.s-completed { --c: var(--completed); } .s-cancelled { --c: var(--cancelled); }
.badge[class*=s-] { background: var(--c); }
.s-live.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--cancelled); }
.dot.ok { background: var(--completed); }

/* shell */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: #141821; color: #cfd4dc; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.side .logo { color: #fff; font-weight: 800; font-size: 18px; padding: 0 10px 18px; letter-spacing: -.3px; }
.side .logo span { color: #ff6b6b; }
.logo small { display: block; font-size: 10px; font-weight: 700; letter-spacing: 2px; opacity: .7; }
.side a { color: inherit; text-decoration: none; padding: 9px 10px; border-radius: 8px; }
.side a:hover, .side a.active { background: #262c38; color: #fff; }
.side .me { margin-top: auto; font-size: 12px; padding: 10px; border-top: 1px solid #262c38; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top h2 { font-size: 17px; }
main { padding: 20px 24px; min-width: 0; }
.devbar { background: #fff3bf; color: #6b5200; font-size: 12px; padding: 4px 24px; }

/* notifications */
.bell { position: relative; }
.bell .count { position: absolute; top: -6px; right: -6px; background: var(--live); color: #fff; border-radius: 99px; font-size: 10px; padding: 1px 5px; }
.dropdown { position: absolute; right: 24px; top: 52px; width: 340px; max-height: 420px; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.12); z-index: 50; }
.dropdown .item { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.dropdown .item.unread { background: var(--accent-soft); }

/* calendar */
.cal-head { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.cal-head h3 { font-size: 18px; min-width: 150px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 12px; cursor: pointer; }
.seg button.on { background: var(--text); color: #fff; }
.legend { display: flex; gap: 10px; font-size: 12px; color: var(--muted); margin-left: auto; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); margin-right: 4px; vertical-align: -1px; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--line); gap: 1px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.month .dow { background: #fafbfc; padding: 6px; text-align: center; font-size: 12px; color: var(--muted); }
.month .cell { background: #fff; min-height: 108px; padding: 4px; display: flex; flex-direction: column; gap: 2px; cursor: default; }
.month .cell.other { background: #fafbfc; color: #b0b6bf; }
.month .cell .num { font-size: 12px; padding: 2px 4px; align-self: flex-start; border-radius: 99px; }
.month .cell.today .num { background: var(--accent); color: #fff; }
.ev { display: block; border-radius: 5px; padding: 2px 6px; font-size: 12px; color: #fff; background: var(--c); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; text-decoration: none; }
.ev.s-cancelled { text-decoration: line-through; }
.ev.s-completed, .ev.s-cancelled { opacity: .55; } /* past / cancelled broadcasts fade, 쇼룸 color stays */
.ev-line { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-sub { font-size: 11px; opacity: .85; }
.ev.local { box-shadow: inset 3px 0 0 #fff; } /* registered in this app, not in 스케쥴표 */
.timegrid { display: grid; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 190px); }
.timegrid .hdr { position: sticky; top: 0; background: #fafbfc; z-index: 2; padding: 6px; text-align: center; font-size: 12px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); }
.timegrid .hdr.today { color: var(--accent); font-weight: 700; }
.timegrid .hours { font-size: 11px; color: var(--muted); }
.timegrid .hours div, .timegrid .col .slot { height: 44px; border-bottom: 1px solid #f1f3f5; }
.timegrid .hours div { text-align: right; padding-right: 6px; transform: translateY(-7px); border: 0; }
.timegrid .col { position: relative; border-left: 1px solid var(--line); }
.timegrid .col .ev { position: absolute; left: 3px; right: 3px; white-space: normal; padding: 4px 6px; }
.list-day { margin-bottom: 14px; }
.list-day h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.list-item { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 8px; margin-bottom: 6px; cursor: pointer; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,18,25,.45); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: min(640px, 100%); max-height: 90vh; overflow: auto; padding: 22px; display: grid; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }

/* dashboard */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat b { display: block; font-size: 28px; margin-top: 4px; }
.dash { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.dash h3 { font-size: 14px; margin-bottom: 8px; }
.line-item { display: flex; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid #f1f3f5; }
.line-item:last-child { border: 0; }

/* tables */
table.tbl { width: 100%; border-collapse: collapse; background: #fff; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; white-space: nowrap; }
.scroll-x { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

/* project */
.p-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; flex-wrap: wrap; }
.p-head h1 { font-size: 22px; }
.p-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--text); border-color: var(--text); font-weight: 600; }
.info { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; }
.presence { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.presence span { background: #fff; border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; }

/* script */
.toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; background: #fafbfc; position: sticky; top: 57px; z-index: 5; }
.toolbar button { border: 1px solid transparent; background: none; padding: 4px 8px; border-radius: 6px; cursor: pointer; min-width: 30px; }
.toolbar button:hover { background: #fff; border-color: var(--line); }
.toolbar input[type=color] { width: 30px; height: 28px; border: 0; padding: 0; background: none; }
.doc { background: #fff; border: 1px solid var(--line); padding: 24px 28px; min-height: 420px; line-height: 1.7; font-size: 16px; outline: none; }
.editor { border-radius: 0 0 var(--radius) var(--radius); }
.doc h1 { font-size: 22px; margin: 18px 0 6px; } .doc h2 { font-size: 18px; margin: 14px 0 4px; }
.doc table { border-collapse: collapse; } .doc td, .doc th { border: 1px solid #ced4da; padding: 4px 8px; min-width: 60px; }
.doc mark { background: #fff59d; }
.doc ul, .doc ol { padding-left: 24px; }
.flash { animation: flash 5s ease-out; border-radius: 4px; }
@keyframes flash { 0%, 50% { background: var(--flash); box-shadow: 0 0 0 4px var(--flash); } 100% { background: transparent; box-shadow: 0 0 0 4px transparent; } }
.savebar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.banner { background: #fff3bf; border: 1px solid #ffe066; border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }

/* cue */
.cue td { padding: 4px; }
.cue textarea, .cue input { border: 1px solid transparent; border-radius: 4px; padding: 4px 6px; min-width: 70px; background: transparent; }
.cue textarea:focus, .cue input:focus { border-color: var(--accent); background: #fff; outline: none; }
.cue tr.flash td { animation: flash 5s ease-out; }

/* chat */
.chat { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); height: calc(100vh - 150px); position: sticky; top: 72px; min-height: 360px; }
.chat .ch-head { padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; gap: 8px; align-items: center; }
.chat .members { padding: 6px 12px; border-bottom: 1px solid var(--line); line-height: 1.6; }
.chat .members .tag { font-size: 10px; margin-left: 3px; padding: 0 5px; border-radius: 99px; background: #f1f3f5; color: var(--muted); }
.chat .pins { border-bottom: 1px solid var(--line); background: #fff9db; font-size: 12px; max-height: 110px; overflow: auto; }
.chat .pins div { padding: 5px 12px; }
.chat .msgs { flex: 1; overflow: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 88%; }
.msg .who { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg .bubble { background: #f1f3f5; padding: 7px 10px; border-radius: 10px; white-space: pre-wrap; word-break: break-word; }
.msg.mine { align-self: flex-end; text-align: right; }
.msg.mine .bubble { background: var(--accent); color: #fff; text-align: left; }
.msg.admin:not(.mine) .bubble { background: #fff0f6; }
.msg.important .bubble { box-shadow: 0 0 0 2px var(--live); }
.msg .meta { font-size: 10px; color: var(--muted); margin-top: 2px; }
.msg .pin { border: 0; background: none; cursor: pointer; font-size: 11px; color: var(--muted); }
.msg.system { align-self: center; max-width: 100%; font-size: 11px; color: var(--muted); background: #f8f9fa; padding: 3px 10px; border-radius: 99px; }
.mention { font-weight: 700; }
.chat form { border-top: 1px solid var(--line); padding: 8px; display: grid; gap: 6px; }
.chat .mentions { display: flex; gap: 4px; flex-wrap: wrap; }
.chat .mentions button { border: 1px solid var(--line); background: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; cursor: pointer; }

/* live mode */
.live { --lbg: #fff; --ltext: #111; --lline: #e9ecef; --lpanel: #f8f9fa; background: var(--lbg); color: var(--ltext); height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }
.live.dark { --lbg: #0d0f14; --ltext: #eef0f3; --lline: #232833; --lpanel: #161a22; --flash: #6b5a00; }
.live .l-top { display: flex; gap: 14px; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--lline); flex-wrap: wrap; }
.live .l-top .title { font-weight: 700; font-size: 18px; }
.live .clock { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 700; }
.live .l-body { display: grid; grid-template-columns: 1fr 360px; min-height: 0; }
.live .l-body.nochat { grid-template-columns: 1fr; }
.live .l-script { overflow: auto; padding: 30px 6vw 40vh; line-height: 1.6; scroll-behavior: smooth; }
.live .l-script .section { padding: 10px 18px; border-left: 6px solid transparent; border-radius: 6px; opacity: .55; transition: opacity .2s; cursor: pointer; }
.live .l-script .section.current { opacity: 1; border-color: var(--live); background: var(--lpanel); }
.live .l-script h1, .live .l-script h2 { font-size: 1.25em; margin: .4em 0; }
.live .l-script mark { background: #fff59d; color: #111; }
.live .l-script td { border: 1px solid var(--lline); padding: 4px 8px; }
.live .l-chat { border-left: 1px solid var(--lline); min-height: 0; display: flex; }
.live .l-chat .chat { height: auto; flex: 1; border: 0; border-radius: 0; position: static; background: var(--lpanel); color: var(--ltext); }
.live.dark .chat .msg .bubble { background: #232833; color: #eef0f3; }
.live.dark .chat .msg.mine .bubble { background: var(--accent); }
.live.dark .chat input, .live.dark .chat textarea { background: #0d0f14; border-color: #232833; color: #eee; }
.live.dark .chat .pins { background: #2b2600; }
.live.dark .btn { background: #161a22; border-color: #232833; color: #eee; }
.live .l-next { border-top: 1px solid var(--lline); padding: 10px 18px; font-size: 15px; display: flex; gap: 10px; align-items: center; background: var(--lpanel); }
.live .l-next b { color: var(--live); }

/* auth screens */
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth { width: min(420px, 100%); display: grid; gap: 14px; text-align: center; }
.auth .logo { font-size: 28px; font-weight: 800; } .auth .logo span { color: #ff6b6b; }
.demo-users { display: grid; gap: 6px; }

#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 6px; z-index: 200; }
.toast { background: #1b1f27; color: #fff; padding: 9px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.err { background: var(--live); }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; overflow-x: auto; padding: 8px; align-items: center; }
  .side .logo { padding: 0 10px; } .side .me { display: none; }
  .p-layout, .live .l-body { grid-template-columns: 1fr; }
  .chat { height: calc(100dvh - 300px); min-height: 320px; position: static; }
  .mobile-only { display: inline-block; }
  .p-layout:not(.chat-mode) #chat { display: none; }
  .p-layout.chat-mode #tab { display: none; }
  .p-head h1 { font-size: 19px; }
  .toolbar { top: 0; }
  .grid2 { grid-template-columns: 1fr; }
  .live .l-body { position: relative; }
  .live .l-chat { position: absolute; inset: 0; z-index: 5; }
  .live .l-top { gap: 8px; padding: 8px 12px; }
  .live .l-top .title { font-size: 15px; }
  .live .clock { font-size: 18px; }
  .live .l-script { padding: 16px 14px 40vh; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .hide-m { display: none; }
  .tabs a { padding: 9px 10px; }
  .list-item { grid-template-columns: 52px 1fr; gap: 10px; padding: 10px 12px; }
  .list-item .badge { grid-column: 2; justify-self: start; }
  .files-tbl td:first-child { min-width: 140px; word-break: keep-all; }
  main { padding: 14px; }
}
