/* 2026-10-11 10:05 | y6y.io v2.00 | shared layout and components for every tool (theme-neutral: colours, lines and shapes come from theme.css tokens)
   Shell: header (brand with tool switcher, the tool's header items, the tool's controls, settings), the tool's main
   area, the settings page. Also auth screens, sheets, settings, admin, toasts. Tool layouts live in apps/<id>/public/css/. */

html, body { min-height: 100%; }
body { overscroll-behavior-y: none; }
[hidden] { display: none !important; }

/* ---------- shell and header ---------- */
.dz-shell { max-width: 1180px; margin: 0 auto; padding: 20px 28px 64px; padding-top: max(20px, env(safe-area-inset-top)); }
.dz-header { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.dz-brand { display: flex; align-items: center; gap: 10px; min-width: 0; margin-right: auto; }
.dz-brand__name {
  font-size: 22px; font-weight: 800; letter-spacing: -0.03em; line-height: 1;
  padding: 7px 10px; background: var(--ui-brand-bg); color: var(--ui-brand-ink); border: var(--ui-line-thick); border-radius: var(--ui-r-control); box-shadow: var(--ui-shadow-sm);
}
.dz-brand__sub { font-size: var(--ui-fs-label); font-weight: 800; padding: 3px 8px; background: var(--ui-tag-bg); color: var(--ui-tag-ink); border-radius: var(--ui-r-tag); }
.dz-header__controls { display: flex; align-items: center; gap: 12px; }
.dz-header__items { display: flex; align-items: center; gap: 12px; min-width: 0; }
/* the brand block doubles as the tool switcher once there is more than one tool */
button.dz-brand__switch { font-family: inherit; cursor: pointer; transition: transform 80ms ease, box-shadow 80ms ease; }
button.dz-brand__switch:active { transform: var(--ui-press); box-shadow: none; }
button.dz-brand__switch:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 3px; }
.dz-tools { display: flex; flex-direction: column; }
.dz-tool { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.dz-tool:hover { background: var(--ui-surface); }
.dz-tool.is-current { cursor: default; }
.dz-badge {
  position: absolute; top: -9px; right: -9px; min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--ui-active); border: var(--ui-line); border-radius: var(--ui-r-tag); color: var(--ui-badge-ink); text-shadow: none;
  font-size: 11px; font-weight: 800; line-height: 16px; text-align: center;
}

/* ---------- main area ---------- */
.dz-main { display: flex; flex-direction: column; gap: 22px; }

/* ---------- list rows (drop_zone items, admin users) ---------- */
.dz-item { cursor: pointer; position: relative; }
.dz-item:hover { background: var(--ui-surface); }
.dz-item:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
.dz-item__thumb {
  width: 40px; height: 40px; flex: none; overflow: hidden; border: var(--ui-line);
  background: var(--ui-thumb-bg); color: var(--ui-thumb-ink); border-radius: var(--ui-r-tag);
  display: flex; align-items: center; justify-content: center;
}
.dz-item__thumb--file { background: var(--ui-surface); color: var(--ui-ink); }
.dz-item__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dz-item__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.dz-item__text {
  font-weight: var(--ui-content-weight); white-space: pre-wrap; overflow-wrap: anywhere; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.4;
}
.dz-item__meta { display: flex; flex-wrap: wrap; gap: 5px; }
.dz-item__actions { display: flex; gap: 8px; flex: none; }
.dz-icon-btn { width: var(--ui-control-sm); min-height: var(--ui-control-sm); height: var(--ui-control-sm); padding: 0; }
.dz-item__check { width: 22px; height: 22px; flex: none; border: var(--ui-line); border-radius: var(--ui-r-tag); padding: 0; cursor: pointer; background: var(--ui-surface); }
.dz-item__check[aria-checked="true"] { background: var(--ui-active); }
.dz-item.is-selected { background: var(--ui-highlight-bg); color: var(--ui-highlight-ink); }
.dz-item .ui-progress { margin-top: 2px; }

