[hidden] { display: none !important; }
:root {
  --bg: #0b0d10; --fg: #e6e8eb; --muted: #8a9099; --line: #1c2027;
  --key: #171a20; --key-on: #2b313b; --accent: #e6e8eb; --danger: #ff6b6b;
  --app-h: 100dvh; --app-top: 0px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overflow: hidden;
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  overscroll-behavior: none; touch-action: none; }
#app { position: fixed; left: 0; right: 0; top: var(--app-top); height: var(--app-h);
  display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
#term { flex: 1; min-height: 0; padding: 4px 0 0 6px; }
#term .xterm { height: 100%; }
#term .xterm-viewport { overflow-y: hidden !important; background: var(--bg) !important; }

#bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  padding-bottom: max(6px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
body.kb #bar { padding-bottom: 6px; }
#keys { flex: 1; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; }
#keys::-webkit-scrollbar { display: none; }
.k { flex: none; min-width: 42px; height: 36px; padding: 0 10px; border: 0; border-radius: 9px;
  background: var(--key); color: var(--fg); font: 500 14px ui-monospace, "SF Mono", Menlo, monospace;
  user-select: none; -webkit-user-select: none; touch-action: manipulation; transition: background .08s, transform .08s; }
.k:active, .k.down { background: var(--key-on); transform: scale(.94); }
.k.on { background: var(--fg); color: var(--bg); }
.k.snip { font-family: inherit; font-size: 13px; color: var(--muted); }
.k.icon { font-size: 18px; min-width: 40px; }

#status { position: absolute; top: calc(env(safe-area-inset-top) + 8px); right: 10px; z-index: 5;
  padding: 4px 10px; border-radius: 99px; font-size: 12px; background: rgba(23,26,32,.92);
  color: var(--muted); pointer-events: none; backdrop-filter: blur(8px); }
#status.bad { color: #ffb86b; }

.sheet, .screen { touch-action: auto; }
.screen { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 20; padding: 24px; }
.screen form { width: 100%; max-width: 360px; text-align: center; }
.screen h1 { font-size: 20px; margin: 12px 0 4px; }
.screen p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.logo { color: var(--fg); }
input, textarea { width: 100%; background: var(--key); color: var(--fg); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; font: 17px ui-monospace, Menlo, monospace; outline: none; }
input { text-align: center; letter-spacing: .08em; }
textarea { font-size: 14px; min-height: 200px; resize: vertical; }
button.primary { width: 100%; margin-top: 12px; height: 48px; border: 0; border-radius: 12px;
  background: var(--fg); color: var(--bg); font: 600 16px inherit; font-family: inherit; }
.err { color: var(--danger) !important; min-height: 1.4em; margin-top: 12px !important; }

.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.45); display: flex; align-items: flex-end;
  animation: fade .15s ease; }
.sheet .panel { width: 100%; max-width: 520px; margin: 0 auto; background: #12151a; border-radius: 18px 18px 0 0;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 4px;
  animation: up .2s cubic-bezier(.2,.8,.2,1); max-height: 90%; overflow: auto; }
.sheet .panel > button, .row { background: none; border: 0; color: var(--fg); text-align: left;
  font: 16px inherit; font-family: inherit; padding: 13px 6px; border-bottom: 1px solid var(--line); }
.row { display: flex; justify-content: space-between; align-items: center; }
.row button { background: var(--key); color: var(--fg); border: 0; border-radius: 8px; padding: 6px 14px; margin-left: 6px; font-size: 15px; }
.sheet .panel > button.danger { color: var(--danger); }
.sheet .panel > button.muted { color: var(--muted); border: 0; text-align: center; }
.sheet .panel > button.primary { text-align: center; border: 0; color: var(--bg); }
#modalBody h2 { font-size: 17px; margin: 8px 0; }
#modalBody p { color: var(--muted); font-size: 13px; margin: 6px 0; }
.bigcode { font: 600 24px ui-monospace, Menlo, monospace; letter-spacing: .06em; text-align: center;
  padding: 18px 0; user-select: all; -webkit-user-select: all; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
