/* ===== 基本設定 ===== */
:root {
  --bg: #0b0d10;
  --panel: rgba(16, 19, 24, 0.92);
  --panel-line: #2c333d;
  --text: #d8dde3;
  --text-dim: #8a93a0;
  --accent: #d4a73a;
  --danger: #c8443c;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.hidden { display: none !important; }

/* ===== 施設Canvas ===== */
#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* ブラウザ既定のスクロール・ズームを無効化 */
  cursor: grab;
}
#world.dragging { cursor: grabbing; }

/* ===== 上部HUD ===== */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(6px + var(--safe-t)) calc(10px + var(--safe-r)) 6px calc(10px + var(--safe-l));
  background: linear-gradient(to bottom, rgba(8,10,13,0.95), rgba(8,10,13,0.75));
  border-bottom: 1px solid var(--panel-line);
  z-index: 10;
  font-size: 13px;
}
.hud-block { display: flex; flex-direction: column; line-height: 1.15; }
.hud-label { font-size: 10px; color: var(--text-dim); letter-spacing: 0.08em; }
.hud-value { font-size: 17px; font-weight: bold; font-variant-numeric: tabular-nums; }
.hud-gauge { min-width: 90px; flex: 0 1 160px; }
.gauge {
  height: 8px;
  margin-top: 4px;
  background: #1c2129;
  border: 1px solid #39414d;
  overflow: hidden;
}
.gauge-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, #b8862b, var(--danger));
  transition: width 0.3s;
}
.hud-spacer { flex: 1; }
.hud-btn {
  background: #1b2028;
  border: 1px solid var(--panel-line);
  padding: 6px 12px;
  min-height: 34px;
}
.hud-btn:hover { border-color: var(--accent); }

/* ===== カメラ操作ボタン ===== */
#cam-controls {
  position: fixed;
  right: calc(10px + var(--safe-r));
  bottom: calc(12px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9;
}
.round-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  font-size: 18px;
}
.round-btn:active { background: #2a313b; }

/* ===== 下部情報パネル ===== */
#info-panel {
  position: fixed;
  left: calc(10px + var(--safe-l));
  bottom: calc(12px + var(--safe-b));
  width: min(420px, calc(100vw - 80px - var(--safe-l) - var(--safe-r)));
  max-height: 45vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-left: 3px solid var(--accent);
  padding: 10px 36px 12px 12px;
  z-index: 9;
}
#info-title { font-weight: bold; font-size: 15px; margin-bottom: 6px; }
#info-body { font-size: 13px; color: var(--text-dim); line-height: 1.5; }
.icon-btn {
  position: absolute;
  top: 4px; right: 4px;
  width: 32px; height: 32px;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-dim);
}

/* ===== モーダル ===== */
#modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: calc(12px + var(--safe-t)) calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l));
}
.modal-box {
  position: relative;
  width: min(640px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: #12161c;
  border: 1px solid var(--panel-line);
  border-top: 3px solid var(--accent);
}
.modal-head {
  position: relative;
  padding: 10px 44px 10px 14px;
  border-bottom: 1px solid var(--panel-line);
}
.modal-head h2 { margin: 0; font-size: 16px; }
#modal-body {
  padding: 12px 14px 16px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
  -webkit-user-select: text;
  user-select: text;
}

/* 更新履歴 */
.changelog-entry { margin-bottom: 14px; }
.changelog-entry h3 { margin: 0 0 4px; font-size: 14px; color: var(--accent); }
.changelog-entry .date { color: var(--text-dim); font-size: 12px; margin-left: 8px; font-weight: normal; }
.changelog-entry ul { margin: 0; padding-left: 20px; }

