:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #dde1e6;
  --text: #1f2430;
  --muted: #667085;
  --primary: #2f5fd8;
  --primary-hover: #24499f;
  --danger: #c0392b;
  --danger-bg: #fbeae8;
  --success-bg: #eafaf1;
  --success-text: #1e7e45;
  --radius: 8px;
}

* { box-sizing: border-box; }

/* The `hidden` attribute is how every screen/section toggle in app.js
   works (showScreen, logout, etc). By default that's safe, but ANY
   selector below that sets `display` on the same element (e.g.
   `.topbar-account { display: flex }`) silently wins over the browser's
   default `[hidden] { display: none }` UA rule, because author CSS
   always beats user-agent CSS regardless of selector specificity. This
   was bug #4 - the logged-in pseudonym stayed visible after logout even
   though `hidden` was correctly being set on its container. This one
   rule makes `hidden` always win, for every element, permanently. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.menu-wrapper {
  position: relative;
}

.menu-btn {
  font-size: 1.1rem;
  line-height: 1;
}

.menu-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.35rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
  min-width: 170px;
  z-index: 20;
  overflow: hidden;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.9rem;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
}

.menu-item:hover {
  background: #f0f1f3;
}

.topbar-account {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar-sep {
  color: var(--border);
}

.motto-banner {
  font-style: italic;
  color: var(--muted);
  padding: 0 0 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.success-box {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  background: var(--success-bg);
  color: var(--success-text);
  font-size: 0.9rem;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.screen h1 {
  margin-top: 0;
  font-size: 1.5rem;
}

/* Scoped to #screen-settings specifically (not a bare ".screen h2" rule)
   because the dashboard already uses an <h2> for the current category
   name (#currentTypeName) with its own different styling. */
#screen-settings h2 {
  font-size: 1.1rem;
  margin: 2rem 0 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

#screen-settings h2:first-of-type {
  margin-top: 1.5rem;
}

.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.25rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.92rem;
  font-weight: 600;
}

label .muted {
  font-weight: 400;
}

input[type="text"],
input[type="password"],
input[type="datetime-local"],
textarea {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}

input:focus,
textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

textarea { resize: vertical; font-family: inherit; }

.button-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.btn {
  font: inherit;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.btn:hover { background: #f0f1f3; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-hover); }

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

.btn-small {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  align-self: flex-start;
  font: inherit;
  font-size: 0.9rem;
}

.error-box {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.9rem;
}

.credential-box {
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.credential-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.credential-value {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 1.15rem;
  word-break: break-all;
  margin-bottom: 0.6rem;
}

.checkbox-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.25rem;
  font-weight: 400;
  font-size: 0.92rem;
}

.checkbox-row input { width: auto; }

.dashboard-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.type-nav {
  flex: 0 0 200px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
}

.type-nav-header {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

#typeList {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

#typeList li button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  color: var(--text);
}

#typeList li button:hover { background: #f0f1f3; }

#typeList li.active button {
  background: var(--primary);
  color: #fff;
}

.add-type-form {
  display: flex;
  gap: 0.4rem;
  margin-top: 0;
}

.add-type-form input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
}

.type-panel {
  flex: 1 1 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  min-height: 200px;
}

.type-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.type-panel-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.object-form-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.inline-label {
  flex: 1 1 auto;
}

.object-list {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.object-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}

.object-item textarea {
  width: 100%;
  margin-bottom: 0.5rem;
}

.object-item-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.object-item-actions {
  display: flex;
  gap: 0.5rem;
}

.status-toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  background: var(--success-bg);
  color: var(--success-text);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  font-size: 0.9rem;
}

.status-toast.is-error {
  background: var(--danger-bg);
  color: var(--danger);
}

@media (max-width: 560px) {
  .dashboard-layout { flex-direction: column; }
  .type-nav { flex: 1 1 auto; width: 100%; }
}
