:root {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #111a2e;
  --panel-2: #16213a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #0ea5e9;
  --ok: #4ade80;
  --err: #f87171;
  --border: #223049;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px calc(14px + env(safe-area-inset-top)) 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
}
.brand-icon { width: 28px; height: 28px; border-radius: 8px; }

.banner {
  margin: 10px 16px 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  background: #3f2d0e;
  border: 1px solid #7c5a17;
  color: #fbd38d;
}
.banner.info {
  background: #0e2a3f;
  border-color: #17567c;
  color: #7dd3fc;
}

.hidden { display: none !important; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px 0 12px;
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 8px;
  font-size: 0.92rem;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

main {
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  color: var(--muted);
}

input, select, textarea {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}
.btn.primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #04202e;
}
.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: auto;
}
.btn.small {
  padding: 8px 12px;
  font-size: 0.85rem;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.row.space-between {
  justify-content: space-between;
}

.status {
  min-height: 1.2em;
  font-size: 0.9rem;
  margin-top: 10px;
}
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.status.pending { color: var(--accent); }

.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.card .card-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}
.card .card-body {
  word-break: break-word;
  font-size: 0.95rem;
  white-space: pre-wrap;
}
.card .card-meta {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 6px;
}

h2 {
  font-size: 1.05rem;
  margin: 20px 0 8px 0;
}
h2:first-child { margin-top: 0; }

.batch-summary-row {
  margin-top: 20px;
}

.batch-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.batch-row.written {
  opacity: 0.6;
}
.batch-row-checkbox {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.batch-row-content {
  flex: 1;
  min-width: 0;
}
.batch-row-name {
  font-weight: 700;
  font-size: 1rem;
}
.batch-row-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}
.batch-row-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.batch-row-actions .btn {
  width: auto;
  flex: 1;
}

ul { padding-left: 20px; margin: 8px 0; }
li { margin-bottom: 6px; font-size: 0.92rem; }

code {
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.85em;
}
