:root {
  --bg: #f6f3ee;
  --ink: #1a1a1a;
  --muted: #5c5c5c;
  --card: #ffffff;
  --accent: #0b6e4f;
  --border: #ddd6cb;
  --danger: #9b1c1c;
  --font: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #e7f2ec 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #efe8dc 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  min-width: 0;
}

.brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}

/* Author display:flex beats the UA [hidden] rule; restore hide for chrome. */
.account-chip[hidden],
.nav[hidden],
.switcher[hidden] {
  display: none;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: min(16rem, 46vw);
  margin-left: auto;
  padding: 0.35rem 0.55rem 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(26, 26, 26, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.account-chip:hover,
.account-chip:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 110, 79, 0.12);
  outline: none;
}

.account-chip-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--accent);
}

.account-chip-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
  text-align: left;
}

.account-chip-email {
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-chip-context {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-chip-caret {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--muted);
}

.switcher {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 1rem 2rem;
  background: rgba(26, 26, 26, 0.35);
}

.switcher-panel {
  width: min(28rem, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.35rem 1.35rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.switcher-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.switcher-panel h2 {
  margin: 0;
}

.switcher-close-x {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.2rem;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  line-height: 0;
}

.switcher-close-x:hover {
  color: var(--ink);
  background: #f0ebe3;
}

.switcher-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.switcher-list li + li {
  margin-top: 0.45rem;
}

.switcher-list button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  cursor: pointer;
  color: var(--ink);
}

.switcher-list button:hover {
  border-color: var(--accent);
  background: #f4faf7;
}

.switcher-list button.current {
  border-color: var(--accent);
  background: #e7f2ec;
}

.switcher-role-icon {
  display: inline-flex;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #f0ebe3;
  color: var(--ink);
}

.switcher-list button.current .switcher-role-icon {
  background: #d5ebe1;
  color: var(--accent);
}

.switcher-role-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  flex: 1 1 auto;
}

.switcher-role-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.switcher-role-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.switcher-role-desc {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.switcher-current-badge {
  margin-left: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  background: #fff;
  border: 1px solid #b7d9c9;
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex: 1 1 auto;
  justify-content: flex-end;
}

@media (max-width: 720px) {
  .nav {
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }

  .account-chip {
    max-width: min(14rem, 55vw);
  }
}

.nav button {
  border: 1px solid transparent;
  background: transparent;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font: inherit;
}

.nav button:hover,
.nav button.active {
  color: var(--ink);
  border-color: var(--border);
  background: var(--card);
}

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

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  letter-spacing: -0.03em;
}

h2 {
  margin: 1.75rem 0 0.75rem;
  font-size: 1.15rem;
}

.muted {
  color: var(--muted);
}

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

details.card > summary {
  cursor: pointer;
  list-style-position: outside;
  font-size: 1.05rem;
}

details.card > summary::-webkit-details-marker {
  color: var(--muted);
}

details.card .details-body {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.card-emphasis {
  border-color: #b7d9c9;
  box-shadow: 0 0 0 1px #d5ebe1 inset;
}

.copy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0 0.75rem;
}

.copy-row .copy-value {
  flex: 1 1 12rem;
  display: block;
  padding: 0.45rem 0.6rem;
  background: #f4faf7;
  border: 1px solid var(--border);
  border-radius: 6px;
  word-break: break-all;
  font-size: 0.9rem;
}

label {
  display: block;
  font-size: 0.9rem;
  margin: 0.75rem 0 0.35rem;
}

input,
select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: #fff;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}

button.primary,
.btn,
a.btn {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button.primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 0.55rem 1rem;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}

button.danger-btn {
  color: var(--danger);
  border-color: #e2b4b4;
  padding: 0.3rem 0.55rem;
  font-size: 0.85rem;
}

button.danger-btn:hover {
  background: #faf0f0;
}

.error {
  color: var(--danger);
  margin-top: 0.75rem;
}

.ok {
  color: var(--accent);
  margin-top: 0.75rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.35rem;
  border-bottom: 1px solid var(--border);
}

code {
  font-size: 0.85em;
  background: #f0ebe3;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.stack > * + * {
  margin-top: 0.75rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.check input {
  width: auto;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.card-head h2 {
  margin: 0;
}

.activity {
  border-top: 1px solid var(--border);
  padding: 0.75rem 0;
}

.activity:first-child {
  border-top: 0;
  padding-top: 0;
}

#settings-form .row,
#settings-form.stack > * + * {
  margin-top: 0.75rem;
}

#settings-form label {
  margin-top: 0.75rem;
}

#settings-form button#save {
  margin-top: 1rem;
}
