/* ========================================
   ui.css — Jottit admin UI components
   ======================================== */

/* ── Dark mode ──────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #333840;
    --text: #ccc;
    --text-muted: #777;
    --text-bright: #eee;
    --divider: #222;
    --code-bg: #1a1a1a;
    --input-bg: #2a2e34;
    --card-bg: #3c4149;
  }
}

/* ── Main layout ────────────────────── */
main {
  max-width: var(--site-measure);
  margin: 0 auto;
  padding: var(--space-9) var(--space-5) var(--space-8);
  overflow-x: clip;
}

@media (min-width: 641px) {
  main {
    padding-top: var(--space-6);
  }
}

article {
  max-width: var(--site-measure);
  margin-left: auto;
  margin-right: auto;
}

/* ── Avatar settings ────────────────── */
.avatar-section {
  margin-bottom: var(--space-6);
}

.avatar-row {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
  margin: 0;
}

.avatar-placeholder {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  background: var(--input-bg);
  color: var(--divider);
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-placeholder svg {
  width: 100%;
  height: 100%;
}

.avatar-detail {
  min-width: 0;
}

.avatar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-2);
}

.avatar-actions a {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.avatar-remove {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: #c0392b;
}

.avatar-detail .text-muted {
  font-size: var(--text-sm);
  margin-bottom: 0;
}

/* ── Top nav ────────────────────────── */
.top-nav {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-muted);
}

.top-nav a,
.top-nav .link-button {
  color: #bbb;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.inline {
  display: inline;
}

/* ── Auth pages ─────────────────────── */
.page-centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-4) var(--space-4) var(--space-10);
  text-align: center;
}

.public-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body:has(.public-page) {
  background: var(--bg);
  color: var(--text);
}

.public-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4);
}

.public-header .top-nav-dark {
  position: static;
}

.public-header .top-nav-dark a {
  color: #999;
}

.public-header .top-nav-dark a:hover {
  color: #333;
}

.public-content {
  max-width: 640px;
  padding: var(--space-8) var(--space-4);
  margin: 0 auto;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.public-content h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: var(--space-4);
  text-align: center;
}

.public-content h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
}

.public-content .panel {
  padding: var(--space-8);
}

.public-content p {
  font-size: var(--text-lg);
  line-height: 1.7;
}

.home-footer {
  position: fixed;
  bottom: var(--space-6);
  left: 0;
  right: 0;
  text-align: center;
}

.home-footer a {
  color: #bbb;
  text-decoration: none;
}

.home-footer a:hover {
  color: #fff;
}

.home-footer-icon {
  width: 24px;
  height: 24px;
  fill: currentColor;
  display: block;
  margin: 0 auto;
}

.home-footer-nav {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
}

.home-footer-nav a {
  margin: 0 var(--space-2);
}

.public-page .home-footer {
  position: static;
  padding: var(--space-8) 0;
}

.logo {
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 0;
  background: linear-gradient(90deg, var(--brand-1), var(--brand-2), var(--brand-3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
}

.logo.logo-sm {
  font-size: 1.65rem;
  text-decoration: none;
}

.form-narrow {
  width: 100%;
  max-width: 340px;
  margin-bottom: var(--space-4);
}

.form-narrow .pill-input input {
  flex: 1;
}

.pill-input {
  display: flex;
  align-items: center;
  background: var(--input-bg);
  border: 1px solid var(--divider);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-4);
  font-family: var(--font-mono);
}

.pill-input-suffix {
  font-size: var(--text-base);
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  margin-right: var(--space-4);
}

.pill-input input {
  border: none;
  background: transparent;
  border-radius: 0;
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  min-width: 0;
  width: auto;
}

.pill-input-right input {
  text-align: right;
}

.pill-input input:focus {
  outline: none;
  border: none;
}

.pill-input input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset;
  -webkit-text-fill-color: var(--text-bright);
}

.pill-input button {
  border-radius: var(--radius-pill);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--bg);
  background: var(--text-bright);
  transition: opacity var(--speed-fast);
}

.pill-input button:hover {
  opacity: 0.8;
}

