/* Premium paper editor, seven skins, and the one placement modal.
   Tokens stay in nqn.css. No web fonts. */

.nq-editor {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.nq-editor-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
}

.nq-editor-title {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 2.5rem;
  font-weight: 950;
  letter-spacing: -0.03em;
  line-height: 1.08;
}

.nq-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.nq-editor-download,
.nq-editor-save,
.nq-editor-search,
.nq-editor-notify-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 999px;
  padding: 0.65rem 1.2rem;
  font: inherit;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
}

.nq-editor-download,
.nq-editor-search {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.nq-editor-save,
.nq-editor-notify-btn {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
}

.nq-editor-download svg,
.nq-editor-save svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: currentColor;
}

.nq-editor-download:hover,
.nq-editor-download:focus-visible,
.nq-editor-search:hover,
.nq-editor-search:focus-visible {
  color: var(--ink);
}

.nq-editor-save:hover,
.nq-editor-save:focus-visible,
.nq-editor-notify-btn:hover,
.nq-editor-notify-btn:focus-visible {
  color: #fff;
}

.nq-editor-notify-btn:disabled,
.nq-editor-search:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.nq-editor-settings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.nq-editor-skins {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 0.85rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 8px 22px rgba(17, 24, 39, 0.04);
}

.nq-skin {
  width: 64px;
  height: 64px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  cursor: pointer;
  font: inherit;
}

.nq-skin-swatch {
  display: block;
  flex: 1 1 auto;
  min-height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.nq-skin-name {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-align: center;
}

.nq-skin[aria-pressed="true"] {
  outline: 3px solid #5A9A7A;
  outline-offset: 0;
}

.nq-skin[data-skin="classic"] .nq-skin-swatch {
  background: #fff;
  border-bottom: 3px solid #111827;
}

.nq-skin[data-skin="fun-colourful"] .nq-skin-swatch {
  background: linear-gradient(135deg, #5A9A7A, #E8785C 45%, #5B4B9A);
}

.nq-skin[data-skin="1940s"] .nq-skin-swatch {
  background: #f3efe4;
  border: 2px solid #111;
}

.nq-skin[data-skin="plain"] .nq-skin-swatch {
  background: #fff;
  border: 1px solid #111;
}

.nq-skin[data-skin="modern"] .nq-skin-swatch {
  background: #F6F7FB;
  box-shadow: inset 0 -3px 0 #5A9A7A;
}

.nq-skin[data-skin="elegant-serif"] .nq-skin-swatch {
  background: #fbf9f6;
  border-bottom: 1px solid rgba(17, 24, 39, 0.35);
}

.nq-skin[data-skin="bold-tabloid"] .nq-skin-swatch {
  background: #111827;
}

.nq-editor .nq-viewpill button[aria-pressed="false"],
.nq-place .nq-viewpill button[aria-pressed="false"] {
  background: #fff;
  color: #51705A;
}

.nq-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem);
  gap: 1rem;
  align-items: start;
}

.nq-sheet-wrap {
  width: min(100%, 210mm);
  overflow: auto;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}

.nq-sheet-stage {
  transform-origin: top left;
  width: 210mm;
}

.nq-sheet-frame {
  display: flex;
  flex-direction: column;
  width: 210mm;
  height: 297mm;
  max-width: none;
  aspect-ratio: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  box-sizing: border-box;
}

.nq-sheet-frame[hidden] {
  display: none !important;
}

.nq-sheet-mast {
  flex: 0 0 22mm;
  margin: 0;
  padding: 2mm 3mm;
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.15;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nq-sheet-foot {
  flex: 0 0 12mm;
  margin: 0;
  padding: 0 3mm;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.nq-sheet {
  --cols: 4;
  --rows: 24;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 10mm));
  background-color: transparent;
  background-image:
    linear-gradient(to right, rgba(90, 154, 122, 0.18) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(90, 154, 122, 0.18) 1px, transparent 1px);
  background-size: calc(100% / var(--cols)) 10mm;
  background-position: -1px -1px;
}

