* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: system-ui, sans-serif; font-size: 14px; background: #f3f2ee; color: #222; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; padding: 4px 10px; border: 1px solid #aaa; border-radius: 4px; background: #fff; }
button:hover { background: #eee; }
button.active { background: #2f6fdf; color: #fff; border-color: #2f6fdf; }
.tab-strip button.active { background: #fafaf7; }
button.primary { background: #2a9d5c; color: #fff; border-color: #2a9d5c; }
button.primary:disabled { background: #bbb; border-color: #bbb; cursor: default; }
button.small, label.small.button { padding: 1px 6px; font-size: 12px; }
label.button { border: 1px solid #aaa; border-radius: 4px; background: #fff; cursor: pointer; }
input, select, textarea { padding: 3px 6px; border: 1px solid #bbb; border-radius: 4px; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.error { color: #c22; }
.old { color: #888; margin-right: 6px; }
.changed { border-color: #2f6fdf; }
.hint { color: #777; }
h3, h4 { margin: 8px 0 4px; }

/* lobby */
.lobby { max-width: 480px; margin: 40px auto; padding: 24px; background: #fff; border-radius: 8px; box-shadow: 0 2px 8px #0002; }
.login label { display: block; margin: 8px 0; }
.login input { width: 100%; }
.campaigns li { margin: 4px 0; }

/* game shell */
.game { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.game > .split { flex: 1; min-height: 0; }
.split { display: flex; min-width: 0; min-height: 0; width: 100%; height: 100%; }
.split.vertical { flex-direction: column; }
.split.horizontal { flex-direction: row; }
.split-child { min-width: 0; min-height: 0; display: flex; overflow: hidden; }
.split-child > .panel { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.split-child > .split { flex: 1; }
.panel { background: #fafaf7; border: 1px solid #ddd; }

.topbar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: #2b2b33; color: #eee; }
.topbar a.brand { color: #fff; font-weight: bold; text-decoration: none; }
.topbar .spacer { flex: 1; }
.topbar .conn { font-size: 12px; color: #f88; }
.topbar .conn.online { color: #8f8; }
.topbar select { padding: 1px 4px; }

.toolbar { display: flex; gap: 6px; padding: 6px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid #ddd; }
.toolbar input.narrow { width: 60px; }
.toolbar input[type=color] { width: 36px; height: 28px; padding: 0 2px; }
.toolbar .sep { width: 1px; height: 20px; background: #ccc; margin: 0 4px; }

.paper-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.paper-header { display: flex; gap: 6px; padding: 4px 6px; align-items: center; border-bottom: 1px solid #ddd; }
.paper-area { flex: 1; min-height: 0; display: flex; background: #d9d7cf; }
.paper-area .empty { margin: auto; color: #666; }
svg.paper { flex: 1; width: 100%; height: 100%; touch-action: none; user-select: none; }
svg.paper .item { cursor: grab; }
svg.paper.drawing { cursor: crosshair; }
svg.paper.drawing .item { cursor: crosshair; }
svg.paper .selected rect.outline, svg.paper .selected polyline, svg.paper .selected line, svg.paper .selected ellipse, svg.paper .selected > g > rect { filter: drop-shadow(0 0 3px #ff9800); }
svg.paper .selected text { filter: drop-shadow(0 0 2px #ff9800); }
svg.paper .ghost.mine { cursor: grab; }
svg.paper .display-value { cursor: pointer; }
.token-label { pointer-events: none; }

/* tabs */
.tabs-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.tab-strip { display: flex; border-bottom: 1px solid #ccc; background: #eceae4; }
.tab-strip .tab { border: none; border-radius: 0; background: transparent; padding: 6px 10px; }
.tab-strip .tab.active { background: #fafaf7; border-bottom: 2px solid #2f6fdf; color: #222; font-weight: 600; }
.tab-body { flex: 1; overflow: auto; padding: 8px; min-height: 0; }
.tab-body > div { display: block; }

/* pending */
.pending textarea { width: 100%; }
.pending ul.changes { list-style: none; padding: 0; margin: 6px 0; }
.pending ul.changes li { display: flex; justify-content: space-between; gap: 6px; padding: 2px 0; border-bottom: 1px dotted #ddd; }
.notes { background: #f0efe8; padding: 4px 6px; border-radius: 4px; white-space: pre-wrap; margin: 4px 0; font-size: 12px; }
.other-pending { border-left: 4px solid #888; padding: 4px 8px; margin: 6px 0; background: #fff; }
.other-pending ul { margin: 2px 0; padding-left: 16px; }
.command.failed { border-left: 3px solid #c22; padding-left: 6px; }

/* log */
.log { display: flex; flex-direction: column; height: 100%; }
.log-entries { overflow: auto; flex: 1; }
.log-entry { padding: 4px 0; border-bottom: 1px solid #e5e5e5; }
.log-entry .num { color: #888; font-size: 12px; }
.log-entry ul.changes { margin: 2px 0; padding-left: 16px; font-size: 12px; color: #555; }
pre.output { margin: 2px 0; font-size: 12px; white-space: pre-wrap; }

/* inspector */
.field { display: flex; gap: 6px; align-items: center; margin: 3px 0; }
.field label { width: 110px; color: #555; }
.data-node .row { margin: 2px 0; flex-wrap: nowrap; }
.data-node .row .old { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.data-node .label { min-width: 80px; color: #444; }
.data-node input[type=text], .data-node input[type=number] { width: 110px; min-width: 60px; flex: 1; }
.data-node select { max-width: 130px; }
.data-map, .data-list { padding-left: 10px; border-left: 2px solid #e5e5e5; }
.linked-entity { margin: 2px 0 6px 18px; padding: 4px 6px; border-left: 2px solid #2f6fdf55; background: #f4f6fb; }
.data-node .expander { padding: 0 4px; min-width: 20px; }
.add-field input { width: 110px; }
.removed { color: #c22; }
details summary { cursor: pointer; }

/* lists */
.entities ul, .papers ul { list-style: none; padding: 0; margin: 6px 0; }
.entities li, .papers li { padding: 3px 0; border-bottom: 1px dotted #ddd; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.entities li.selected a { font-weight: bold; }
.papers li.active > a { font-weight: bold; }
.papers .row.small { width: 100%; }

/* notices */
.notices { position: fixed; bottom: 12px; left: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 10; max-width: 480px; }
.notice { background: #333; color: #fff; padding: 6px 10px; border-radius: 6px; display: flex; gap: 10px; align-items: center; box-shadow: 0 2px 6px #0004; }
.notice.error { background: #b32; }
.notice button { background: transparent; border: none; color: #fff; padding: 0 4px; }
.invites { list-style: none; padding: 0; }
.invites li { display: flex; gap: 4px; align-items: center; margin: 3px 0; }
.invites input { flex: 1; min-width: 0; font-size: 11px; }
.lobby .invite { background: #eef3ff; padding: 8px; border-radius: 6px; }

/* uncommitted notice */
.uncommitted { display: inline-flex; align-items: center; gap: 8px; background: #ffb300; color: #222; padding: 3px 10px; border-radius: 14px; font-weight: 600; }
.uncommitted .dot { width: 9px; height: 9px; border-radius: 50%; background: #c62828; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.uncommitted button.small { padding: 1px 8px; }
.tab .badge { display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: #ffb300; color: #222; font-size: 11px; font-weight: 700; text-align: center; }
/* layers */
.paper-header .sep { width: 1px; height: 20px; background: #ccc; margin: 0 4px; }
.paper-header .layers button.active { background: #2f6fdf; color: #fff; }
.layer-tools { display: inline-flex; gap: 6px; align-items: center; }
.layer-tools .hint { color: #777; font-size: 12px; }
svg.paper.layer-background [data-kind=background].item { cursor: grab; }
svg.paper.layer-background [data-kind=background].selected image { outline: 2px solid #ff9800; }
svg.paper.layer-background .token, svg.paper.layer-background [data-kind=text], svg.paper.layer-background [data-kind=drawing], svg.paper.layer-background [data-kind=display] { pointer-events: none; opacity: 0.6; }
svg.paper .handle { cursor: nwse-resize; }
