h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  letter-spacing: -0.04em;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.icon-button,
.back-button,
.rail-category,
.page-item,
.page-insert,
.notes-drawer button {
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid var(--line-strong);
  font-size: 1.55rem;
}

.category-card {
  display: flex;
  min-height: 150px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
}

.category-card strong {
  font-size: 1.25rem;
}

.category-card span,
.empty-state {
  color: var(--muted);
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 36px;
  text-align: center;
}

.back-button,
.rail-category,
.page-item {
  width: 100%;
  padding: 10px 12px;
  text-align: left;
}

.back-button {
  margin-bottom: 18px;
}

.rail-category--active,
.page-item--active {
  background: var(--accent);
  color: var(--accent-ink);
}

.page-insert {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 22px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.page-insert::before {
  position: absolute;
  right: 8px;
  left: 8px;
  height: 1px;
  background: var(--line);
  content: "";
}

.page-insert span {
  z-index: 1;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
}

.page-title {
  min-width: 0;
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 1.1rem;
  font-weight: 700;
}

.notes-drawer header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: max(7px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 7px max(14px, env(safe-area-inset-left));
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px);
}

.brand-button,
.topbar-actions button,
.admin-actions button,
.user-actions button,
.primary-button,
.offline-account,
.page-delete {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  cursor: pointer;
}

.brand-button {
  border: 0;
  font-weight: 800;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.topbar-actions button,
.admin-actions button,
.user-actions button,
.primary-button {
  padding: 8px 12px;
}

.sync-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.sync-pill[data-sync-status="conflict"],
.sync-pill[data-sync-status="failed"] {
  border-color: #bd3434;
  color: #bd3434;
}

.theme-control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.8rem;
}

.theme-control select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.app-view .workspace {
  min-height: calc(100dvh - 58px);
}

.app-view .category-rail,
.app-view .page-rail,
.app-view .editor-pane {
  min-height: calc(100dvh - 58px);
}

.login-shell,
.admin-shell {
  min-height: 100dvh;
  padding: max(32px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.login-shell {
  display: grid;
  place-items: center;
}

.login-card {
  width: min(480px, 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(24px, 5vw, 44px);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-intro,
.offline-account span,
.user-row span {
  color: var(--muted);
}

.login-card form,
.login-card label {
  display: grid;
  gap: 7px;
}

.login-card form {
  gap: 16px;
  margin-top: 28px;
}

.login-card input {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 12px;
  background: var(--surface);
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.form-error {
  border-left: 4px solid #bd3434;
  padding-left: 12px;
  color: #bd3434;
}

.form-message {
  border-left: 4px solid var(--accent);
  padding-left: 12px;
}

.onboarding-section {
  display: grid;
  gap: 10px;
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.onboarding-section details {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}

.onboarding-section summary {
  font-weight: 700;
  cursor: pointer;
}

.onboarding-section form {
  margin-top: 16px;
}

.offline-section {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.offline-section h2 {
  font-size: 1rem;
}

.offline-account {
  display: flex;
  width: 100%;
  min-height: 64px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 9px 13px;
  text-align: left;
}

.admin-shell {
  width: min(1000px, 100%);
  min-height: auto;
  margin: 0 auto;
}

.admin-header,
.user-row,
.user-actions,
.admin-actions {
  display: flex;
  align-items: center;
}

.admin-header,
.user-row {
  justify-content: space-between;
  gap: 18px;
}

.admin-actions,
.user-actions {
  gap: 8px;
}

.user-row {
  border-bottom: 1px solid var(--line);
  padding: 15px 0;
}

.user-row > div:first-child {
  display: grid;
  gap: 4px;
}

.page-row {
  display: flex;
  align-items: stretch;
  gap: 3px;
}

.page-row .page-item {
  min-width: 0;
  flex: 1;
}

.page-delete {
  border-color: transparent;
  color: var(--muted);
}

.toast {
  position: fixed;
  z-index: 100;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 16px;
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow);
}

.toast button {
  border: 1px solid currentColor;
  border-radius: 8px;
  background: transparent;
  color: inherit;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
}

.offline-retry {
  display: inline-flex;
  min-height: var(--target);
  align-items: center;
  padding: 8px 14px;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .app-topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    max-width: 72vw;
    overflow-x: auto;
  }

  .theme-control {
    display: none;
  }
}
