/* DePage admin — minimal, neutral, accessible */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: #1f2937; background: #f9fafb; }
a { color: #2563eb; text-decoration: none; } a:hover { text-decoration: underline; }
button { cursor: pointer; font: inherit; }
.link { background: none; border: 0; color: #2563eb; padding: 0; }
.muted { color: #6b7280; font-size: 0.9rem; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1.25rem; background: #fff; border-bottom: 1px solid #e5e7eb; flex-wrap: wrap; gap: 0.5rem; }
.brand { font-weight: 700; font-size: 1.1rem; }
nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
nav a { color: #374151; font-weight: 500; padding: 0.25rem 0.4rem; }
nav a.active { color: #2563eb; }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

/* Responsive — phones (< 640px) and tablets (< 900px).
   Aim: every tap target ≥ 44px on phones (iOS HIG), no horizontal scroll. */
@media (max-width: 640px) {
  main { padding: 1rem 0.75rem; }
  .topbar { padding: 0.6rem 0.75rem; }
  nav { width: 100%; justify-content: flex-start; }
  nav a, nav button { padding: 0.6rem 0.8rem; min-height: 44px; display: inline-flex; align-items: center; }
  .view-head { flex-wrap: wrap; }
  .view-head h1 { font-size: 1.2rem; flex-basis: 100%; }
  .grid, .media-grid { grid-template-columns: 1fr; }
  .editor-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .editor-tabs .etab { white-space: nowrap; padding: 0.7rem 0.9rem; min-height: 44px; }
  .block .bhead button, .block-add button, .card .actions button,
  .timeline .actions button, .comments-mod .actions button {
    min-height: 38px; padding: 0.4rem 0.7rem; font-size: 0.85rem;
  }
  .block-add { gap: 0.35rem; }
  .block-add button { flex: 1 1 calc(50% - 0.35rem); }
  aside iframe { height: 360px; }
  dialog { min-width: auto; width: calc(100vw - 2rem); }
  .login { margin: 2vh auto; padding: 1.25rem; }
}
.view-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.view-head h1 { margin: 0; font-size: 1.4rem; flex: 1; }
.spacer { flex: 1; }

.primary { background: #2563eb; color: #fff; border: 0; border-radius: 6px; padding: 0.55rem 1rem; font-weight: 600; }
.primary:hover { background: #1d4ed8; }
button:not(.primary):not(.link) { border: 1px solid #d1d5db; background: #fff; padding: 0.4rem 0.8rem; border-radius: 5px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 1rem; }
.card h3 { margin: 0 0 0.5rem; }
.card .meta { font-size: 0.85rem; color: #6b7280; margin-bottom: 0.75rem; }
.card .actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.card .cid { font-family: ui-monospace, monospace; font-size: 0.7rem; color: #9ca3af; word-break: break-all; }

/* Login */
.login { max-width: 420px; margin: 5vh auto; background: #fff; padding: 2rem; border-radius: 12px; border: 1px solid #e5e7eb; text-align: center; }
.qr-box { display: flex; align-items: center; justify-content: center; min-height: 220px; }
.qr-box img, .qr-box canvas { max-width: 220px; height: auto; }
.spinner { width: 28px; height: 28px; border: 3px solid #e5e7eb; border-top-color: #2563eb; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status { color: #6b7280; min-height: 1.2em; }
.login details { margin-top: 1rem; text-align: left; }
.login input[type=text], .login input[type=password] { width: 100%; padding: 0.5rem; border: 1px solid #d1d5db; border-radius: 5px; }
.login .tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.login .tab { flex: 1; padding: 0.5rem; background: #f3f4f6; border: 0; border-radius: 5px; font-weight: 600; color: #6b7280; }
.login .tab.active { background: #2563eb; color: #fff; }
.login .form { text-align: left; }
.login .form label { display: block; margin: 0.5rem 0 0.25rem; font-weight: 500; }
.login .form button[type=submit] { width: 100%; margin-top: 1rem; padding: 0.6rem; }
.login .sep { margin: 1.5rem 0; border: 0; border-top: 1px solid #e5e7eb; }

/* Editor */
.editor-tabs { display: flex; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid #e5e7eb; }
.editor-tabs .etab { background: none; border: 0; padding: 0.5rem 1rem; color: #6b7280; font-weight: 500; border-bottom: 2px solid transparent; border-radius: 0; }
.editor-tabs .etab.active { color: #2563eb; border-bottom-color: #2563eb; }
.editor-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1.5rem; }
@media (max-width: 900px) { .editor-grid { grid-template-columns: 1fr; } }
aside iframe { width: 100%; height: 520px; border: 1px solid #e5e7eb; border-radius: 6px; background: #fff; }

.title-input { width: 100%; padding: 0.5rem 0.6rem; font-size: 1.1rem; border: 1px solid #d1d5db; border-radius: 5px; margin-bottom: 1rem; }

/* Block list */
.block { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: 0.75rem; margin-bottom: 0.6rem; }
.block .bhead { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.5rem; font-size: 0.85rem; color: #6b7280; }
.block .bhead .btype { font-weight: 600; color: #1f2937; }
.block .bhead .bactions { margin-left: auto; display: flex; gap: 0.2rem; }
.block .bhead button { font-size: 0.75rem; padding: 0.15rem 0.4rem; }
.block textarea, .block input[type=text], .block input[type=url], .block select { width: 100%; padding: 0.4rem; border: 1px solid #d1d5db; border-radius: 4px; font: inherit; font-family: ui-monospace, monospace; font-size: 0.92rem; }
.block textarea { min-height: 90px; resize: vertical; }
.block .row { display: flex; gap: 0.5rem; align-items: center; }
.block .row label { font-size: 0.85rem; color: #6b7280; }
.block.image .preview { margin-top: 0.5rem; }
.block.image .preview img { max-width: 240px; max-height: 160px; border: 1px solid #e5e7eb; border-radius: 4px; }
.block-add { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.block-add button { font-size: 0.85rem; }

/* Versions timeline */
.timeline { list-style: none; padding: 0; }
.timeline li { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: 0.75rem; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.75rem; }
.timeline .ver { font-weight: 700; color: #2563eb; font-size: 1.2rem; }
.timeline .info { flex: 1; font-size: 0.9rem; }
.timeline .info .cid { font-family: ui-monospace, monospace; font-size: 0.75rem; color: #9ca3af; word-break: break-all; }
.timeline .actions { display: flex; gap: 0.3rem; }
.timeline li.current { border-color: #2563eb; background: #eff6ff; }

/* Media */
.dropzone { display: block; padding: 1.5rem; background: #f9fafb; border: 2px dashed #d1d5db; border-radius: 8px; text-align: center; cursor: pointer; margin: 0.5rem 0 1rem; }
.dropzone.drag { background: #e0e7ff; border-color: #2563eb; }
.dropzone input { display: none; }
.callout { background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 0.75rem 1rem; margin-bottom: 1rem; color: #78350f; font-size: 0.9rem; line-height: 1.5; }
.callout code { background: #fef3c7; padding: 0.1em 0.3em; border-radius: 3px; font-family: ui-monospace, monospace; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; list-style: none; padding: 0; }
.media-grid li { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: 0.5rem; }
.media-grid li .thumb { background: #f3f4f6; aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center; border-radius: 4px; margin-bottom: 0.4rem; overflow: hidden; }
.media-grid li .thumb img { max-width: 100%; max-height: 100%; }
.media-grid li .thumb .kind { color: #6b7280; font-weight: 600; }
.media-grid li .name { font-size: 0.8rem; word-break: break-all; }
.media-grid li .cid { font-family: ui-monospace, monospace; font-size: 0.7rem; color: #6b7280; cursor: pointer; word-break: break-all; }
.media-grid li button { font-size: 0.75rem; }

/* Comments mod */
.comments-mod { list-style: none; padding: 0; }
.comments-mod li { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: 0.75rem; margin-bottom: 0.5rem; }
.comments-mod .author { font-weight: 600; }
.comments-mod .meta { color: #6b7280; font-size: 0.8rem; }
.comments-mod .actions { margin-top: 0.5rem; display: flex; gap: 0.4rem; }
.comments-mod .actions button.approve { border-color: #86efac; color: #166534; background: #f0fdf4; }
.comments-mod .actions button.spam { border-color: #fca5a5; color: #991b1b; background: #fef2f2; }

/* Form bits */
.form label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 500; font-size: 0.92rem; }
.form input, .form textarea, .form select { width: 100%; padding: 0.45rem 0.55rem; border: 1px solid #d1d5db; border-radius: 5px; font: inherit; }
.form textarea { min-height: 80px; resize: vertical; }
.inline { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.inline input { flex: 1; min-width: 160px; padding: 0.4rem; border: 1px solid #d1d5db; border-radius: 5px; }

dl.account dt { font-weight: 600; margin-top: 0.75rem; }
dl.account dd { margin-left: 0; color: #374151; word-break: break-all; font-family: ui-monospace, monospace; font-size: 0.9rem; }

.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 99px; font-size: 0.75rem; font-weight: 600; background: #f3f4f6; color: #4b5563; }
.badge.draft { background: #fef3c7; color: #92400e; }
.badge.published { background: #d1fae5; color: #065f46; }

/* `<dialog>` natively, with a `<div>` overlay polyfill for Safari < 15.4 */
dialog { border: 0; border-radius: 10px; padding: 1.5rem; min-width: 320px; }
dialog::backdrop { background: rgba(0,0,0,0.45); }
.dp-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: none; align-items: center; justify-content: center; z-index: 1000; }
.dp-overlay.open { display: flex; }
.dp-overlay .panel { background: #fff; border-radius: 10px; padding: 1.5rem; min-width: 320px; max-width: 90vw; max-height: 90vh; overflow: auto; }