/* ---------- auth ---------- */
.dz-auth { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.dz-auth__inner { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 24px; }
.dz-auth .dz-brand { justify-content: center; margin-right: 0; }
.dz-auth .dz-brand__name { font-size: 30px; }
.dz-form { display: flex; flex-direction: column; gap: 14px; }
.dz-form h1 { margin: 0 0 2px; }
.dz-form p { margin: 0; }
.dz-field-label { display: flex; flex-direction: column; gap: 6px; }
.dz-field-label > .ui-label { font-weight: 700; text-transform: var(--ui-chrome-case); }
/* interface labels follow the theme's case; descriptions and user content never do */
.dz-meter > .ui-label, .dz-switch-label, .dz-setting__text > span:first-child, .dz-facts dt, .dz-stat > .ui-meta { text-transform: var(--ui-chrome-case); }
.dz-form__links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.dz-linkbtn { background: none; border: 0; padding: 4px 0; cursor: pointer; font-size: var(--ui-fs-label); font-weight: 700; text-transform: var(--ui-chrome-case); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.dz-linkbtn:hover { background: var(--ui-highlight-bg); color: var(--ui-highlight-ink); }
.dz-error { color: var(--ui-danger-ink); background: var(--ui-danger-bg); border: var(--ui-line); border-color: var(--ui-danger-line); border-radius: var(--ui-r-control); padding: 6px 10px; font-size: var(--ui-fs-label); font-weight: 700; }
.dz-error:empty { display: none; }
.dz-pin { font-size: 26px; letter-spacing: 0.6em; text-align: center; padding-left: calc(12px + 0.6em); font-variant-numeric: tabular-nums; }
/* white behind the QR code in both themes so authenticator apps can scan it */
.dz-qr { display: flex; justify-content: center; padding: 12px; background: #FFFFFF; border: var(--ui-line); border-radius: var(--ui-r-control); align-self: center; }
.dz-qr img { width: 220px; height: 220px; image-rendering: pixelated; }
.dz-secret { word-break: break-all; font-size: var(--ui-fs-label); }
.dz-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; padding: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- sheets (modal panels) ---------- */
.dz-scrim {
  position: fixed; inset: 0; z-index: 50; background: var(--ui-scrim);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: dz-fade 120ms ease;
}
.dz-sheet {
  width: 100%; max-width: 640px; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); overflow: auto;
  display: flex; flex-direction: column; gap: 16px; padding: 20px; overscroll-behavior: contain;
  animation: dz-rise 140ms ease;
}
.dz-sheet--wide { max-width: 920px; }
.dz-sheet__content { display: flex; flex-direction: column; gap: 16px; }
.dz-sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dz-sheet__head .ui-title { overflow-wrap: anywhere; }
.dz-detail-text { white-space: pre-wrap; overflow-wrap: anywhere; padding: 14px; line-height: 1.55; max-height: 46vh; overflow: auto; user-select: text; }
.dz-detail-text textarea { min-height: 200px; }
.dz-preview { display: flex; justify-content: center; padding: 10px; }
.dz-preview img { max-width: 100%; max-height: 52vh; display: block; border: var(--ui-line); border-radius: var(--ui-r-control); }
.dz-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; margin: 0; }
.dz-facts dt { color: var(--ui-muted); font-size: var(--ui-fs-label); }
.dz-facts dd { margin: 0; overflow-wrap: anywhere; font-weight: 600; }
.dz-action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.dz-actions-row { display: flex; gap: 10px; flex-wrap: wrap; }
.dz-actions-row > .ui-btn { flex: 1 1 auto; }
.dz-inline-form { display: flex; gap: 10px; align-items: stretch; }
.dz-inline-form > .ui-field { flex: 1; min-width: 0; }

/* ---------- settings page (one scrolling page, groups stacked) ---------- */
.dz-page { display: flex; flex-direction: column; gap: 20px; }
.dz-page__head { display: flex; align-items: center; gap: 14px; }
.dz-settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 22px; align-items: start; }
.dz-settings__group { display: flex; flex-direction: column; gap: 16px; }
.dz-settings__group:has(.dz-stats) { grid-column: 1 / -1; }
.dz-settings__headrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dz-settings__heading { display: inline-block; align-self: flex-start; padding: var(--ui-heading-pad); background: var(--ui-heading-bg); border: var(--ui-heading-line); }
.dz-settings__body { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.dz-section { display: flex; flex-direction: column; gap: 10px; }
.dz-section h3 { margin: 0; font-size: 14px; font-weight: var(--ui-strong-weight); text-transform: var(--ui-chrome-case); }
.dz-section p { margin: 0; }
.dz-setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dz-setting__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dz-device { display: flex; align-items: center; gap: 12px; }
.dz-device__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

/* ---------- admin ---------- */
.dz-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.dz-stat { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.dz-stat__value { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dz-user { flex-direction: column; align-items: stretch; gap: 10px; }
.dz-user__head { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.dz-user__panel { display: flex; flex-direction: column; gap: 10px; }
.dz-user__tool { display: flex; flex-direction: column; gap: 10px; }
.dz-limits { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.dz-errors { max-height: 240px; overflow: auto; font-size: var(--ui-fs-meta); }
.dz-errors div { padding: 3px 0; overflow-wrap: anywhere; }

/* ---------- toasts ---------- */
.dz-toasts { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(560px, calc(100vw - 32px)); pointer-events: none; }
.dz-toast { display: flex; align-items: center; gap: 10px; padding: 8px 14px; max-width: 100%; pointer-events: auto; font-weight: 700; animation: dz-rise 140ms ease; }

/* ---------- splash ---------- */
.dz-splash { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; }

@keyframes dz-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dz-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- narrow desktop and tablet ---------- */
/* ---------- phone (Fold7 cover screen and folded) ---------- */
@media (max-width: 640px) {
  .dz-shell { padding: 14px 14px 40px; padding-top: max(14px, env(safe-area-inset-top)); }
  .dz-header { gap: 10px; margin-bottom: 16px; }
  .dz-brand__name { font-size: 18px; padding: 5px 8px; }
  .dz-header__controls { gap: 10px; }
  .dz-header__items { order: 3; flex: 1 1 100%; }
  .dz-item { gap: 10px; padding: 8px 10px; }
  .dz-item__actions .dz-icon-btn:not(.dz-keep) { display: none; }
  .dz-scrim { padding: 0; align-items: flex-end; }
  .dz-sheet { max-width: none; max-height: 92vh; max-height: 92dvh; padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); border-bottom: 0; box-shadow: none; border-radius: var(--ui-r-panel) var(--ui-r-panel) 0 0; }
  .dz-settings { gap: 18px; }
  .dz-settings__group { padding: 16px 14px; }
  .dz-limits { grid-template-columns: 1fr 1fr; }
  .dz-limits > .ui-btn { grid-column: 1 / -1; }
  .dz-action-grid { grid-template-columns: 1fr 1fr; }
  .dz-auth .dz-brand__name { font-size: 26px; }
  .ui-card.dz-auth-card { padding: 20px 16px; }
}
