:root {
  --bg: #0e0a06;
  --ink: #ffb443;
  --ink-highlight: #fde68a;
  --ink-muted: #b37a2b;
  --ink-dim: #7c521c;
  --island: #171009;
  --island-hover: #21160c;
  --drawer: #120c07;
  --item-bg: #1b1209;
  --border: #a16207;
  --border-dashed: #713f12;
  --border-subtle: rgba(161, 98, 7, 0.3);
  --danger: #fb7185;
  --danger-bg: rgba(251, 113, 133, 0.12);
  --danger-border: rgba(251, 113, 133, 0.5);
  --ok: #86efac;
  --glow-text: 0 0 8px rgba(255, 180, 67, 0.22);
  --glow-island: 0 0 24px rgba(245, 158, 11, 0.18), 0 12px 32px rgba(0, 0, 0, 0.6);
  --radius: 4px;
  --radius-sm: 3px;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --topbar-h: 48px;
  /* Set by app.js from visualViewport: distance between the layout-viewport bottom and the
     visible bottom (on-screen keyboard), and how far the visible area has scrolled down. */
  --kb-inset: 0px;
  --vv-top: 0px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(255, 180, 67, 0.03) 0px,
      rgba(255, 180, 67, 0.03) 1px,
      transparent 1px,
      transparent 3px
    ),
    radial-gradient(
      ellipse 70% 42% at 50% 100%,
      rgba(245, 158, 11, 0.14),
      transparent 70%
    );
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.55;
  text-shadow: var(--glow-text);
  -webkit-font-smoothing: antialiased;
  color-scheme: dark;
}

body {
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

::selection {
  background: rgba(255, 180, 67, 0.28);
  color: var(--ink-highlight);
}

a {
  color: var(--ink);
  text-decoration: none;
}

a:hover {
  color: var(--ink-highlight);
}

button, input, select, textarea {
  font-family: var(--font-mono);
  color: var(--ink);
}

/* Custom amber scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: #713f12 #0e0a06;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: #0e0a06;
}

*::-webkit-scrollbar-thumb {
  background: #4e2b0d;
  border-radius: 2px;
}

*::-webkit-scrollbar-thumb:hover {
  background: #a16207;
}

.hidden {
  display: none !important;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  padding: 0 clamp(14px, 3vw, 28px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transform: translateY(var(--vv-top));
  background: rgba(14, 10, 6, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-highlight);
  white-space: nowrap;
  flex-shrink: 0;
}

.brand:hover {
  color: #fff3c4;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 8px rgba(255, 180, 67, 0.85), 0 0 16px rgba(245, 158, 11, 0.55);
  display: inline-block;
  flex-shrink: 0;
  animation: amberPulse 2.8s ease-in-out infinite;
}

@keyframes amberPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.92); }
}

.topbar-slug {
  flex: 0 1 auto;
  min-width: 6ch;
  color: var(--ink);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.telemetry {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.telemetry-sep {
  color: var(--ink-dim);
  user-select: none;
}

.telemetry-item.over-limit,
.telemetry-danger {
  color: var(--danger);
  text-shadow: 0 0 8px rgba(251, 113, 133, 0.3);
}

/* Home Canvas */
.canvas-main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--topbar-h));
}

.canvas-form {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

.canvas-editor {
  flex: 1 0 auto;
  width: 100%;
  min-height: calc(100dvh - var(--topbar-h));
  padding: 28px clamp(18px, 5vw, 56px) 190px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--ink);
  caret-color: var(--ink-highlight);
  font-size: 14.5px;
  line-height: 1.65;
  tab-size: 2;
  text-shadow: var(--glow-text);
}

.canvas-editor::placeholder {
  text-shadow: none;
}

/* All placeholders use muted ink (≈5:1 on the dark surfaces, WCAG AA). */
input::placeholder,
textarea::placeholder {
  color: var(--ink-muted);
  opacity: 1;
}

/* Floating Bottom Stack (Toasts + Popovers + Dynamic Island) */
.floating-stack {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom) + var(--kb-inset));
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100vw - 24px);
  pointer-events: none;
}

.floating-stack > * {
  pointer-events: auto;
}

