/* =========================================================================
 * style.css — CyberOffice バーチャルオフィス
 * ドット絵/レトロゲーム風の世界観
 * ========================================================================= */

:root {
  --bg: #1a1626;
  --bg-panel: #262033;
  --bg-card: #2e2740;
  --border: #4a4258;
  --text: #f0ecf7;
  --text-dim: #a99fc0;
  --primary: #6c5ce7;
  --primary-hover: #7d6ff0;
  --accent: #ffd166;
  --danger: #e74c3c;
  --green: #2ecc71;
  --font-pixel: 'DotGothic16', monospace;
  --font-body: 'M PLUS 1p', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- screens ---------- */
.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-pixel);
  font-size: 14px;
  padding: 8px 16px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: transform .08s, background .15s;
}
.btn:hover { background: #3a3350; }
.btn:active { transform: translateY(2px); }
.btn.primary {
  background: var(--primary);
  border-color: #574bcc;
  box-shadow: 0 3px 0 #453aa8;
}
.btn.primary:hover { background: var(--primary-hover); }
.btn.primary:active { box-shadow: 0 1px 0 #453aa8; }
.btn.danger { background: var(--danger); border-color: #b03426; box-shadow: 0 3px 0 #8f2a1e; }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .35; cursor: not-allowed; box-shadow: none; }
.btn.wide { width: 100%; padding: 12px; font-size: 16px; }
.btn.small { font-size: 12px; padding: 4px 10px; }

/* =========================================================================
 * ログイン画面
 * ========================================================================= */
#screen-login {
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background:
    repeating-linear-gradient(0deg, transparent 0 30px, rgba(108,92,231,.06) 30px 32px),
    repeating-linear-gradient(90deg, transparent 0 30px, rgba(108,92,231,.06) 30px 32px),
    var(--bg);
}

.login-card {
  width: min(420px, 92vw);
  background: var(--bg-panel);
  border: 3px solid var(--border);
  border-radius: 12px;
  padding: 32px 28px;
  box-shadow: 0 8px 0 rgba(0,0,0,.35), 0 20px 60px rgba(0,0,0,.5);
  position: relative;
  z-index: 1;
}

.logo {
  font-family: var(--font-pixel);
  font-size: 32px;
  text-align: center;
  color: var(--accent);
  text-shadow: 3px 3px 0 rgba(0,0,0,.4);
}
.logo.small { font-size: 20px; text-align: left; }

.tagline {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin: 8px 0 20px;
}

.tab-switch {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  background: var(--bg);
  border-radius: 8px;
  padding: 4px;
}
.tab {
  flex: 1;
  font-family: var(--font-pixel);
  font-size: 14px;
  padding: 8px;
  background: transparent;
  color: var(--text-dim);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.tab.active { background: var(--primary); color: #fff; }

form label, .modal label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
form input, form select, .modal input, .modal select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  outline: none;
}
form input:focus, .modal input:focus, .modal select:focus { border-color: var(--primary); }

.form-error {
  color: #ff8a80;
  font-size: 12px;
  min-height: 18px;
  margin-bottom: 8px;
}

.login-heading {
  font-family: var(--font-pixel);
  font-size: 18px;
  text-align: center;
  margin-bottom: 18px;
  color: var(--text);
}

.login-logo {
  display: block;
  margin: 24px auto 0;
  max-width: 190px;
  height: auto;
}

.version-tag {
  text-align: center;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 10px;
  opacity: .7;
}

/* =========================================================================
 * 共通ヘッダー
 * ========================================================================= */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-panel);
  border-bottom: 2px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.header-left, .header-right { display: flex; align-items: center; gap: 10px; }

.username-chip {
  font-size: 12px;
  padding: 5px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--text-dim);
}

/* =========================================================================
 * ルーム選択画面
 * ========================================================================= */
.rooms-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 20px;
}
.rooms-title {
  font-family: var(--font-pixel);
  font-size: 22px;
  margin-bottom: 32px;
}
.room-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 280px));
  gap: 24px;
  justify-content: center;
  width: 100%;
  max-width: 960px;
}
.room-card {
  background: var(--bg-panel);
  border: 3px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform .12s, border-color .12s;
}
.room-card:hover { transform: translateY(-4px); border-color: var(--primary); }
.room-card-preview {
  position: relative;
  height: 130px;
  background: #0f0c18;
  border-bottom: 2px solid var(--border);
}
.room-card-preview canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}
.room-card-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 11px;
  background: rgba(14,13,24,0.8);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 3px 10px;
}
.room-card-body { padding: 16px; }
.room-card-name {
  font-family: var(--font-pixel);
  font-size: 18px;
  margin-bottom: 12px;
}