/* ── Passcode ───────────────────────── */
.passcode-inputs {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}

.passcode-inputs input {
  width: 3rem;
  height: 3.5rem;
  text-align: center;
  font-size: var(--text-2xl);
  font-family: var(--font-mono);
  background: var(--bg);
  border: 1px solid var(--text-muted);
  border-radius: var(--radius-md);
  padding: 0;
}

.passcode-inputs input:focus {
  outline: none;
  border-color: var(--text-bright);
}

/* ── Buttons ────────────────────────── */
.btn {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--bg);
  background: var(--text-bright);
  border: none;
  border-radius: var(--radius-pill);
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--speed-fast);
}

.btn:hover {
  opacity: 0.8;
}

.icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  vertical-align: -2px;
}

.btn--sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
}

.btn--outline {
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--text-muted);
}

.btn--outline:hover {
  color: var(--text-bright);
  border-color: var(--text-bright);
}

.btn--primary {
  background: color-mix(in srgb, var(--brand-1), var(--brand-2) 40%);
  color: #fff;
}

/* ── Panel ──────────────────────────── */
.panel {
  max-width: var(--measure);
  margin: 0 auto;
  background: var(--card-bg);
  color: var(--text);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.panel--narrow {
  max-width: var(--measure-narrow);
}

p.panel-notice {
  display: block;
  margin: calc(-1 * var(--space-6)) calc(-1 * var(--space-6)) var(--space-6);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  text-align: center;
}

@media (max-width: 640px) {
  .panel {
    background: none;
    border-radius: 0;
    padding: 0;
  }
}

.settings-form input[type="text"] {
  border-radius: var(--radius-pill);
}

.settings-form textarea {
  border-radius: 16px;
}

.panel-divider {
  border-top: 1px solid color-mix(in srgb, var(--divider), transparent 50%);
  margin-top: var(--space-8);
  padding-top: var(--space-8);
}

/* ── Domain settings ────────────────── */
.domain-verified {
  color: var(--success);
  font-weight: var(--weight-medium);
}

.domain-verified::before {
  content: "\2713 ";
}

.domain-status {
  font-size: var(--text-sm);
}

.domain-instructions {
  margin: var(--space-4) 0;
  font-size: var(--text-sm);
}

.domain-instructions pre {
  font-size: var(--text-xs);
  margin-bottom: var(--space-3);
}

.domain-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.domain-remove {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: #c0392b;
}

/* ── Export / danger zones ───────────── */
.export-zone {
  max-width: var(--measure-narrow);
  margin: var(--space-8) auto 0;
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  padding: var(--space-6);
}

.export-zone h3 {
  margin-bottom: var(--space-3);
}

.export-zone p {
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.danger-zone {
  max-width: var(--measure-narrow);
  margin: var(--space-8) auto 0;
  border: 1px solid #c0392b;
  border-radius: var(--radius-md);
  padding: var(--space-6);
}

.danger-zone h3 {
  color: #c0392b;
  margin-bottom: var(--space-3);
}

.danger-zone p {
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.btn--danger {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: #fff;
  background: #c0392b;
  border: none;
  border-radius: var(--radius-pill);
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--speed-fast);
}

.btn--danger:hover {
  opacity: 0.8;
  color: #fff;
}

.btn--danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Alerts ─────────────────────────── */
.error,
.success {
  font-size: var(--text-sm);
  display: inline-block;
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-pill);
}

.error {
  color: var(--error);
  background: color-mix(in srgb, var(--error), transparent 88%);
}

.success {
  color: color-mix(in srgb, var(--success), black 20%);
  background: color-mix(in srgb, var(--success), transparent 80%);
}

/* ── Editor ─────────────────────────── */
.editor-page {
  background: var(--bg);
  color: var(--text);
}

main.editor {
  max-width: var(--editor-measure);
  min-height: 100vh;
  position: relative;
}

@media (min-width: 641px) {
  main.editor {
    padding-inline: 0;
  }
}

.editor form {
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.editor-error {
  color: #c0392b;
  margin-bottom: var(--space-4);
}

.editor .editor-title {
  border: none;
  border-radius: 0;
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--text-bright);
  background: transparent;
  padding: 0;
  margin-bottom: var(--space-4);
}

.editor .editor-title::placeholder {
  color: var(--text);
  opacity: 0.5;
}

.editor .editor-body {
  flex: 1;
  min-height: 60vh;
  font-size: var(--text-lg);
  line-height: var(--leading-loose);
  color: var(--text);
  background: transparent;
}

.editor .editor-body .ProseMirror {
  outline: none;
  min-height: 60vh;
}

.editor-page .jot-bubble-menu {
  border-radius: 999px;
  padding: 6px 14px;
  gap: 6px;
}

.editor-page .jot-bubble-divider {
  margin: 0 4px;
}

.editor .editor-body.drag-over {
  border: 1px dashed var(--divider);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.editor-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--bg);
  padding: var(--space-4) max(var(--space-4), calc((100vw - var(--editor-measure)) / 2));
}