/* Dynamic Island & Action Island */
.island {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: var(--island);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--glow-island);
  max-width: 100%;
  flex-wrap: wrap;
}

.island-group {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.island-sep {
  width: 1px;
  height: 20px;
  background: rgba(161, 98, 7, 0.45);
  flex-shrink: 0;
}

.island-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-shadow: var(--glow-text);
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.island-btn:hover,
.island-btn[aria-expanded="true"] {
  background: var(--island-hover);
  border-color: var(--border-dashed);
  color: var(--ink-highlight);
}

.island-btn:focus-visible,
.btn:focus-visible,
.peek-tab:focus-visible,
.preset-btn:focus-visible,
.brand:focus-visible,
.toast-close:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--ink-highlight);
  outline-offset: 2px;
}

.caret {
  color: var(--ink-muted);
  font-size: 11px;
}

/* Slug Inline Input */
.slug-wrap {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 8px;
  background: rgba(14, 10, 6, 0.7);
  border: 1px solid var(--border-dashed);
  border-radius: var(--radius-sm);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.slug-wrap:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px rgba(255, 180, 67, 0.3);
}

.slug-prefix {
  color: var(--ink-muted);
  font-size: 12.5px;
  user-select: none;
  cursor: text;
}

.slug-input {
  width: 118px;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink-highlight);
  font-size: 12.5px;
  padding: 0 4px 0 2px;
}

.slug-status {
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  padding-left: 4px;
}

.slug-status:empty {
  display: none;
}

.slug-status.ok {
  color: var(--ok);
  text-shadow: 0 0 8px rgba(134, 239, 172, 0.35);
}

.slug-status.err {
  color: var(--danger);
  text-shadow: 0 0 8px rgba(251, 113, 133, 0.35);
}

.slug-status.checking {
  color: var(--ink-muted);
}

/* Password Lock Toggle & Inline Reveal */
.lock-wrap[data-locked="true"] #lock-toggle {
  background: rgba(255, 180, 67, 0.12);
  border-color: var(--border);
  color: var(--ink-highlight);
}

.lock-input-slot {
  position: relative;
  min-width: 0;
  height: 32px;
}

.lock-hint,
.lock-password-input {
  position: absolute;
  inset: 0;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}

.lock-hint {
  display: flex;
  align-items: center;
  padding: 0 8px;
  color: var(--ink-muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: none;
  pointer-events: none;
}

.lock-password-input {
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  pointer-events: none;
}

.lock-wrap[data-locked="true"] .lock-hint {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
}

.lock-wrap[data-locked="true"] .lock-password-input {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0s;
}

.lock-password-input {
  width: 100%;
  height: 32px;
  padding: 0 8px;
  background: rgba(14, 10, 6, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-highlight);
  font-size: 12.5px;
  outline: none;
}

.lock-password-input:focus {
  border-color: var(--ink-highlight);
  box-shadow: 0 0 0 1px rgba(253, 230, 138, 0.3);
}

/* Command Island layout: fixed width, three stable rows so nothing shifts when the
   password field appears.
   Row 1: expiry + slug · Row 2: lock toggle + password slot · Row 3: SAVE & SHARE */
.command-island {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "expiry slug"
    "lock lock"
    "drop drop";
  align-items: center;
  gap: 8px;
  width: min(460px, calc(100vw - 24px));
  padding: 8px;
}

.command-island > .island-sep {
  display: none;
}

.command-island .expiry-wrap {
  grid-area: expiry;
}

.command-island .slug-wrap {
  grid-area: slug;
  min-width: 0;
}

.command-island .slug-input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.command-island .lock-wrap {
  grid-area: lock;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

.command-island #lock-toggle {
  width: 118px;
  justify-content: flex-start;
}

.command-island .btn-drop {
  grid-area: drop;
  width: 100%;
  height: 36px;
  justify-content: center;
}

/* Expiry Popover */
.popover {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  width: 264px;
  padding: 12px;
  background: var(--island);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--glow-island);
  z-index: 50;
}