/* ===== 狭い画面（スマホ縦）向け調整 ===== */
@media (max-width: 520px) {
  #hud { gap: 10px; font-size: 12px; }
  .hud-value { font-size: 15px; }
  .hud-gauge { min-width: 70px; }
}
/* 背の低い画面（スマホ横）向け調整 */
@media (max-height: 460px) {
  #info-panel { max-height: 55vh; }
  .round-btn { width: 38px; height: 38px; font-size: 16px; }
  #cam-controls { gap: 6px; }
}

/* ===== 段階2：ログ・パネル部品 ===== */
.hud-value.research { color: #7ab0e0; }

#log {
  position: fixed;
  top: calc(56px + var(--safe-t));
  left: calc(10px + var(--safe-l));
  width: min(380px, calc(100vw - 80px));
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 8;
  pointer-events: none;
}
.log-item {
  background: rgba(10, 12, 16, 0.82);
  border-left: 3px solid #5a6472;
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1.4;
  transition: opacity 0.8s;
}
.log-item.warn { border-left-color: #d4a73a; }
.log-item.danger { border-left-color: var(--danger); color: #f0b0a8; }
.log-item.good { border-left-color: #6fd27a; }
.log-item.fade { opacity: 0; }

#info-title .risk-badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  color: #111;
  margin-right: 4px;
  vertical-align: 2px;
}
#info-body .row { margin-bottom: 6px; color: var(--text); }
#info-body .desc { margin: 4px 0 8px; font-size: 12px; }
.dim { color: var(--text-dim); }
.small { font-size: 11px; }
.warn-text { color: #e8c050 !important; }

.pips { display: inline-flex; gap: 3px; vertical-align: middle; }
.pips i { width: 14px; height: 6px; background: #2a2f36; display: inline-block; }
.pips i.on { background: #6fd27a; }
.pips i.on.low { background: var(--danger); }

.work-hint { font-size: 12px; color: var(--text); margin: 6px 0; }
.work-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 4px;
}
.work-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 2px;
  min-height: 56px;
  background: #1b2028;
  border: 1px solid var(--panel-line);
}
.work-btn:hover:not(:disabled) { border-color: var(--accent); }
.work-btn:active:not(:disabled) { background: #2a313b; }
.work-btn:disabled { opacity: 0.4; cursor: default; }
.work-btn .wname { font-weight: bold; font-size: 14px; color: var(--text); }
.work-btn .wstat { font-size: 10px; color: var(--text-dim); }
.work-btn .wrate { font-size: 12px; color: #7ab0e0; }

.btn {
  margin-top: 8px;
  padding: 8px 12px;
  min-height: 38px;
  background: #1b2028;
  border: 1px solid var(--panel-line);
}
.btn:hover { border-color: var(--accent); }

.bar-row { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 4px; color: var(--text); }
.bar-row > span:first-child { width: 20px; }
.bar { flex: 1; height: 8px; background: #1c2129; border: 1px solid #39414d; overflow: hidden; }
.bar i, .mbar i { display: block; height: 100%; }
i.hp { background: #c8443c; }
i.sp { background: #7ab0e0; }
.num { width: 54px; text-align: right; font-variant-numeric: tabular-nums; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; margin-top: 6px; color: var(--text); font-size: 12px; }

.staff-list { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.staff-row {
  display: grid;
  grid-template-columns: 5.5em 6em 1fr 3em 60px 4.5em;
  align-items: center;
  gap: 6px;
  text-align: left;
  padding: 8px;
  min-height: 42px;
  background: #1b2028;
  border: 1px solid var(--panel-line);
  font-size: 13px;
}
.staff-row:hover:not(:disabled) { border-color: var(--accent); }
.staff-row:disabled { opacity: 0.4; cursor: default; }
.staff-row .sname { font-weight: bold; }
.staff-row .sdept { font-size: 11px; }
.staff-row .sstate { font-size: 11px; color: var(--text-dim); text-align: right; }
.sbar { display: flex; flex-direction: column; gap: 2px; }
.mbar { display: block; height: 4px; background: #2a2f36; }
#modal-body .staff-row:nth-child(n) > span:nth-child(3):empty { display: none; }

@media (max-width: 520px) {
  .staff-row { grid-template-columns: 1fr auto 60px; grid-template-rows: auto auto; font-size: 12px; }
  .staff-row .sdept { grid-column: 2; }
  .staff-row .sstate { grid-column: 3; }
  .work-btn .wname { font-size: 13px; }
  #log { width: calc(100vw - 20px); }
}

/* HUDは折り返さない（狭い画面では崩壊ゲージを縮める） */
.hud-block, .hud-btn { white-space: nowrap; flex-shrink: 0; }
.hud-gauge { flex-shrink: 1; min-width: 50px; }
@media (max-width: 520px) {
  #hud { gap: 8px; padding-left: calc(8px + var(--safe-l)); padding-right: calc(8px + var(--safe-r)); }
  .hud-btn { padding: 6px 8px; }
  .hud-spacer { display: none; }
  .hud-gauge { flex: 1 1 auto; }
}

/* 狭い画面：情報パネルを横いっぱいにし、表示中はズームボタンを隠す（ピンチは使える） */
@media (max-width: 600px) {
  #info-panel { left: calc(6px + var(--safe-l)); right: calc(6px + var(--safe-r)); width: auto; bottom: calc(6px + var(--safe-b)); }
  body.panel-open #cam-controls { display: none; }
  .work-grid { gap: 4px; }
  .work-btn { min-height: 50px; padding: 4px 1px; }
}
@media (max-width: 340px) {
  #hud { font-size: 11px; gap: 6px; }
  .hud-value { font-size: 13px; }
  .hud-label { font-size: 9px; }
  .hud-btn { padding: 4px 6px; min-height: 30px; }
}

/* ===== 段階3：戦闘UI ===== */
#log { top: calc(var(--hud-h, 50px) + 6px); }
.hud-btn.alert {
  background: #5a1a1a;
  border-color: var(--danger);
  color: #ffd0c8;
  animation: alert-blink 1s infinite;
}
@keyframes alert-blink { 50% { background: #8a2a24; } }
.hud-btn.active { background: #3a3220; border-color: var(--accent); color: #f0d890; }
.danger-text { color: #e05a50; font-size: 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.btn-row .btn { margin-top: 0; flex: 1 1 auto; }
.btn.primary { background: #3a2a1c; border-color: #8a6a2a; color: #f0d890; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.chip { background: #2a2f36; border: 1px solid var(--panel-line); padding: 4px 8px; font-size: 12px; min-height: 30px; }
.staff-row.pick.checked { border-color: var(--accent); background: #262218; }
body.multi-mode #world { cursor: crosshair; }

@media (max-width: 520px) {
  #hud { flex-wrap: wrap; row-gap: 4px; }
}

/* ===== 段階4：1日の進行 ===== */
.hud-sub { font-size: 11px; color: var(--text-dim); font-weight: normal; margin-left: 1px; }
.hud-value.overtime, .hud-value.overtime .hud-sub { color: var(--danger); animation: alert-blink-text 1s infinite; }
@keyframes alert-blink-text { 50% { opacity: 0.5; } }
.round-btn.active { border-color: var(--accent); color: #f0d890; background: #3a3220; }
.round-btn.speed { font-size: 14px; font-weight: bold; }

#pause-banner {
  position: fixed;
  top: calc(var(--hud-h, 50px) + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 16px;
  background: rgba(10, 12, 16, 0.85);
  border: 1px solid var(--accent);
  color: #f0d890;
  font-size: 13px;
  letter-spacing: 0.2em;
  z-index: 8;
  pointer-events: none;
}

#banner {
  position: fixed;
  left: 0; right: 0;
  top: 38%;
  text-align: center;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  color: #e8dcc0;
  text-shadow: 0 2px 12px #000;
}
#banner div { font-size: 46px; font-weight: bold; letter-spacing: 0.15em; }
#banner small { font-size: 15px; color: var(--accent); letter-spacing: 0.2em; }
#banner.show { animation: banner 2.6s ease-out forwards; }
@keyframes banner {
  0% { opacity: 0; transform: translateY(10px); }
  15% { opacity: 1; transform: none; }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* 全画面スクリーン */
#screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(5, 6, 8, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(12px + var(--safe-t)) calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) calc(12px + var(--safe-l));
}
#screen-box {
  width: min(760px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: #0f1317;
  border: 1px solid var(--panel-line);
  border-top: 3px solid var(--accent);
  padding: 18px 20px 20px;
}
#screen-box h1 { margin: 0 0 8px; font-size: 22px; letter-spacing: 0.06em; }
#screen-box h1.bad { color: var(--danger); }
#screen-box h1.good { color: #6fd27a; }
.screen-lead { color: var(--text); font-size: 14px; margin: 0 0 14px; line-height: 1.6; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
  padding: 10px;
  background: #161b21;
  border: 1px solid var(--panel-line);
}
.card:hover { border-color: var(--accent); background: #1c2229; }
.card .risk-badge { display: inline-block; padding: 1px 6px; font-size: 11px; color: #111; }
.card-preview { width: 100%; height: auto; background: linear-gradient(#1d232b, #12161b); }
.card-name { font-size: 15px; color: var(--text); }
.card-desc { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
table.summary { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 14px; }
table.summary th { text-align: left; color: var(--text-dim); font-weight: normal; padding: 6px 8px; width: 45%; border-bottom: 1px solid #222830; }
table.summary td { padding: 6px 8px; border-bottom: 1px solid #222830; }
table.summary td.bad { color: #f08a80; }
table.summary td.good { color: #7ab0e0; }
.hire-list { margin: 0 0 14px; padding-left: 20px; line-height: 1.8; }
#screen .btn.wide { min-height: 46px; font-size: 15px; margin-top: 8px; }

@media (max-width: 600px) {
  .cards { grid-template-columns: 1fr; }
  .card { display: grid; grid-template-columns: 110px 1fr; grid-template-rows: auto auto 1fr; column-gap: 10px; }
  .card-preview { grid-row: 1 / 4; width: 110px; }
  #banner div { font-size: 36px; }
}

/* ===== 段階5：管理メニュー・情報 ===== */
.manage-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.research-pt { color: #7ab0e0; font-size: 14px; }
.research-pt b { font-size: 20px; }
.tabs { display: flex; gap: 4px; margin: 10px 0; border-bottom: 1px solid var(--panel-line); }
.tab { flex: 1; padding: 10px 6px; min-height: 42px; background: #161b21; border: 1px solid var(--panel-line); border-bottom: none; color: var(--text-dim); }
.tab.on { background: #2a2416; color: #f0d890; border-color: #8a6a2a; }
.tab-body { margin-bottom: 8px; }
.m-card { background: #161b21; border: 1px solid var(--panel-line); padding: 10px; margin-bottom: 8px; font-size: 13px; }
.m-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.m-card .risk-badge, .info-sec .risk-badge { display: inline-block; padding: 1px 6px; font-size: 11px; color: #111; }
.stage-chips { display: flex; flex-wrap: wrap; gap: 3px; margin: 6px 0; }
.stage-chips span { font-size: 11px; padding: 2px 6px; background: #22272e; color: #5a636e; border: 1px solid #2c333d; }
.stage-chips span.on { background: #1f3a2a; color: #9ee0a8; border-color: #3a6a4a; }
.type-badge { font-size: 11px; padding: 1px 6px; color: #111; }
.type-badge.weapon { background: #d0a050; }
.type-badge.armor { background: #6a9ac0; }
.equip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 2px; }
.equip-row label { display: flex; align-items: center; gap: 4px; font-size: 12px; flex: 1 1 200px; }
select { font: inherit; font-size: 13px; color: var(--text); background: #0f1317; border: 1px solid var(--panel-line); padding: 6px; min-height: 34px; flex: 1; max-width: 100%; }
.train-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 6px; }
.small-btn { font-size: 12px; padding: 6px 4px; min-height: 34px; background: #1b2028; border: 1px solid var(--panel-line); }
.small-btn:disabled { opacity: 0.35; }
.btn.danger { background: #4a1a1a; border-color: var(--danger); color: #ffd0c8; }
.new-badge { font-size: 10px; background: #6fd27a; color: #111; padding: 0 5px; }
.good-text { color: #9ee0a8; }
.detail-title { font-size: 17px; margin: 10px 0 6px; }
.info-sec { border-top: 1px solid #222830; padding: 8px 0; }
.info-sec h3 { margin: 0 0 4px; font-size: 13px; color: var(--accent); }
.info-sec.is-locked h3 { color: #5a636e; }
.info-sec p { margin: 4px 0; }
.info-sec ul { margin: 4px 0; padding-left: 20px; }
.locked { color: #5a636e; letter-spacing: 0.2em; }
.story { font-style: italic; color: #c8c0b0; }
.info-table { border-collapse: collapse; font-size: 12px; margin: 4px 0; }
.info-table th, .info-table td { padding: 3px 10px 3px 0; text-align: left; }
.info-table th { color: var(--text-dim); font-weight: normal; }
#info-body > .btn { margin-top: 2px; }
@media (max-width: 520px) {
  .train-row { grid-template-columns: repeat(2, 1fr); }
}
/* 管理メニューの「管理を終える」は画面下に固定 */
#screen-box > .btn.wide[data-act="done"] { position: sticky; bottom: 0; box-shadow: 0 -8px 16px rgba(10, 12, 16, 0.9); }

/* ===== 段階6：タイトル・メニュー ===== */
#title {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  background: radial-gradient(ellipse at center, rgba(8, 10, 13, 0.55), rgba(5, 6, 8, 0.92));
  overflow-y: auto;
}
.title-box { text-align: center; width: min(420px, 100%); }
.title-sub { font-size: 11px; letter-spacing: 0.35em; color: var(--text-dim); }
#title h1 { margin: 10px 0 6px; font-size: 40px; letter-spacing: 0.12em; color: #e8dcc0; text-shadow: 0 0 24px rgba(212, 167, 58, 0.25); line-height: 1.2; }
#title h1 span { display: block; font-size: 22px; color: var(--accent); letter-spacing: 0.5em; margin-top: 4px; }
.title-lead { color: var(--text); font-size: 13px; margin: 0 0 18px; }
.title-menu { display: flex; flex-direction: column; gap: 8px; }
.title-menu button {
  padding: 12px;
  min-height: 48px;
  font-size: 16px;
  letter-spacing: 0.1em;
  background: rgba(20, 24, 30, 0.9);
  border: 1px solid var(--panel-line);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.title-menu button:hover:not(:disabled) { border-color: var(--accent); color: #f0d890; }
.title-menu button:disabled { opacity: 0.4; cursor: default; }
.title-menu small { font-size: 11px; color: var(--text-dim); letter-spacing: 0; margin-top: 2px; }
.title-note { margin-top: 18px; font-size: 11px; color: #5a636e; }
.title-note span { margin-left: 6px; }
body.on-title #hud, body.on-title #cam-controls, body.on-title #log { display: none; }

.menu-h { font-size: 13px; color: var(--accent); margin: 10px 0 6px; }
.vol-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.vol-row span { width: 5em; }
.vol-row input[type=range] { flex: 1; min-height: 32px; accent-color: #d4a73a; }
.vol-row input[type=checkbox] { width: 22px; height: 22px; accent-color: #d4a73a; }
.vol-row b { width: 2.5em; text-align: right; font-variant-numeric: tabular-nums; }
.credit { margin: 6px 0 10px; }
.credit a { color: #7ab0e0; word-break: break-all; }
@media (max-height: 520px) {
  #title h1 { font-size: 30px; }
  .title-menu { display: grid; grid-template-columns: 1fr 1fr; }
  .title-menu button { min-height: 40px; padding: 8px; }
}

/* ===== Essen：MOD管理・エディタ ===== */
#modal { z-index: 80; } /* Essen画面より手前に確認ダイアログを出す */
#essen {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(5, 6, 8, 0.94);
  display: flex;
  justify-content: center;
  padding: calc(10px + var(--safe-t)) calc(10px + var(--safe-r)) calc(10px + var(--safe-b)) calc(10px + var(--safe-l));
}
#essen-box {
  width: min(900px, 100%);
  overflow-y: auto;
  background: #0f1317;
  border: 1px solid var(--panel-line);
  border-top: 3px solid #8a6fc4;
  padding: 14px 16px 20px;
}
.essen-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.essen-head h1 { margin: 0; font-size: 22px; letter-spacing: 0.08em; }
.essen-head h1 span { font-size: 13px; color: #b9a6e8; margin-left: 6px; letter-spacing: 0.1em; }
.essen-head .btn { margin-top: 0; }
.essen-notice { background: #2a2416; border: 1px solid #8a6a2a; padding: 8px 10px; margin: 8px 0; font-size: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.essen-notice .btn { margin-top: 0; }
.essen-list { margin-top: 12px; }
.essen-errors { color: #f0b0a8; font-size: 12px; margin: 4px 0; padding-left: 18px; }
.m-row .spacer { flex: 1; }
.m-card.m-row .btn { margin-top: 0; }
.essen-form { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.essen-form .menu-h, .essen-form .essen-note { grid-column: 1 / -1; margin-bottom: 0; }
.essen-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-dim); }
.essen-field.textarea, .essen-field.lines, .essen-field.code, .essen-field.image { grid-column: 1 / -1; }
.essen-input { display: flex; align-items: center; gap: 8px; }
.essen-input input[type=text], .essen-input input[type=number], .essen-input textarea, .essen-input select {
  flex: 1; width: 100%; font: inherit; font-size: 13px; color: var(--text);
  background: #0a0d10; border: 1px solid var(--panel-line); padding: 6px 8px; min-height: 34px;
  -webkit-user-select: text; user-select: text;
}
.essen-input textarea { resize: vertical; line-height: 1.5; }
.essen-input textarea.code { font-family: Consolas, "Courier New", monospace; font-size: 12px; color: #c8e0b0; }
.essen-input input[type=range] { flex: 1; accent-color: #8a6fc4; min-height: 30px; }
.essen-input input[type=color] { width: 56px; height: 34px; padding: 0; border: 1px solid var(--panel-line); background: none; }
.essen-input input[type=checkbox] { width: 22px; height: 22px; accent-color: #8a6fc4; }
.essen-input output { width: 3.5em; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.essen-input .btn { margin-top: 0; }
.essen-thumb { max-width: 96px; max-height: 96px; background: #222; border: 1px solid var(--panel-line); }
.essen-note code, .essen-field code { color: #c8e0b0; }
.abno-edit { display: grid; grid-template-columns: 240px 1fr; gap: 14px; align-items: start; }
.abno-preview { position: sticky; top: 0; text-align: center; }
.abno-preview canvas { width: 100%; max-width: 220px; border: 1px solid var(--panel-line); }
.essen-foot { position: sticky; bottom: -20px; background: #0f1317; padding: 10px 0; margin-top: 12px; box-shadow: 0 -8px 16px rgba(10, 12, 16, 0.9); }
@media (max-width: 640px) {
  .essen-form { grid-template-columns: 1fr; }
  .abno-edit { grid-template-columns: 1fr; }
  .abno-preview { position: static; }
  .abno-preview canvas { max-width: 180px; }
}