.editor-draft {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: 0;
}

input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--text-muted);
  border-radius: 3px;
  background: #fff;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

input[type="checkbox"]:checked {
  background: var(--text-muted);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2.5 6l2.5 2.5 4.5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.editor-send {
  position: fixed;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  padding: var(--space-4) max(var(--space-4), calc((100vw - var(--editor-measure)) / 2 + var(--space-4)));
}

.editor-sent {
  font-size: var(--text-sm);
  color: var(--text-muted);
  padding: var(--space-2) 0;
  display: inline-block;
}

.draft-label {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: var(--weight-medium);
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
  border: 1px solid color-mix(in srgb, var(--text-muted), transparent 60%);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3);
  margin-left: var(--space-3);
  background: #eee;
}

.back-link {
  margin-right: auto;
}

/* ── Admin menu ─────────────────────── */
.admin-menu {
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  right: var(--space-4);
  z-index: 100;
  max-width: var(--content-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-4);
  pointer-events: none;
}

@media (min-width: 641px) {
  .admin-menu {
    top: var(--space-6);
  }
}

.admin-menu > * {
  pointer-events: auto;
}

.admin-avatar,
.admin-initials {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.admin-avatar img {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  margin: 0;
}

.admin-avatar:hover,
.admin-initials:hover {
  box-shadow: 0 0 0 1px var(--bg), 0 0 0 2px var(--text-muted);
}

.admin-initials {
  background: var(--input-bg);
  border: 1px solid var(--divider);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-muted);
  user-select: none;
}

.admin-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--space-4);
  background: var(--card-bg);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.16);
  min-width: 160px;
  padding: var(--space-3) 0;
}

#admin-toggle:checked ~ .admin-dropdown {
  display: block;
}

.admin-dropdown a,
.admin-dropdown button {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-base);
  color: var(--text);
  text-decoration: none;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

.admin-dropdown-divider {
  border: none;
  border-top: 1px solid var(--divider);
  margin: var(--space-2) 0;
}

.admin-dropdown a:hover,
.admin-dropdown button:hover {
  background: var(--input-bg);
  color: var(--text-bright);
}

.admin-dropdown form button {
  padding-top: var(--space-2);
  padding-bottom: 0;
}

.admin-dropdown-email {
  display: block;
  padding: 0 var(--space-5) var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.top-nav .admin-menu {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  margin: 0;
  max-width: none;
  pointer-events: auto;
}

/* ── Settings extras ────────────────── */
.settings-form fieldset {
  border: none;
  padding: 0;
}

.settings-form fieldset legend {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-bright);
  margin-bottom: var(--space-2);
}

.social-links-editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
  margin-bottom: var(--space-3);
}

.social-link-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.social-link-row input[type="text"] {
  width: 140px;
  flex-shrink: 0;
}

.social-link-row input[type="url"] {
  flex: 1;
  min-width: 0;
}

.social-link-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-xl);
  color: var(--text-muted);
  padding: 0 var(--space-1);
  line-height: 1;
}

.social-link-remove:hover {
  color: var(--error);
}

.subscribers-table {
  width: 100%;
  margin-top: var(--space-6);
  font-size: var(--text-sm);
}