.popover-title,
.popover-subtitle {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  margin-bottom: 8px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.preset-btn {
  height: 30px;
  padding: 0 6px;
  background: var(--item-bg);
  border: 1px dashed var(--border-dashed);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.preset-btn:hover {
  border-style: solid;
  border-color: var(--border);
  color: var(--ink-highlight);
}

.preset-btn.is-active {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: var(--bg);
  text-shadow: none;
  font-weight: 700;
}

.preset-wide {
  grid-column: span 4;
}

.popover-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 10px 0;
}

.custom-expiry-row {
  display: grid;
  grid-template-columns: 68px 1fr auto;
  gap: 6px;
  align-items: center;
}

.custom-expiry-row input,
.custom-expiry-row select {
  height: 30px;
  padding: 0 6px;
  background: var(--bg);
  border: 1px solid var(--border-dashed);
  border-radius: var(--radius-sm);
  color: var(--ink-highlight);
  font-size: 12px;
  outline: none;
}

.custom-expiry-row input:focus,
.custom-expiry-row select:focus {
  border-color: var(--ink);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  background: var(--item-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  text-shadow: var(--glow-text);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover {
  background: var(--island-hover);
  border-color: var(--ink);
  color: var(--ink-highlight);
}

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

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
  font-weight: 700;
  text-shadow: none;
  box-shadow: 0 0 14px rgba(255, 180, 67, 0.28);
}

.btn-primary:hover {
  background: var(--ink-highlight);
  border-color: var(--ink-highlight);
  color: var(--bg);
  box-shadow: 0 0 18px rgba(253, 230, 138, 0.42);
}

.btn-drop {
  padding: 0 15px;
  letter-spacing: 0.06em;
}

.btn-danger {
  background: transparent;
  border-color: var(--danger-border);
  color: var(--danger);
  text-shadow: none;
}

.btn-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: #fda4af;
}

.btn-danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #160609;
  font-weight: 700;
  text-shadow: none;
}

.btn-danger-solid:hover {
  background: #fda4af;
  border-color: #fda4af;
  color: #160609;
}

.btn-xs {
  height: 26px;
  padding: 0 8px;
  font-size: 11px;
}

.popover-error {
  margin-top: 8px;
  color: var(--danger);
  font-size: 11.5px;
  line-height: 1.4;
  text-shadow: none;
}

.drawer:focus {
  outline: none;
}

.paste-expired .topbar [data-expires-at] {
  color: var(--danger);
  text-shadow: none;
}

/* Floating Toasts */
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--island);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--glow-island);
  font-size: 12.5px;
  max-width: min(640px, calc(100vw - 24px));
  flex-wrap: wrap;
}

.toast-error {
  border-color: var(--danger);
  background: #1d0c10;
  color: var(--danger);
  text-shadow: none;
  box-shadow: 0 0 20px rgba(251, 113, 133, 0.22), 0 10px 26px rgba(0, 0, 0, 0.55);
}

.toast-close {
  background: transparent;
  border: 0;
  color: var(--ink-muted);
  font-size: 17px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
}

.toast-close:hover {
  color: var(--ink-highlight);
}

.toast-error .toast-close {
  color: var(--danger);
}

/* Right-Edge Magnetic Peek Tab */
.peek-tab {
  position: fixed;
  right: 0;
  /* --tab-top is set by app.js (visible-viewport centre, clamped above the island). */
  top: var(--tab-top, 50%);
  transform: translateY(-50%);
  z-index: 45;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  padding: 14px 8px;
  background: var(--island);
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  box-shadow: -4px 0 20px rgba(245, 158, 11, 0.16);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, opacity 0.18s ease;
}

.peek-tab:hover {
  transform: translateY(-50%) translateX(-4px);
  background: var(--island-hover);
  color: var(--ink-highlight);
  box-shadow: -6px 0 24px rgba(245, 158, 11, 0.28);
}

.drawer-instant .drawer,
.drawer-instant .drawer-backdrop,
.drawer-instant .peek-tab {
  transition: none !important;
}

body.drawer-open .peek-tab {
  opacity: 0;
  pointer-events: none;
}