/* =========================================================================
 * ルーム画面
 * ========================================================================= */
#screen-room { height: 100vh; }
.room-header { flex-wrap: nowrap; }
.room-title-text { font-family: var(--font-pixel); font-size: 18px; }

.status-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 10px;
}
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}
#status-select {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-body);
  outline: none;
  cursor: pointer;
}
#status-select option { background: var(--bg-card); }

.room-body {
  flex: 1;
  display: flex;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.room-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.room-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #0f0c18;
  border: 3px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#game-canvas {
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---------- チャット吹き出し(Habbo風に上へ流れる) ---------- */
.bubble-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.chat-bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  max-width: 220px;
  background: #fffef5;
  color: #222;
  border: 2px solid #222;
  border-radius: 8px;
  padding: 4px 9px 5px;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 2px 2px 0 rgba(0,0,0,.35);
  /* 上昇・フェードはgame.jsのループで駆動(margin-top / opacity) */
  word-break: break-word;
}
.chat-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -7px;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #222;
  border-bottom: none;
}
.chat-bubble.npc { background: #eef4ff; }
.bubble-name {
  display: block;
  font-weight: 700;
  font-size: 10px;
  margin-bottom: 1px;
}

/* ---------- ビデオパネル ---------- */
.video-panel {
  position: absolute;
  right: 18px;
  top: 18px;
  width: 190px;
  border: 3px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  z-index: 5;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
.video-panel { cursor: grab; touch-action: none; }
.video-panel.fw-active { cursor: grabbing; border-color: var(--primary); }
.video-panel video { width: 100%; display: block; transform: scaleX(-1); }
.video-label {
  position: absolute;
  left: 6px; bottom: 6px;
  font-size: 10px;
  background: rgba(0,0,0,.6);
  padding: 2px 8px;
  border-radius: 99px;
}

/* ---------- 他ユーザーの映像(WebRTC・移動/リサイズ可能ウィンドウ) ---------- */
.remote-videos {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.rv-tile {
  position: absolute;
  width: 190px;
  pointer-events: auto;
  border: 3px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 6px 20px rgba(0,0,0,.5);
  cursor: grab;
  touch-action: none;
}
.rv-tile.fw-active { cursor: grabbing; border-color: var(--primary); }
.fw-resize {
  position: absolute;
  right: 0; bottom: 0;
  width: 16px; height: 16px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,.55) 50%);
  border-radius: 0 0 6px 0;
  z-index: 2;
}
.rv-mode {
  position: absolute;
  top: 4px; left: 6px;
  font-size: 9px;
  color: #fff;
  background: rgba(224,75,75,.85);
  padding: 1px 7px;
  border-radius: 99px;
}
.rv-mode:empty { display: none; }
.rv-tile video { width: 100%; display: block; min-height: 40px; }
.rv-tile.audio-only { background: var(--bg-panel); }
.rv-tile.audio-only video { height: 0; min-height: 0; }
.rv-tile .rv-placeholder {
  display: none;
  text-align: center;
  font-size: 20px;
  padding: 10px 0 22px;
}
.rv-tile.audio-only .rv-placeholder { display: block; }
.rv-name {
  position: absolute;
  left: 6px; bottom: 6px;
  font-size: 10px;
  background: rgba(0,0,0,.6);
  padding: 2px 8px;
  border-radius: 99px;
  color: #fff;
}
.rv-mic {
  position: absolute;
  right: 6px; bottom: 6px;
  font-size: 11px;
}
/* ---------- モード選択ポップオーバー(🎤/📷) ---------- */
.mode-popover {
  position: absolute;
  bottom: 56px;
  right: 0;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 20;
  min-width: 210px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.mode-popover button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  font-family: var(--font-body);
  font-size: 13px;
  text-align: left;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
}
.mode-popover button:hover { background: var(--bg-card); }
.mode-popover button.sel { background: rgba(108,92,231,.25); outline: 1px solid var(--primary); }
.mp-sub { font-size: 10px; color: var(--text-dim); }
.tool-btn.loud::after, .tool-btn.present::after {
  content: '📢';
  position: absolute;
  top: -6px; right: -6px;
  font-size: 12px;
}
.tool-btn.present::after { content: '📽'; }

/* ---------- 大声チャット ---------- */
.chat-bubble.loud { font-weight: 700; border-width: 3px; }
.chat-log-item.loud { font-weight: 700; }
.chat-log-item.loud::before { content: '📢 '; }

/* ---------- 範囲設定(管理画面) ---------- */
.range-form {
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.range-form label { margin: 0; }
.range-form input { max-width: 120px; }
.range-desc { display: block; font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.range-form .btn { align-self: flex-start; }

/* ---------- ツールバー ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  align-items: center;
  position: relative;
  flex-wrap: wrap;
}
.chat-input-wrap {
  flex: 1;
  display: flex;
  gap: 8px;
  min-width: 220px;
}
#chat-input {
  flex: 1;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  outline: none;
}
#chat-input:focus { border-color: var(--primary); }

.toolbar-buttons { display: flex; gap: 8px; }
.tool-btn {
  width: 44px; height: 44px;
  font-size: 20px;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  position: relative;
}
.tool-btn:hover { background: #3a3350; }
.tool-btn.on { border-color: var(--green); background: rgba(46,204,113,.15); }
.tool-btn.off::after {
  content: '';
  position: absolute;
  left: 8px; top: 50%;
  width: 28px; height: 2.5px;
  background: var(--danger);
  transform: rotate(-45deg);
  border-radius: 2px;
}
.tool-btn.muted { border-color: var(--danger); background: rgba(231,76,60,.15); }

.controls-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

/* ---------- 絵文字ピッカー ---------- */
.emoji-picker {
  position: absolute;
  bottom: 56px;
  right: 0;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(5, 40px);
  gap: 4px;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.emoji-picker button {
  width: 40px; height: 40px;
  font-size: 21px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.emoji-picker button:hover { background: var(--bg-card); }

/* ---------- サイドバー ---------- */
.room-sidebar {
  width: 250px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}
.sidebar-section {
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-section h3 {
  font-family: var(--font-pixel);
  font-size: 14px;
  margin-bottom: 10px;
}
.chat-log-section { flex: 1; }

.participant-list { list-style: none; }
.participant-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  padding: 5px 4px;
}
.p-avatar {
  width: 18px; height: 18px;
  border-radius: 4px;
  flex-shrink: 0;
  image-rendering: pixelated;
}
.p-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.p-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-hear { font-size: 11px; }
.p-npc-tag {
  font-size: 9px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text-dim);
}
.hear-note { font-size: 10px; color: var(--text-dim); margin-top: 6px; }
.p-npc-tag.member { color: #7bed9f; border-color: #2ecc71; }

.mode-chip {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}
.mode-chip.online { color: #7bed9f; border-color: #2ecc71; background: rgba(46,204,113,.1); }

.chat-log {
  flex: 1;
  overflow-y: auto;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 120px;
}
.chat-log-item { line-height: 1.5; }
.chat-log-name { font-weight: 700; margin-right: 4px; }
.chat-log-time { color: var(--text-dim); font-size: 10px; margin-left: 4px; }

/* =========================================================================
 * 管理画面
 * ========================================================================= */
.admin-main {
  flex: 1;
  padding: 24px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.admin-tab {
  font-family: var(--font-pixel);
  font-size: 14px;
  padding: 10px 18px;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 8px 8px 0 0;
  color: var(--text-dim);
  cursor: pointer;
}
.admin-tab.active { background: var(--primary); color: #fff; border-color: #574bcc; }

.admin-panel { display: none; }
.admin-panel.active { display: block; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}
.panel-head h3 { font-family: var(--font-pixel); font-size: 17px; }
.panel-head select {
  padding: 8px 10px;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-body);
  margin-right: 8px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 13px;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.admin-table th {
  background: var(--bg-card);
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: 12px;
  color: var(--text-dim);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table td .btn { margin-right: 6px; }

.role-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid;
}
.role-badge.admin { color: var(--accent); border-color: var(--accent); }
.role-badge.member { color: var(--text-dim); border-color: var(--border); }

.npc-chat-badge {
  font-size: 9px;
  background: rgba(108,92,231,.2);
  border: 1px solid var(--primary);
  color: #b3a8ff;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

.panel-note { margin-top: 12px; font-size: 11.5px; color: var(--text-dim); }

.empty-row { text-align: center; color: var(--text-dim); padding: 24px !important; }

/* ---------- モーダル ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10,8,18,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  width: min(560px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 3px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal h3 { font-family: var(--font-pixel); margin-bottom: 16px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ---------- 着せ替えエディタ ---------- */
#my-avatar-mini {
  image-rendering: pixelated;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.avatar-editor {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.ae-preview {
  flex-shrink: 0;
  background:
    repeating-linear-gradient(0deg, transparent 0 14px, rgba(108,92,231,.07) 14px 15px),
    repeating-linear-gradient(90deg, transparent 0 14px, rgba(108,92,231,.07) 14px 15px),
    var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 4px;
}
.ae-preview canvas { display: block; image-rendering: pixelated; }
.ae-controls { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ae-group { display: flex; flex-direction: column; gap: 4px; }
.ae-label { font-size: 11px; color: var(--text-dim); }
.ae-opts { display: flex; flex-wrap: wrap; gap: 5px; }
.ae-swatch {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 2px solid var(--border);
  cursor: pointer;
}
.ae-swatch.sel { border-color: #fff; box-shadow: 0 0 0 2px var(--primary); }
.ae-style {
  font-family: var(--font-body);
  font-size: 11px;
  padding: 5px 9px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}
.ae-style.sel { border-color: var(--primary); background: rgba(108,92,231,.2); }

/* ---------- 着せ替えエディタ(アロー・カルーセル) ---------- */
.ae2 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.ae2-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.ae2-mid {
  flex-shrink: 0;
  background:
    repeating-linear-gradient(0deg, transparent 0 14px, rgba(108,92,231,.07) 14px 15px),
    repeating-linear-gradient(90deg, transparent 0 14px, rgba(108,92,231,.07) 14px 15px),
    var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 4px;
}
.ae2-mid canvas { display: block; image-rendering: pixelated; }
.ae2-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 5px 6px;
}
.ae2-arrow {
  width: 26px; height: 26px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.ae2-arrow:hover { background: var(--primary); border-color: var(--primary); }
.ae2-face {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}
.ae2-lbl { font-size: 9px; color: var(--text-dim); }
.ae2-val { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ae2-swatch {
  flex: 1;
  height: 24px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,.15);
}

/* ---------- NPC管理 ---------- */
.npc-mini {
  image-rendering: pixelated;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.cell-sub { font-size: 10.5px; color: var(--text-dim); }
.ai-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.ai-badge.on { color: #7bed9f; border-color: #2ecc71; background: rgba(46,204,113,.12); }
.npc-form textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font-body);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  outline: none;
  resize: vertical;
}
.npc-form textarea:focus { border-color: var(--primary); }
.ai-fieldset {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
}
.ai-fieldset legend { font-size: 12px; color: var(--text-dim); padding: 0 6px; }
.check-label { display: flex !important; align-items: center; gap: 8px; font-size: 12.5px !important; color: var(--text) !important; }
.check-label input { width: auto !important; margin: 0 !important; display: inline-block !important; }

/* =========================================================================
 * コンソール(Habbo Console風)
 * ========================================================================= */
/* ツールバーのコンソールアイコン(筐体のミニチュア) */
.console-icon {
  display: block;
  width: 26px; height: 26px;
  margin: 0 auto;
  background: linear-gradient(180deg, #f6cc4a, #e3ab2a);
  border: 2px solid #7a5c16;
  border-radius: 5px;
  position: relative;
}
.ci-title {
  position: absolute; top: 1px; left: 4px; right: 4px; height: 3px;
  background: #fbe08a; border-radius: 2px;
}
.ci-screen {
  position: absolute; top: 5px; left: 3px; right: 3px; height: 11px;
  background: #3d3d3d;
  border: 1px solid #26260f;
  border-radius: 2px;
}
.ci-keys { position: absolute; bottom: 1.5px; left: 3px; right: 3px; display: flex; gap: 2px; justify-content: center; }
.ci-keys i { width: 4px; height: 3px; background: #a87f1d; border-radius: 1px; }

/* 本体 */
.console {
  position: absolute;
  left: 18px;
  bottom: 14px;
  width: 300px;
  z-index: 30;
  background: linear-gradient(180deg, #f6cc4a 0%, #efc23b 55%, #e3ab2a 100%);
  border: 3px solid #7a5c16;
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(0,0,0,.55), inset 0 2px 0 rgba(255,255,255,.35);
  padding: 6px 10px 10px;
  font-family: var(--font-pixel);
  user-select: none;
}
.console-titlebar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  background: linear-gradient(180deg, #fbe08a, #f0c445);
  border: 1.5px solid #a87f1d;
  border-radius: 6px;
  margin: 0 14px 6px;
  padding: 2px 8px;
}
.console-title { font-size: 13px; color: #4a3608; letter-spacing: 1px; }
.ct-deco { width: 7px; height: 7px; background: #d9a92c; border: 1px solid #a87f1d; border-radius: 2px; }
.console-x {
  position: absolute;
  right: -22px; top: -2px;
  width: 18px; height: 18px;
  font-size: 10px;
  background: #f0c445;
  color: #4a3608;
  border: 1.5px solid #a87f1d;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
}
.console-x:hover { background: #fbe08a; }

.console-screen-wrap {
  display: flex;
  background: #3d3d3d;
  border: 2px solid #26260f;
  border-radius: 8px;
  box-shadow: inset 0 3px 8px rgba(0,0,0,.6);
  height: 240px;
  overflow: hidden;
}
.console-screen {
  flex: 1;
  padding: 10px 8px 10px 12px;
  color: #e8e8e8;
  font-size: 12px;
  line-height: 1.55;
  overflow-y: auto;
}
.console-screen::-webkit-scrollbar { display: none; }
.console-empty { white-space: pre-line; }

/* 疑似スクロールバー(装飾) */
.console-scrollbar {
  width: 16px;
  background: #b9b9b9;
  border-left: 2px solid #26260f;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.csb-btn {
  height: 16px;
  background: linear-gradient(180deg, #e3e3e3, #a8a8a8);
  border-bottom: 1px solid #6f6f6f;
  font-size: 7px;
  color: #3d3d3d;
  display: flex; align-items: center; justify-content: center;
}
.csb-btn:last-child { border-top: 1px solid #6f6f6f; border-bottom: none; }
.csb-track { flex: 1; position: relative; background: #9a9a9a; }
.csb-thumb {
  position: absolute; top: 2px; left: 1.5px; right: 1.5px; height: 26px;
  background: linear-gradient(90deg, #e3e3e3, #b5b5b5);
  border: 1px solid #6f6f6f;
  border-radius: 2px;
}

/* メモ一覧 */
.memo-item {
  padding: 5px 7px;
  border-radius: 4px;
  margin-bottom: 5px;
  cursor: pointer;
  border: 1px solid transparent;
  word-break: break-word;
}
.memo-item:hover { background: rgba(255,255,255,.07); }
.memo-item.sel { background: rgba(246,204,74,.18); border-color: #f6cc4a; }
.memo-date { display: block; font-size: 9px; color: #9a9a9a; margin-top: 2px; }
.memo-compose textarea {
  width: 100%;
  height: 110px;
  background: #2e2e2e;
  border: 1px solid #6f6f6f;
  border-radius: 4px;
  color: #e8e8e8;
  font-family: var(--font-body);
  font-size: 12px;
  padding: 6px;
  resize: none;
  outline: none;
}
.memo-compose-actions { display: flex; gap: 6px; margin-top: 6px; }
.memo-compose-actions .console-btn { flex: 1; }

/* 中段のボタン列 */
.console-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 2px 8px;
}
.console-help-q {
  width: 18px; height: 18px;
  background: #d9d9d9;
  border: 1.5px solid #6f6f6f;
  border-radius: 3px;
  color: #3d3d3d;
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.console-btn {
  flex: 1;
  font-family: var(--font-pixel);
  font-size: 11px;
  padding: 4px 8px;
  background: linear-gradient(180deg, #e9e9e9, #bdbdbd);
  border: 1.5px solid #6f6f6f;
  border-radius: 4px;
  color: #3d3d3d;
  cursor: pointer;
}
.console-btn:hover:not([disabled]) { background: linear-gradient(180deg, #f6f6f6, #cecece); }
.console-btn[disabled] { opacity: .45; cursor: default; color: #8a8a8a; }

/* 下部タブ(MY INFO / MEMO / FIND / HELP) */
.console-tabs {
  display: flex;
  gap: 5px;
  background: #d9a92c;
  border: 1.5px solid #a87f1d;
  border-radius: 8px;
  padding: 5px;
}
.console-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 2px 4px;
  font-family: var(--font-pixel);
  font-size: 8px;
  color: #4a3608;
  background: linear-gradient(180deg, #f6cc4a, #e8b830);
  border: 1.5px solid #a87f1d;
  border-radius: 5px;
  cursor: pointer;
}
.console-tab .ct-face {
  font-size: 14px;
  width: 22px; height: 22px;
  background: #3d2f10;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.console-tab:hover { background: linear-gradient(180deg, #fbe08a, #f0c445); }
.console-tab.active {
  background: linear-gradient(180deg, #c8952c, #b9861f);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.35);
}

/* =========================================================================
 * ルームレイアウトエディタ(管理画面)
 * ========================================================================= */
.re-wrap { display: flex; flex-direction: column; gap: 12px; }
.re-top { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.re-palette {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  width: 210px;
  flex-shrink: 0;
}
.re-tool {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 11px;
  padding: 5px 7px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.re-tool.sel { border-color: var(--primary); background: rgba(108,92,231,.22); }
.re-grid-wrap { flex: 1; min-width: 0; overflow-x: auto; }
.re-grid {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 2px solid var(--border);
  border-radius: 6px;
  width: max-content;
}
.re-cell {
  width: 24px; height: 24px;
  background: var(--bg-panel);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
}
.re-cell:hover { outline: 2px solid var(--primary); outline-offset: -2px; z-index: 1; }
.re-cell.rug { background: #47609e; }
.re-cell { position: relative; }
.re-cell .dir-arrow {
  position: absolute;
  right: 0; bottom: -2px;
  font-size: 8px;
  font-style: normal;
  color: var(--accent);
  text-shadow: 0 0 2px #000;
}
.re-dir-wrap { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.re-dir {
  width: 26px; height: 26px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}
.re-dir.sel { border-color: var(--primary); background: rgba(108,92,231,.25); }
.re-bedcolor {
  width: 22px; height: 22px;
  border-radius: 5px;
  border: 2px solid var(--border);
  cursor: pointer;
}
.re-bedcolor.sel { border-color: #fff; box-shadow: 0 0 0 2px var(--primary); }
.re-preview-label { font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.re-preview {
  width: 100%;
  background: #12101e;
  border: 2px solid var(--border);
  border-radius: 8px;
  display: block;
}
.re-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.re-bar select {
  padding: 7px 10px;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-body);
}
.modal.wide { width: min(920px, 96vw); }

/* ---------- トースト ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 2px solid var(--primary);
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  animation: toast-in .2s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- レスポンシブ ---------- */
@media (max-width: 860px) {
  .room-body { flex-direction: column; overflow-y: auto; }
  .room-sidebar { width: 100%; flex-direction: row; }
  .sidebar-section { flex: 1; }
  .room-viewport { min-height: 320px; }
  .video-panel { width: 130px; }
}
