/* 우당탕 우사기상사 화면 */
@font-face {
  font-family: "Jua";
  src: url("Jua-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #b3875e;
  --paper: #fff6e0;
  --mast-paper: #fff3d6;
  --mast-ink: #30483c;
  --paper-rule: #cdb78e;
  --print-ink: #30483c;
  --print-ink-muted: #594734;
  --print-accent: #894732;
  --ink: #312c22;
  --mute: var(--print-ink-muted);
  --line: #d9c295;
  --accent: #3d5948;
  --ok: #38614c;
  --bad: #8c392e;
  --wait: #814722;
  --walnut: #694933;
  --brass: #ad884e;
  --shell-font: "Jua", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --shell-selection: #e4ebd0;
  --shell-hover: #f1e7cb;
  --shell-pressed: #e8d9b9;
  --shell-focus: #663b25;
  --soft: #eee1c2;
  --button-radius: 7px;
  --motion: 160ms cubic-bezier(.22, 1, .36, 1);
  --outer: clamp(14px, 2vw, 48px);
  --page-width: 1880px;
  --scene-gutter: max(var(--outer), calc((100vw - var(--page-width)) / 2));
  --drawer-width: clamp(350px, 31.5vw, 472px);
  --floor-light: linear-gradient(117deg, transparent 7%, #ffd98c38 7.6% 16%, transparent 16.6% 26%, #ffe4a422 26.6% 35%, transparent 35.6%);
  --floor-planks: repeating-linear-gradient(151deg, transparent 0 48px, #63380f26 49px, #ffdc992b 50px, transparent 52px 65px);
  --floor-grain: repeating-linear-gradient(151deg, #7c553516 0 1px, transparent 2px 6px);
  --floor-base: linear-gradient(105deg, #db9559, #de924d 54%, #b97a43);
}

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
  min-height: 640px;
  font: 400 15px/1.4 var(--shell-font);
  font-synthesis: none;
  background:
    var(--floor-light), var(--floor-planks), var(--floor-grain), var(--floor-base);
}
button, input, textarea, select { color: inherit; font-family: inherit; }
:focus-visible { outline: 2px solid var(--shell-focus); outline-offset: 3px; }
[hidden] { display: none !important; }

.office-hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  position: relative;
  z-index: 1;
  margin-inline: var(--scene-gutter);
  padding-block: 9px 0;
  color: var(--print-ink);
  pointer-events: none;
}
.hud-context, .hud-controls {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: clamp(5px, .65vw, 11px);
  pointer-events: auto;
}
.hud-context {
  width: fit-content;
  max-width: 100%;
  min-height: 44px;
  padding: 3px 10px;
  border: 1px solid #bc9c68;
  border-radius: 7px;
  background: #fff2d8f2;
  box-shadow: 0 2px 8px #35241545;
}
.hud-context:has(#projectContext[hidden] + .stats:empty) { visibility: hidden; }
.project-index {
  min-width: min(100%, 5ch);
  margin: 0;
  overflow: hidden;
  color: var(--print-ink-muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#nowTitle { color: var(--print-ink); font-weight: 700; }
.hud-controls {
  --hud-control-height: 44px;
  --hud-control-gap: 8px;
  justify-content: flex-end;
  align-items: flex-start;
  gap: var(--hud-control-gap);
}
.runtime-status {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 44px;
  padding-inline: 10px;
  border: 1px solid #bc9c68;
  border-radius: 7px;
  background: #fff2d8f2;
  box-shadow: 0 2px 8px #35241545;
  font-size: 13px;
  font-weight: 700;
}
#runTxt { min-width: 0; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runtime-status .dot { width: 8px; height: 8px; flex: none; border: 1px solid #755b37; border-radius: 50%; background: #a98047; box-shadow: 0 0 0 2px #fff0cb; }
.runtime-status[data-tone="active"] .dot { border-color: #34503e; background: #5d7956; }
.runtime-status[data-tone="issue"] { color: var(--bad); }
.runtime-status[data-tone="issue"] .dot { border-color: currentColor; background: currentColor; }
.mast-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.usage-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  color: var(--print-ink);
  background: var(--paper);
  border: 1px solid var(--brass);
  border-radius: 5px;
  box-shadow: 0 2px 7px #35241536;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
#usageToggle { anchor-name: --usage-toggle; }
#settingsToggle { anchor-name: --settings-toggle; }
.usage-toggle::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.usage-toggle:hover, .usage-toggle[aria-expanded="true"],
body:has(#usagePanel:popover-open) #usageToggle,
body:has(#settingsPanel:popover-open) #settingsToggle { background: var(--shell-hover); }
#usePill.warn .usage-toggle { color: var(--bad); }
#usagePanel, #settingsPanel {
  position: fixed;
  inset: 61px var(--scene-gutter) auto auto;
  width: min(19rem, calc(100vw - 24px));
  margin: 0;
  padding: 16px;
  color: var(--print-ink);
  background: var(--mast-paper);
  border: 1px solid var(--brass);
  border-radius: 7px;
  box-shadow: 0 12px 28px #69493326, 0 3px #ac884a61;
}
#usagePanel { font-variant-numeric: tabular-nums; }
@supports (top: anchor(bottom)) {
  #usagePanel, #settingsPanel { inset: calc(anchor(bottom) + 8px) anchor(right) auto auto; }
  #usagePanel { position-anchor: --usage-toggle; }
  #settingsPanel { position-anchor: --settings-toggle; }
}
.usage-heading, .usage-period > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.usage-heading { border-bottom: 1px solid var(--paper-rule); padding-bottom: 8px; }
.usage-heading h2 { margin: 0; font-size: 15px; font-weight: 600; }
#usageWarning { color: var(--print-accent); font-size: 12px; font-weight: 600; }
.usage-period { margin-top: 12px; }
.usage-period > div { margin-bottom: 4px; }
.usage-period b { font-weight: 600; }
.usage-period progress { display: block; width: 100%; height: 6px; border: 0; border-radius: 4px; overflow: hidden; appearance: none; background: var(--shell-hover); color: var(--accent); }
.usage-period progress::-webkit-progress-bar { background: var(--shell-hover); }
.usage-period progress::-webkit-progress-value { background: var(--accent); }
.usage-period progress::-moz-progress-bar { background: var(--accent); }
#usePill.warn #usageWeekBar::-webkit-progress-value { background: var(--print-accent); }
#usePill.warn #usageWeekBar::-moz-progress-bar { background: var(--print-accent); }

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  width: min(calc(100% - 2 * var(--outer)), var(--page-width));
  margin-inline: auto;
  padding-block: 4px 8px;
  min-height: 0;
}
body:not(.reel) main {
  width: 100%;
  padding-inline: var(--scene-gutter);
  overflow-x: clip;
}
body:not(.reel) :is(.stage, .workspace) { grid-area: 1 / 1; }
.stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}
.stats { display: flex; min-width: 0; align-items: center; gap: 3px 9px; flex-wrap: wrap; }
.stats:not(:empty) { padding-inline-start: 8px; border-inline-start: 1px solid var(--paper-rule); }
#projectContext[hidden] + .stats { padding-inline-start: 0; border: 0; }
.stat { display: inline-flex; align-items: baseline; gap: 4px; color: var(--print-ink-muted); font-size: 13px; white-space: nowrap; }
.stat b { color: var(--print-ink); font-size: 14px; line-height: 1; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat b em { font-size: 12px; font-style: normal; margin-left: 1px; font-weight: 500; }
.stat.warning, .stat.warning b { color: var(--bad); }
#sceneSpotlight {
  position: relative;
  z-index: 1;
  margin: 3px 0 0;
  width: fit-content;
  max-width: calc(100% - 6px);
  padding: 4px 9px;
  border-inline-start: 2px solid var(--brass);
  background: var(--paper);
  color: var(--print-ink);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.scene-area {
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
#sceneConnection { position: absolute; z-index: 1; inset: 20px 0 auto; width: fit-content; margin: 0 auto; padding: 6px 12px; border-radius: 5px; background: var(--paper); color: var(--mute); }
svg#scene { width: 100%; height: 100%; display: block; }
svg#scene[data-photo] { position: fixed; inset: 0; width: 100%; height: 100dvh; }
#scene[data-fit-photo] #sceneRoomArt image { mask: url(#studioForeground); }
svg#scene:focus-visible { outline-offset: -3px; }
#scene .person-tag { pointer-events: none; }
#scene [data-sid] { cursor: pointer; }
#scene :is([data-sid], .automation) > .person-tag { visibility: hidden; }
#scene [data-sid][data-selected] > .person-tag { visibility: visible; }
#scene :is(.tag, .zlabel, .lane) {
  fill: var(--print-ink);
  stroke: #fff7e8;
  stroke-width: 6;
  stroke-linejoin: round;
  paint-order: stroke;
  font-family: var(--shell-font);
  font-weight: 700;
}
#scene .tag { font-size: 9px; stroke-width: 3; }
#scene .zlabel { font-size: 20px; }
#scene .lane { font-size: 13px; stroke-width: 4; }
#scene .lane.busy { fill: #884934; }
#sceneActions .hs { cursor: pointer; outline: none; fill: var(--print-ink); }
#sceneActions .hs rect { fill: #fff0c9; stroke: #987747; stroke-width: 1.5; filter: drop-shadow(0 2px 0 #6e4e322f); }
#sceneActions .hs circle { fill: #9a5b43; pointer-events: none; }
#sceneActions .hs-label { font-size: 15px; font-weight: 700; pointer-events: none; }
#sceneActions .hs:is(:hover, :focus-visible, [aria-expanded="true"], .near) rect { fill: #dfeadf; stroke: #496957; }
#sceneActions .hs:focus-visible rect { stroke-width: 3; }
@media (hover: hover) {
  #scene :is([data-sid], .automation):hover > .person-tag { visibility: visible; }
}
.spotbtn { flex: none; display: inline-flex; align-items: center; gap: 8px; }
.spotbtn::before { content: ""; width: 9px; height: 10px; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.spotbtn[aria-pressed="true"]::before { clip-path: none; height: 9px; }

.workspace {
  z-index: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
body:not(.reel) .workspace {
  justify-self: end;
  inline-size: min(100%, var(--drawer-width));
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}
body:not(.reel) .workspace[inert] {
  opacity: 0;
  transform: translateX(32px);
  visibility: hidden;
  pointer-events: none;
  transition: opacity 170ms ease-out, transform 170ms ease-out, visibility 0s 170ms;
}
@media (prefers-reduced-motion: reduce) {
  body:not(.reel) .workspace,
  body:not(.reel) .workspace[inert] { transition: none; }
}
.pane {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overflow-wrap: anywhere;
  padding: 12px 16px 16px;
  scrollbar-color: #a9936c transparent;
}
.pane :is(.tk, .runbox, .ev, .sec, details) { max-width: 100%; }
.pane .sec { margin: 20px 0 8px; color: var(--accent); font-size: 13px; }
.pane .ev { border-bottom: 1px solid var(--line); }
.pane .row { flex-wrap: wrap; }
.pane .row input { min-width: 8ch; }
.runbox { padding: 8px 12px; border-radius: var(--button-radius); background: var(--soft); color: var(--accent); font-size: 13px; margin: 0 0 12px; }
.tk { border-radius: 4px; padding: 12px; background: var(--paper); }
.tk.cur { box-shadow: none; }
.empty { color: var(--mute); padding: 16px 8px; text-align: left; }
.pane > .empty { margin: 4px 0 8px; line-height: 1.6; }

.b, .sugg button, .chiprow button {
  min-height: 40px;
  border-radius: var(--button-radius);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  transition: background-color var(--motion), border-color var(--motion);
}
.b, .b.acc { background: var(--accent); border-color: var(--accent); color: #fff; }
.b.ghost, .sugg button, .chiprow button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--accent);
}
.b.ghost:hover, .sugg button:hover:hover, .chiprow button:not(.on):hover { background: var(--soft); border-color: var(--paper-rule); }
.b:not(.ghost, :disabled):hover { background: var(--mast-ink); }

textarea, input[type=text] { border-radius: var(--button-radius); background: #fdfdf9; color: var(--ink); }
textarea::placeholder, input::placeholder { color: var(--mute); opacity: 1; }
.sugg { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 12px; }
.sugg button { padding-inline: 8px; min-height: 36px; font-size: 12px; text-align: left; }

.roster-summary { display: flex; gap: 8px 14px; flex-wrap: wrap; }
.roster-group { margin-bottom: 16px; }
.staff {
  color: var(--ink);
  min-height: 48px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 6px 4px;
  text-align: left;
  font: inherit;
  font-size: 13px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.staff .av { width: 34px; height: 34px; border-radius: 8px; border: 1px solid #0001; color: #22271f; font-size: 12px; font-weight: 600; }
.staff b, .staff .st { white-space: normal; }
.staff .st { color: var(--mute); font-size: 11px; font-weight: 500; text-align: right; max-width: 14ch; }
.staff .st.work { color: var(--ok); }
.staff .st.error { color: var(--bad); }
.staff[data-act="staff"]:hover { background: var(--shell-hover); }
.staff .usagi-portrait { background-color: #faf2dc; }
.staff .more { padding: 0; }
.roster-summary .warning { color: var(--bad); }

#settingsPanel .usage-heading { align-items: center; }
#settingsPanel button, .hud-controls .b.ghost {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--brass);
  border-radius: 5px;
  color: var(--print-ink);
  background: var(--paper);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.hud-controls .b.ghost { box-shadow: inset 0 0 0 2px #fff9e9a3, 0 2px #9d7b4538; }
#settingsPanel button:hover:not(:disabled), .hud-controls .b.ghost:hover { background: var(--shell-hover); }
#settingsPanel button[aria-pressed="true"], .hud-controls .spotbtn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--shell-selection);
}
#settingsPanel button:is(:disabled, [aria-disabled="true"]) { opacity: .55; cursor: default; }
#settingsPanel .settings-close { border-color: transparent; background: transparent; }
#modeLabel { margin: 14px 0 6px; font-weight: 700; }
#modeHelp { margin: 8px 0 16px; color: var(--mute); font-size: 13px; }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
#stopAfter { width: 100%; }
#settingsStatus { margin: 10px 0 0; color: var(--bad); }
#settingsStatus:empty { margin: 0; }

body.reel { display: block; min-height: 0; }
body.reel .office-hud { display: flex; min-height: 53px; justify-content: flex-end; }
body.reel main {
  width: 100%;
  height: calc(100dvh - 53px);
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 0;
  gap: 0;
}
body.reel .stage { width: 100%; padding: 0; grid-template-rows: minmax(0, 1fr); }
body.reel .scene-area { grid-row: 1; border: 0; border-radius: 0; }
body.reel :is(.hud-context, .attendance-controls, #spotBtn, #officeIndex, #sceneSpotlight, #usePill, #settingsToggle) { display: none; }
body.reel .workspace { max-height: 30vh; border-left: 0; border-top: 1px solid var(--line); }
body.reel .pane { min-height: 0; padding-top: 12px; }
body.reel svg#scene { position: absolute; inset: clamp(164px, 24vw, 230px) 0 0; height: calc(100% - clamp(164px, 24vw, 230px)); width: 100%; padding: 0; }
body.reel #hero { display: block; position: absolute; inset: clamp(20px, 3vw, 24px) clamp(16px, 3vw, 28px) auto; z-index: 1; pointer-events: none; }
body.reel #hero :is(.k, .v, .d) { color: var(--ink); }
body.reel #hero .k, body.reel #hero .d { font-size: clamp(18px, 3vw, 26px); }
body.reel #hero .v { font-size: clamp(42px, 7vw, 62px); }
.plain, .plain.see, .mcheck, .layer, .layer.lock, .kcol, .kcard, .kcard.star, .tk.soft {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.plain.see, .layer.lock, .kcol { background: var(--soft); }
.plain small, .plain.see small { color: var(--accent); }
.chip, .kind0, .tidy .kind { border-radius: 4px; }
.chip.h, .kind0.mine { background: #f1e3da; color: var(--wait); }
.kcard .w { background: #5a636a; }
.kcard .w.claude, .kcard .w.office { background: var(--accent); }
.kcard.star { border-left-color: var(--wait); }
.kcard.dec { border-left-color: var(--bad); }
.bar span { border-radius: 2px; }

.hud-controls :is(#attendance-toggle, #spotBtn, #usageToggle, #settingsToggle) {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  inline-size: 112px;
  min-block-size: var(--hud-control-height);
}
@media (max-width: 1150px) {
  #runTxt { max-width: 15ch; }
  .stat { font-size: 12px; }
  .hud-context { gap: 4px; padding-inline: 8px; }
  .stats { gap: 2px 7px; }
}
@media (max-width: 900px) {
  .office-hud {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    max-inline-size: calc(100vw - 2 * var(--scene-gutter));
  }
  .hud-controls { max-width: 100%; flex-wrap: wrap; }
}

.attendance-controls { display: flex; align-items: flex-start; gap: var(--hud-control-gap); min-width: 0; max-width: 100%; }
#attendance-status {
  display: grid;
  place-items: center;
  min-block-size: var(--hud-control-height);
  max-inline-size: 20ch;
  margin: 0;
  padding: 3px 6px;
  border-radius: 3px;
  color: var(--print-ink-muted);
  background: var(--paper);
  font-size: 13px;
  overflow-wrap: anywhere;
  text-align: center;
}
#attendance-status.is-error { color: var(--print-accent); }
.hud-controls #attendance-toggle {
  color: var(--paper);
  background: var(--print-ink);
  border: 1px solid var(--print-ink);
  box-shadow: inset 0 0 0 2px #fff8dc26, 0 2px #9d7b4538;
  font-weight: 700;
  white-space: nowrap;
}
.hud-controls #attendance-toggle::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-inline-end: 7px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: #dcac61;
}
.hud-controls #attendance-toggle:hover:not([aria-disabled="true"]) { background: var(--accent); }
.hud-controls #attendance-toggle[aria-disabled="true"] {
  color: var(--print-ink-muted);
  background: transparent;
  border-color: var(--paper-rule);
  box-shadow: none;
  cursor: default;
}

@media (forced-colors: active) {
  body { background: Canvas; }
  #scene[data-fit-photo] #sceneRoomArt image { mask: none; }
  .hud-context, .runtime-status, #usagePanel, #settingsPanel { border: 1px solid CanvasText; }
  .usage-toggle, #settingsPanel button, .hud-controls .b.ghost { border: 1px solid ButtonText; }
  #settingsPanel button[aria-pressed="true"], .hud-controls .spotbtn[aria-pressed="true"] {
    forced-color-adjust: none;
    background: Highlight;
    border-color: Highlight;
    color: HighlightText;
  }
  .office-hud :focus-visible, .stage :focus-visible, .office-hud [popover] :focus-visible { outline-color: Highlight; }
  .spotbtn::before { forced-color-adjust: none; }
  #sceneActions .hs rect { fill: Canvas; stroke: ButtonText; filter: none; }
  #sceneActions .hs:is(:focus-visible, [aria-current="true"], [aria-expanded="true"]) rect { fill: Canvas; stroke: Highlight; }
  #sceneActions .hs-label { fill: ButtonText; }
}