/* Drawer Backdrop & Slide-Out Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(14, 10, 6, 0.68);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.drawer {
  position: fixed;
  top: var(--vv-top);
  right: 0;
  bottom: var(--kb-inset);
  z-index: 60;
  width: min(410px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--drawer);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 36px rgba(0, 0, 0, 0.72), -2px 0 24px rgba(245, 158, 11, 0.14);
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  visibility: hidden;
}

.drawer.is-open {
  transform: translateX(0);
  visibility: visible;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-highlight);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 2px;
  background: var(--item-bg);
  border: 1px solid var(--border-dashed);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.drawer-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.drawer-filter-bar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-filter-input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  background: var(--bg);
  border: 1px solid var(--border-dashed);
  border-radius: var(--radius-sm);
  color: var(--ink-highlight);
  font-size: 12.5px;
  outline: none;
}

.drawer-filter-input:focus {
  border-color: var(--ink);
}

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 16px 24px;
}

.paste-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.paste-item {
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: var(--item-bg);
  border: 1px dashed var(--border-dashed);
  border-radius: var(--radius-sm);
  transition: border-color 0.14s ease, background 0.14s ease;
}

.paste-item:hover {
  border-color: var(--border);
  background: #22160b;
}

.paste-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.paste-slug-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex-wrap: wrap;
}

.paste-slug {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-highlight);
  word-break: break-all;
}

.paste-slug:hover,
.paste-item:hover .paste-slug {
  text-decoration: underline;
}

/* Whole card navigates: the slug link's overlay covers the card; buttons sit above it. */
.paste-slug::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
}

.paste-slug:focus-visible {
  outline: none;
}

.paste-item:has(.paste-slug:focus-visible) {
  outline: 2px solid var(--ink-highlight);
  outline-offset: 2px;
}

.paste-item button {
  position: relative;
  z-index: 1;
}

.badge-locked {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(255, 180, 67, 0.12);
  color: var(--ink-highlight);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.paste-preview {
  font-size: 12px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 16px;
  text-shadow: none;
}

.paste-preview:empty {
  display: none;
}

.paste-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--ink-muted);
  text-shadow: none;
}

.meta-sep {
  color: var(--ink-dim);
}

.empty-state {
  padding: 28px 14px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 12.5px;
  border: 1px dashed var(--border-dashed);
  border-radius: var(--radius-sm);
  background: rgba(27, 18, 9, 0.5);
}

/* Paste Viewer (/:slug) & Vault / 404 Pages */
.viewer-main {
  /* body is a 100dvh flex column, so this fills whatever the (1- or 2-row) header leaves. */
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

/* Viewer header: title | meta | actions on one row; when there is no room the
   actions wrap to a second row of the same sticky header, aligned right. The header
   stays in normal flow (sticky), so content always starts below its real height. */
.topbar.viewer-topbar {
  /* Two classes so the later phone-size .topbar padding rule can't drop the
     vertical padding. */
  height: auto;
  min-height: var(--topbar-h);
  flex-wrap: wrap;
  column-gap: 14px;
  row-gap: 8px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.viewer-topbar .topbar-left {
  /* Content-sized: a long slug keeps its room and pushes meta/actions to row 2;
     only once it is alone on its row does it shrink and truncate. */
  flex: 1 1 auto;
}

.header-actions {
  flex: 0 0 auto;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.delete-anchor {
  position: relative;
  display: inline-flex;
}

/* Delete confirmation drops down from the DELETE button. */
.header-actions .delete-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 35;
  width: min(420px, calc(100vw - 24px));
}

.header-actions .delete-popover-title {
  overflow-wrap: anywhere;
}

.viewer-wrap {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

.paste-viewer {
  flex: 1 0 auto;
  margin: 0;
  /* No bottom island on the viewer any more, so only a normal bottom margin. */
  padding: 28px clamp(18px, 5vw, 56px) 48px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  tab-size: 2;
}

.vault-stage {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
}

.vault-card {
  width: min(460px, 100%);
  padding: 24px 22px;
  background: var(--island);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--glow-island);
  text-align: center;
}

.vault-badge {
  display: inline-block;
  padding: 3px 9px;
  margin-bottom: 12px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: rgba(255, 180, 67, 0.1);
  color: var(--ink-highlight);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.vault-badge-danger {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
  text-shadow: none;
}

.vault-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-highlight);
}

.vault-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: 12px;
}

