:root {
  --bg: #000;
  --panel: #0e0e0e;
  --panel-2: #161616;
  --line: #262626;
  --line-2: #3a3a3a;
  --text: #f4f4f4;
  --muted: #8d8d8d;
  --danger: #ff5a52;
  --ok: #e8e8e8;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; }

.screen { min-height: 100dvh; padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 90px); }
.screen.center { display: flex; flex-direction: column; align-items: center; justify-content: center; padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
.screen.center > .card, .screen.center > form { width: 100%; max-width: 400px; }

.brand { font-weight: 800; letter-spacing: .32em; font-size: 15px; }
.brand.big { font-size: 34px; letter-spacing: .38em; margin-bottom: 6px; padding-left: .38em; }
.tag { text-transform: uppercase; letter-spacing: .2em; font-size: 11px; margin: 0 0 26px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; text-align: center; max-width: 320px; margin-top: 18px; }
.mono { font-family: var(--mono); }
h2 { font-size: 20px; margin: 0 0 8px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin: 28px 0 10px; font-weight: 600; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 18px;
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 14px;
}

label { font-size: 13px; color: var(--muted); margin-top: 4px; }
input, textarea, select {
  width: 100%;
  font: inherit;
  font-size: 16px; /* evita zoom no iPhone */
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 12px 13px;
  outline: none;
}
input:focus, textarea:focus { border-color: #fff; }
textarea { resize: vertical; }
input[type=search] { -webkit-appearance: none; }
.code-input { text-align: center; font-family: var(--mono); font-size: 30px; letter-spacing: .4em; padding-left: .4em; }
#recovery-key { font-family: var(--mono); text-transform: uppercase; font-size: 14px; }

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px; font-family: var(--mono); }
.eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); font-size: 18px; padding: 8px; cursor: pointer; }

.btn {
  font: inherit; font-size: 15px; font-weight: 600;
  color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: 10px;
  padding: 12px 14px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none; text-align: center;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: #fff; color: #000; border-color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); border-color: #4a1d1b; }
.btn.icon { padding: 7px 11px; font-size: 13px; font-weight: 500; }
.small-btn { font-size: 13px; padding: 8px; }
.file-btn { display: block; margin: 0; font-size: 14px; color: var(--text); border: 1px dashed var(--line-2); }

.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 6px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.pair-code { font-family: var(--mono); font-size: 40px; font-weight: 700; letter-spacing: .14em; text-align: center; padding: 14px 0; border: 1px solid var(--line-2); border-radius: 12px; background: #000; }

.meter { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--danger); transition: width .2s; }
.meter span[data-s="3"] { background: #cfcfcf; }
.meter span[data-s="4"], .meter span[data-s="5"] { background: #fff; }

.recovery-box {
  font-family: var(--mono); font-size: 17px; line-height: 1.7; letter-spacing: .04em;
  background: #000; border: 1px solid #fff; border-radius: 12px;
  padding: 14px; word-break: break-all; text-align: center; user-select: all; -webkit-user-select: all;
}
.check { display: flex; gap: 10px; align-items: center; color: var(--text); font-size: 14px; margin: 8px 0 2px; }
.check input { width: 20px; height: 20px; accent-color: #fff; }

/* cofre aberto */
.top { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 14px; position: sticky; top: 0; background: var(--bg); z-index: 5; padding-top: calc(env(safe-area-inset-top) + 4px); margin-top: calc(-1 * env(safe-area-inset-top)); }
.toolbar { display: flex; gap: 8px; }
.toolbar input { flex: 1; }
.toolbar .btn { white-space: nowrap; }
.chips { display: flex; gap: 6px; margin: 12px 0 6px; overflow-x: auto; }
.chip { font: inherit; font-size: 13px; padding: 6px 13px; border-radius: 99px; border: 1px solid var(--line-2); background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap; }
.chip.on { background: #fff; color: #000; border-color: #fff; }

.list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.item { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; }
.item:hover { border-color: var(--line-2); }
.item-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.item-text { min-width: 0; }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty, .empty-search { text-align: center; padding: 40px 10px; }
.type-pill { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; padding: 4px 7px; border-radius: 6px; border: 1px solid var(--line-2); color: var(--muted); flex-shrink: 0; min-width: 52px; text-align: center; }
.type-pill.t-api { background: #fff; color: #000; border-color: #fff; }
.type-pill.t-nota { border-style: dashed; }

.item.dev { cursor: default; flex-wrap: wrap; }
.dev-actions { display: flex; gap: 6px; }
.tag-now { font-size: 11px; font-weight: 600; background: #fff; color: #000; padding: 2px 6px; border-radius: 5px; margin-left: 4px; vertical-align: middle; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.log { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.log li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.log-t { font-family: var(--mono); font-size: 12px; color: var(--muted); display: block; }

.banner { background: #fff; color: #000; border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.banner .btn.ghost { color: #000; }
.banner .btn.primary { background: #000; color: #fff; border-color: #000; }
.banner-row { display: flex; flex-direction: column; gap: 10px; }

.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: center; gap: 4px;
  background: rgba(0,0,0,.92); border-top: 1px solid var(--line);
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 8px);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.nav { flex: 1; max-width: 300px; font: inherit; font-size: 14px; font-weight: 600; background: none; border: 0; color: var(--muted); padding: 10px; border-radius: 10px; cursor: pointer; }
.nav.on { color: #000; background: #fff; }

/* dialogs */
dialog {
  border: 0; padding: 0; background: transparent; color: var(--text);
  width: 100%; max-width: 560px; max-height: 92dvh;
  margin: auto auto 0; overflow: visible;
}
@media (min-width: 700px) { dialog { margin: auto; } }
dialog::backdrop { background: rgba(0,0,0,.72); }
.sheet {
  background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px);
  display: flex; flex-direction: column; gap: 10px;
  max-height: 92dvh; overflow-y: auto;
}
@media (min-width: 700px) { .sheet { border-radius: 18px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; }
.seg { display: flex; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; font: inherit; font-size: 14px; padding: 10px; background: none; color: var(--muted); border: 0; cursor: pointer; }
.seg button.on { background: #fff; color: #000; font-weight: 600; }
.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }

.field { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.f-label { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.f-value { word-break: break-all; font-size: 15px; }
.f-actions { display: flex; gap: 6px; }
.f-notes { white-space: pre-wrap; word-break: break-word; font-size: 14px; }

#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #fff; color: #000; font-size: 14px; font-weight: 500;
  padding: 10px 16px; border-radius: 10px; max-width: calc(100% - 32px); text-align: center;
  transition: opacity .2s, transform .2s; z-index: 100;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
