:root {
  --bg: #0e0f12;
  --panel: #17191d;
  --line: #24272d;
  --text: #e6e7ea;
  --muted: #8b8f98;
  --accent: #5b8def;
}

* { box-sizing: border-box; }

/* .grid sets display:grid, which would otherwise beat the hidden attribute */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.brand { font-weight: 600; letter-spacing: 0.02em; }

.path {
  color: var(--muted);
  font: 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.spacer { flex: 1; }

.status { color: var(--muted); font-size: 13px; }

.btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 14px;
  cursor: pointer;
}

.btn:disabled { opacity: 0.6; cursor: default; }

.btn.tiny {
  padding: 4px 10px;
  font-size: 12px;
  background: #2a2e36;
}

.grid {
  display: grid;
  grid-template-columns: 28% 1fr;
  gap: 16px;
  align-items: start;
}

.accounts {
  position: sticky;
  top: 20px;
  display: grid;
  gap: 10px;
}

.pane-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 2px;
}

#accounts { display: grid; gap: 10px; }

.acct-editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.acct-form {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.acct-foot {
  display: flex;
  gap: 10px;
  padding: 0 14px 14px;
}

.acct-edit-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #131519;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.acct-edit-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.acct-key {
  color: var(--muted);
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}

.acct-edit-items { display: grid; gap: 8px; }

.acct-edit-add { display: flex; gap: 8px; flex-wrap: wrap; }

.acct-edit-tag {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.acct-edit-item {
  display: grid;
  grid-template-columns: 1fr 1.6fr auto auto;
  gap: 8px;
  align-items: center;
}

.field {
  min-width: 0;
  padding: 6px 10px;
  background: #0f1115;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.field:focus {
  outline: none;
  border-color: var(--accent);
}

.field.value,
.field.raw {
  font: 13px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.field.raw {
  width: 100%;
  resize: vertical;
  line-height: 1.5;
}

.field.key { max-width: 180px; }

.acct-edit-head .field:first-child { flex: 1; }

.icon {
  padding: 2px 8px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.icon:hover {
  background: #22252b;
  color: var(--text);
}

.acct-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.acct {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.acct-head {
  display: flex;
  align-items: center;
}

.acct-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 12px;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.acct-toggle:hover { background: #1c1f24; }

.acct-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.acct-head .icon { margin-right: 6px; }

.acct-label {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acct-count {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.chevron {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  transition: transform 120ms ease;
}

.acct.open .chevron { transform: rotate(90deg); }

.acct-items { border-top: 1px solid var(--line); padding: 4px 0; }

.acct-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
}

.acct-item-label { color: var(--muted); font-size: 13px; }

.acct-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.acct-item-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.acct-note {
  margin: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.note {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 70vh;
  display: flex;
  flex-direction: column;
}

.note-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.note-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.note-bar .btn {
  padding: 5px 12px;
  font-size: 13px;
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.btn.ghost:hover { color: var(--text); border-color: var(--muted); }

#md {
  flex: none;
  width: 100%;
  min-height: 60vh;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: var(--text);
  border: 0;
  padding: 16px;
  font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  outline: none;
}

.note-view {
  flex: none;
  padding: 16px;
}

.note-view > :first-child { margin-top: 0; }

.note-view .empty { color: var(--muted); }

@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; }
  .accounts { position: static; }
  .acct-edit-item { grid-template-columns: 1fr; }
  .acct-edit-item .icon { justify-self: end; }
  .acct-edit-head { flex-wrap: wrap; }
  .field.key { max-width: none; }
  .note { min-height: 50vh; }
  #md { min-height: 40vh; }
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login {
  width: min(360px, 90vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
}

.login h1 {
  font-size: 18px;
  margin: 0 0 20px;
  letter-spacing: 0.02em;
}

.login form {
  display: grid;
  gap: 10px;
}

.login input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
}

.login input:focus { border-color: var(--accent); }

.login .btn { width: 100%; padding: 10px; }

.login-error {
  color: #f2777a;
  font-size: 13px;
  min-height: 18px;
  margin: 0;
}