.subscribers-table th {
  text-align: left;
  font-weight: var(--weight-medium);
  color: var(--text-muted);
}

.subscribers-table thead tr {
  border-bottom: 1px solid color-mix(in srgb, var(--divider), transparent 80%);
}

.subscribers-table td,
.subscribers-table th {
  padding: var(--space-2) var(--space-3);
  border-bottom: none;
}

.subscribers-table td:last-child {
  text-align: right;
}

.link-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}

/* ── Write modal ────────────────────── */
.write-modal[hidden] {
  display: none;
}

.write-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.write-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  animation: write-modal-fade-in var(--speed-normal) ease;
}

.write-modal-content {
  position: relative;
  background: var(--card-bg);
  width: 90vw;
  max-width: var(--editor-measure);
  max-height: 90vh;
  border-radius: var(--radius-lg);
  overflow-y: auto;
  padding: var(--space-6);
  color: var(--text);
  animation: write-modal-slide-up var(--speed-normal) ease;
}

@keyframes write-modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes write-modal-slide-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  .write-modal-overlay {
    display: none;
  }

  .write-modal-content {
    width: 100%;
    max-width: none;
    max-height: none;
    height: 100%;
    border-radius: 0;
    background: var(--bg);
  }

  .write-modal-expand {
    display: none;
  }
}

.write-modal-expand {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  color: var(--text-muted);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  line-height: 1;
}

.write-modal-expand:hover {
  color: var(--text-bright);
}

.write-modal-expand svg {
  display: block;
}

.write-modal-content .editor-title {
  border: none;
  border-radius: 0;
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--text-bright);
  background: transparent;
  padding: 0;
  margin-bottom: var(--space-4);
}

.write-modal-content .editor-title::placeholder {
  color: var(--text);
  opacity: 0.5;
}

.write-modal-content .editor-body {
  min-height: 40vh;
  font-size: var(--text-lg);
  line-height: var(--leading-loose);
  color: var(--text);
  background: transparent;
}

.write-modal-content .editor-body .ProseMirror {
  outline: none;
  min-height: 40vh;
}

.write-modal-content .editor-body.drag-over {
  border: 1px dashed var(--divider);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.write-modal-content .btn--outline {
  color: var(--text-muted);
  border-color: var(--text-muted);
}

.write-modal-content .btn--outline:hover {
  color: var(--text-bright);
  border-color: var(--text-bright);
}

.write-modal-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-top: var(--space-4);
  margin-top: var(--space-4);
}

.write-modal-error {
  color: var(--error);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.write-modal-content .ProseMirror[data-placeholder].ProseMirror-empty::before {
  content: attr(data-placeholder);
  color: var(--text);
  opacity: 0.5;
  pointer-events: none;
  position: absolute;
}

/* ── Blogroll editor ────────────────── */
.blogroll-editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
  margin-bottom: var(--space-3);
}

.blogroll-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.blogroll-row input[type="text"] {
  width: 140px;
  flex-shrink: 0;
}

.blogroll-row input[type="url"] {
  flex: 1;
  min-width: 0;
}

.blogroll-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-xl);
  color: var(--text-muted);
  padding: 0 var(--space-1);
  line-height: 1;
}

.blogroll-remove:hover {
  color: var(--error);
}

/* ── Subscribe pages ────────────────── */
.subscribe-page {
  background: #333840;
  color: #ccc;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}

.subscribe-identity {
  text-align: center;
  margin-bottom: var(--space-6);
}

.subscribe-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  object-fit: cover;
  margin: 0 auto var(--space-3);
}

.subscribe-name {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
}

.subscribe-card {
  background: #3c4149;
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.subscribe-page .subscribe-card h1 {
  font-family: var(--font-sans);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: #eee;
  margin-bottom: var(--space-4);
}

.subscribe-page .subscribe-card p {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: #aaa;
  margin-bottom: 0;
}

.subscribe-btn {
  margin-top: var(--space-6);
}

.subscribe-unsub {
  display: block;
  margin-top: var(--space-6);
  font-size: var(--text-sm);
  color: #777;
  text-decoration: none;
}

.subscribe-unsub:hover {
  color: #aaa;
}
