:root {
  --bg: #1b1b1f;
  --panel: #26262c;
  --line: #3a3a42;
  --text: #ececf1;
  --muted: #9a9aa6;
  --accent: #d97757;
  --danger: #e5484d;
  --app-height: 100dvh;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif; }
body { height: var(--app-height); overflow: hidden; }
button { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; min-height: 36px; }
button:active { background: var(--line); }
[hidden] { display: none !important; }
.error { color: var(--danger); min-height: 1.2em; }
.muted { color: var(--muted); font-size: 13px; }

#login { height: 100%; display: grid; place-items: center; padding: 16px; }
#login-form { width: min(360px, 100%); display: grid; gap: 12px; }
#login-form h1 { margin: 0; font-size: 22px; }
#login-form p { margin: 0; color: var(--muted); font-size: 14px; }
#login-form input { font-size: 16px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
#login-form button[type=submit] { background: var(--accent); border-color: var(--accent); color: #fff; padding: 12px; }

#main { height: 100%; display: flex; flex-direction: column; padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
header { display: flex; gap: 6px; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); }
#tabs { display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: none; }
#tabs::-webkit-scrollbar { display: none; }
#tabs button { white-space: nowrap; flex: none; }
#tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#tabs button .dot { color: #7ee787; margin-left: 4px; }
header .add { flex: none; white-space: nowrap; }
header .icon { flex: none; width: 36px; padding: 0; }

#term-wrap { flex: 1; min-height: 0; position: relative; padding: 4px 0 0 6px; }
#term { height: 100%; }
#empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); }
#status { position: absolute; top: 8px; right: 8px; background: var(--panel); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; font-size: 13px; color: var(--muted); }

#keys { display: flex; gap: 6px; overflow-x: auto; padding: 6px 8px; border-top: 1px solid var(--line); scrollbar-width: none; }
#keys::-webkit-scrollbar { display: none; }
#keys button { flex: none; min-width: 44px; font-size: 14px; }

#input { display: flex; gap: 6px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
#text { flex: 1; resize: none; font: 16px/1.4 inherit; font-family: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); max-height: 30vh; }
#input button { background: var(--accent); border-color: var(--accent); color: #fff; padding: 0 16px; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; width: min(440px, calc(100% - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog h2 { font-size: 16px; margin: 8px 0; }
#device-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
#device-list li { display: flex; gap: 8px; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
#device-list small { display: block; color: var(--muted); }
.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