.nq-cell {
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  min-width: 0;
  min-height: 0;
  cursor: pointer;
  grid-column: calc(var(--x) + 1);
  grid-row: calc(var(--y) + 1);
  z-index: 1;
}

.nq-tile {
  position: relative;
  z-index: 2;
  grid-column: calc(var(--x) + 1) / span var(--w);
  grid-row: calc(var(--y) + 1) / span var(--h);
  margin: 1px;
  padding: 0.28rem 0.35rem 1.4rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  text-align: left;
  cursor: grab;
}

.nq-tile h3 {
  margin: 0;
  padding-right: 3.4rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.nq-tile p,
.nq-tile-author,
.nq-tile-kind,
.nq-tile-body,
.nq-tile-more {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.2;
}

.nq-tile-author {
  color: var(--ink);
  font-weight: 700;
}

.nq-tile-body {
  color: var(--ink);
  overflow: hidden;
}

.nq-tile-more {
  font-weight: 800;
  color: #5A9A7A;
}

.nq-tile .nq-qr,
.nq-tile svg.nq-qr,
.nq-tile > svg {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 28px;
  height: 28px;
  background: #fff;
}

.nq-sheet .nq-tile[data-item-type="meme"],
.nq-place-sheet .nq-tile[data-item-type="meme"] {
  background: #EEF6F1;
}

.nq-tile-clear,
.nq-tile-resize {
  position: absolute;
  z-index: 3;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.nq-tile-clear {
  top: 2px;
  right: 2px;
  min-width: 42px;
  min-height: 28px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
}

.nq-tile-resize {
  left: 0;
  bottom: 0;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: nesw-resize;
}

.nq-tile-resize::after {
  content: "";
  position: absolute;
  left: 8px;
  bottom: 8px;
  width: 10px;
  height: 10px;
  border-left: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
}

.nq-tile.is-selected,
.nq-cell.is-selected {
  outline: 2px solid #5A9A7A;
  outline-offset: -2px;
  z-index: 4;
}

.nq-sheet .nq-tile[data-item-type="ad"],
.nq-place-sheet .nq-tile[data-item-type="ad"] {
  background: #FDEEE9;
}

.nq-editor-side {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 8px 22px rgba(17, 24, 39, 0.04);
  padding: 1rem;
}

.nq-editor-side h2 {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.nq-editor-included {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0 0 1rem;
}

.nq-editor-included .nq-latest-item {
  margin: 0;
}

.nq-item-remove {
  margin-top: 0.35rem;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.nq-editor-fossick {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nq-fossick-results {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.nq-fossick-hit {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  padding: 0.7rem 0.75rem;
  font: inherit;
  cursor: pointer;
}

.nq-fossick-hit strong {
  display: block;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.nq-editor-notify p {
  margin: 0.75rem 0 0;
}

.nq-place-card {
  width: min(calc(90vh * 210 / 297 + 2.5rem), calc(100vw - 1rem));
  max-width: calc(100vw - 1rem);
  max-height: calc(100vh - 1rem);
  overflow-x: hidden;
  overflow-y: auto;
}

.nq-place-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.nq-place-papers {
  margin: 0 0 0.75rem;
}

.nq-place .nq-sheet-frame {
  height: 90vh;
  width: calc(90vh * 210 / 297);
  max-width: 100%;
  aspect-ratio: auto;
}

.nq-place-sheet {
  cursor: pointer;
}

.nq-place-status {
  margin: 0.75rem 0 0;
  color: var(--muted);
}

.nq-sheet-frame[data-skin="classic"] {
  background: #fff;
}

.nq-sheet[data-skin="classic"] .nq-tile h3 {
  font-weight: 800;
}

.nq-sheet-frame[data-skin="fun-colourful"] {
  background: #fff;
}

.nq-sheet[data-skin="fun-colourful"] .nq-tile[data-item-type="article"],
.nq-sheet[data-skin="fun-colourful"] .nq-tile[data-item-type="joke"] {
  border-top: 4px solid #5A9A7A;
}

.nq-sheet[data-skin="fun-colourful"] .nq-tile:nth-child(4n + 1) {
  border-top-color: #1F3A5F;
}

.nq-sheet[data-skin="fun-colourful"] .nq-tile:nth-child(4n + 2) {
  border-top-color: #B04E18;
}

.nq-sheet[data-skin="fun-colourful"] .nq-tile:nth-child(4n + 3) {
  border-top-color: #5B4B9A;
}

.nq-sheet-frame[data-skin="1940s"],
.nq-sheet-frame[data-skin="1940s"] .nq-sheet-mast,
.nq-sheet[data-skin="1940s"] .nq-tile {
  font-family: Georgia, "Times New Roman", Times, serif;
}

.nq-sheet-frame[data-skin="1940s"] {
  background: #f3efe4;
  border: 2px solid #111;
}

.nq-sheet[data-skin="1940s"] {
  background-image:
    linear-gradient(to right, rgba(17, 24, 39, 0.16) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(17, 24, 39, 0.16) 1px, transparent 1px);
}

.nq-sheet[data-skin="1940s"] .nq-tile {
  border: 1px solid #111;
  background: rgba(243, 239, 228, 0.92);
  border-radius: 0;
}

.nq-sheet[data-skin="1940s"] .nq-tile h3 {
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nq-sheet-frame[data-skin="plain"] {
  background: #fff;
  color: #111;
}

.nq-sheet[data-skin="plain"] {
  background-image:
    linear-gradient(to right, rgba(17, 24, 39, 0.2) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(17, 24, 39, 0.2) 1px, transparent 1px);
}

.nq-sheet[data-skin="plain"] .nq-tile[data-item-type="article"],
.nq-sheet[data-skin="plain"] .nq-tile[data-item-type="joke"] {
  background: #fff;
  color: #111;
  border-color: #111;
  border-radius: 0;
}

.nq-sheet[data-skin="plain"] .nq-tile p {
  color: #111;
}

.nq-sheet-frame[data-skin="modern"] {
  background: #fff;
  border-radius: 12px;
}

.nq-sheet[data-skin="modern"] .nq-tile {
  background: #F6F7FB;
  border-color: transparent;
  border-radius: 10px;
}

.nq-sheet[data-skin="modern"] .nq-tile h3 {
  font-weight: 700;
  letter-spacing: -0.03em;
}

.nq-sheet-frame[data-skin="elegant-serif"],
.nq-sheet-frame[data-skin="elegant-serif"] .nq-sheet-mast,
.nq-sheet[data-skin="elegant-serif"] .nq-tile {
  font-family: Georgia, "Times New Roman", Times, serif;
}

.nq-sheet-frame[data-skin="elegant-serif"] {
  background: #fbf9f6;
}

.nq-sheet[data-skin="elegant-serif"] .nq-tile {
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(17, 24, 39, 0.15);
  border-radius: 0;
}

.nq-sheet[data-skin="elegant-serif"] .nq-tile h3 {
  font-weight: 600;
  letter-spacing: 0;
}

.nq-sheet-frame[data-skin="bold-tabloid"] {
  background: #fff;
  border: 2px solid #111827;
}

.nq-sheet[data-skin="bold-tabloid"] .nq-tile {
  border: 0;
  border-top: 4px solid #111827;
  border-radius: 0;
  background: #fff;
}

.nq-sheet[data-skin="bold-tabloid"] .nq-tile h3 {
  font-weight: 950;
  font-size: 0.92rem;
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

@media (max-width: 800px) {
  .nq-editor-head,
  .nq-editor-settings,
  .nq-editor-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .nq-editor-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .nq-editor-title {
    font-size: 1.8rem;
  }

  .nq-editor-actions {
    justify-content: flex-start;
  }

  .nq-place .nq-sheet-frame {
    width: 100%;
    height: auto;
    aspect-ratio: 210 / 297;
  }
}

.nq-place .nq-viewpill button[aria-pressed="false"] {
  background: #fff !important;
  color: #51705A !important;
  border-color: #51705A !important;
}

.nq-place-card button.nq-cell,
.nq-place-card button.nq-tile {
  align-self: stretch !important;
  justify-self: stretch !important;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--ink) !important;
  font-weight: 700 !important;
  line-height: 1.15 !important;
  box-shadow: none !important;
}

.nq-place-card button.nq-tile {
  margin: 1px !important;
  padding: 0.28rem 0.35rem 1.4rem !important;
  border: 1px solid var(--line) !important;
  border-radius: 4px !important;
  background: rgba(255, 255, 255, 0.92) !important;
  text-align: left !important;
  cursor: pointer;
  overflow: hidden;
}

.nq-place-card button.nq-tile[data-item-type="ad"] {
  background: #FDEEE9 !important;
}

.nq-place-card button.nq-cell:hover,
.nq-place-card button.nq-tile:hover,
.nq-place-card button.nq-cell:focus-visible,
.nq-place-card button.nq-tile:focus-visible {
  background: transparent;
  color: var(--ink);
}

.nq-place-card button.nq-tile:hover,
.nq-place-card button.nq-tile:focus-visible {
  background: rgba(255, 255, 255, 0.92) !important;
  color: var(--ink) !important;
}

.nq-place-card button.nq-tile[data-item-type="ad"]:hover,
.nq-place-card button.nq-tile[data-item-type="ad"]:focus-visible {
  background: #FDEEE9 !important;
}

@media (prefers-reduced-motion: reduce) {
  .nq-tile,
  .nq-skin,
  .nq-editor-download,
  .nq-editor-save {
    transition: none;
  }
}

/* Masthead / Past Papers / reader (Phase 3) */
.nq-editor-settings-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  align-items: center;
}

.nq-check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.nq-check input {
  width: 1.1rem;
  height: 1.1rem;
}

.nq-viewpill a.nq-viewpill-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0.45rem 1.1rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 800;
  color: #51705A;
  background: #fff;
  border: 0;
}

.nq-viewpill a.nq-viewpill-link[aria-pressed="true"] {
  background: #5A9A7A;
  color: #fff;
}

.nq-mast-head {
  align-items: center;
}

.nq-mast-logo {
  width: 4.5rem;
  height: 4.5rem;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.nq-mast-subscribe {
  margin: 0 0 1rem;
}

.nq-pp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.85rem;
}

.nq-pp-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}

.nq-pp-main {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr) 3.25rem;
  gap: 0.55rem;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.nq-pp-logo {
  width: 2.75rem;
  height: 2.75rem;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.nq-pp-logo-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #EEF6F1;
  color: #5A9A7A;
  font-weight: 900;
}

.nq-pp-title {
  display: block;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.nq-pp-date {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.nq-pp-qr svg {
  width: 3rem;
  height: 3rem;
  display: block;
  background: #fff;
}

.nq-pp-actions {
  display: flex;
  gap: 0.45rem;
  justify-content: flex-end;
}

.nq-reader-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-start;
}

.nq-reader-side-label {
  margin: 0 0 0.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.nq-reader-frame {
  pointer-events: none;
}

.nq-edition-qr {
  margin: 0 0 0.75rem;
}

.nq-edition-qr svg {
  width: 72px;
  height: 72px;
  background: #fff;
}

@media (max-width: 900px) {
  .nq-editor-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .nq-editor-settings {
    grid-template-columns: 1fr;
  }

  .nq-sheet-wrap {
    width: 100%;
  }
}