.vault-slug {
  color: var(--ink);
  font-weight: 600;
}

.vault-desc {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--ink-muted);
}

.vault-form {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
}

.vault-form input {
  flex: 1 1 200px;
  height: 36px;
  padding: 0 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-highlight);
  font-size: 13.5px;
  outline: none;
}

.vault-form input:focus {
  border-color: var(--ink-highlight);
  box-shadow: 0 0 0 1px rgba(253, 230, 138, 0.3);
}

.vault-form .btn {
  height: 36px;
}

.inline-error {
  padding: 8px 10px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 12.5px;
  text-align: left;
  text-shadow: none;
}

/* Delete confirmation panel */
.delete-popover {
  width: min(480px, calc(100vw - 24px));
  padding: 14px 16px;
  background: #1a0c0e;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  box-shadow: 0 0 24px rgba(251, 113, 133, 0.22), 0 12px 30px rgba(0, 0, 0, 0.65);
}

.delete-popover-title {
  margin: 0 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--danger);
  text-shadow: none;
}

.delete-popover-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.delete-popover-row input {
  flex: 1 1 190px;
  height: 32px;
  padding: 0 10px;
  background: var(--bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  color: var(--ink-highlight);
  font-size: 12.5px;
  outline: none;
}

.delete-popover-row input:focus {
  border-color: var(--danger);
}

/* Mobile Responsive Adjustments */
@media (max-width: 720px) {
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }

  .telemetry {
    font-size: 11px;
    gap: 5px;
  }

  /* Viewer top bar on phones: icon-only lock badge so the slug keeps its room. */
  .page-viewer .topbar .badge-text {
    display: none;
  }

  /* Viewer top bar on phones: keep the slug readable by dropping the "created" stamp. */
  .page-viewer .telemetry [data-created-at],
  .page-viewer .telemetry [data-created-at] + .telemetry-sep {
    display: none;
  }

  .canvas-editor,
  .paste-viewer {
    padding: 20px 14px 200px;
  }

  .floating-stack {
    bottom: calc(12px + var(--safe-bottom) + var(--kb-inset));
    width: calc(100vw - 20px);
  }

  .command-island {
    width: 100%;
    gap: 6px;
  }

  /* Phones: title + meta share row 1; the actions take a full-width row 2. */
  .viewer-topbar .topbar-left {
    flex-basis: 0;
  }

  .header-actions {
    flex: 1 1 100%;
    margin-left: 0;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .header-actions > .btn,
  .header-actions > .delete-anchor {
    flex: 1 1 auto;
  }

  .header-actions > .btn,
  .delete-anchor > .btn {
    width: 100%;
    padding: 0 8px;
  }

  .page-viewer .paste-viewer {
    padding-bottom: 32px;
  }

  .island-sep {
    display: none;
  }

  .slug-wrap {
    flex: 1 1 130px;
    min-width: 0;
  }

  .slug-input {
    width: 100%;
    min-width: 56px;
  }


  .popover {
    left: 0;
    right: auto;
    width: min(270px, calc(100vw - 36px));
  }

  .peek-tab {
    padding: 10px 6px;
    font-size: 10.5px;
  }

  .peek-tab:hover {
    transform: translateY(-50%) translateX(-3px);
  }
}

/* Touch / small screens: iOS Safari zooms into any focused field under 16px,
   so every form control is at least 16px here. */
@media (max-width: 768px), (pointer: coarse) {
  textarea,
  input,
  select,
  .canvas-editor,
  .slug-input,
  .lock-password-input,
  .custom-expiry-row input,
  .custom-expiry-row select,
  .drawer-filter-input,
  .vault-form input,
  .delete-popover-row input {
    font-size: 16px !important;
  }

  .canvas-editor {
    line-height: 1.55;
  }

  .slug-prefix {
    font-size: 14px;
  }

  .custom-expiry-row input,
  .custom-expiry-row select {
    height: 34px;
  }

  .vault-form input,
  .delete-popover-row input {
    height: 36px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
