/* QRme Suite — original productivity UI
   Palette: deep teal + warm parchment. Not Office blue, not Google Material. */

:root {
  --ink: #1a2b2a;
  --ink-soft: #3d5250;
  --muted: #6b7f7c;
  --line: #d5e0dd;
  --line-strong: #b8c9c5;
  --paper: #f7f4ef;
  --paper-raised: #fffcf7;
  --surface: #eef4f2;
  --teal: #0d5c56;
  --teal-deep: #084742;
  --teal-soft: #c4e8e2;
  --teal-mist: #e8f5f3;
  --accent: #c45c26;
  --accent-soft: #f5e6dc;
  --danger: #9b2c2c;
  --shadow: 0 1px 2px rgba(26, 43, 42, 0.06), 0 8px 24px rgba(26, 43, 42, 0.06);
  --shadow-lg: 0 4px 12px rgba(26, 43, 42, 0.08), 0 20px 48px rgba(26, 43, 42, 0.1);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Figtree", system-ui, -apple-system, sans-serif;
  --serif: "Literata", "Iowan Old Style", Georgia, serif;
  --topbar-h: 58px;
  --toolbar-h: 48px;
  --status-h: 28px;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--teal);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* Make the hidden attribute win over display:flex rules (.view, .toolbar, wraps). */
[hidden] { display: none !important; }

.view { min-height: 100dvh; display: flex; flex-direction: column; }

/* —— Top bar —— */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--topbar-h);
  padding: 0.5rem 1rem;
  background: var(--paper-raised);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-home { padding: 0.75rem 1.25rem; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-text strong {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-tag {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.topbar-left { flex: 1; }

.doc-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: 0.25rem;
}
.doc-title {
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  max-width: min(42vw, 320px);
  width: 100%;
  letter-spacing: -0.01em;
}
.doc-title:hover, .doc-title:focus {
  background: var(--surface);
  outline: none;
}
.doc-kind {
  font-size: 0.68rem;
  color: var(--muted);
  padding-left: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

.btn-primary {
  background: var(--teal);
  color: #fff;
}
.btn-primary:hover { background: var(--teal-deep); }

.btn-secondary {
  background: var(--teal-mist);
  color: var(--teal-deep);
  border-color: var(--teal-soft);
}
.btn-secondary:hover { background: var(--teal-soft); }

.btn-pdf {
  background: var(--paper-raised, #fffaf0);
  color: var(--teal-deep);
  border-color: var(--teal);
}
.btn-pdf:hover { background: var(--teal-mist); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}
.btn-ghost:hover { background: var(--surface); color: var(--ink); }

/* —— Home —— */
.hero {
  flex: 1;
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 2rem;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--teal-mist);
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0 0 0.85rem;
  font-size: clamp(1.75rem, 4.5vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--ink);
}

.lede {
  margin: 0 0 2rem;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 38rem;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.action-card {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  border-radius: var(--radius);
  padding: 1.25rem 1.2rem 1.35rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  font: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.action-card:hover {
  border-color: var(--teal-soft);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.action-card:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
.action-icon { color: var(--teal); margin-bottom: 0.25rem; }
.action-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.action-desc {
  font-size: 0.9rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.limits-note {
  background: var(--accent-soft);
  border: 1px solid #ebd5c4;
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
  color: var(--ink-soft);
  font-size: 0.875rem;
  line-height: 1.5;
}
.limits-note strong {
  display: block;
  color: var(--accent);
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.limits-note ul {
  margin: 0;
  padding-left: 1.15rem;
}
.limits-note li { margin: 0.25rem 0; }

.site-footer {
  padding: 1.25rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.site-footer .muted { color: var(--ink-soft); font-weight: 600; }

/* —— Toolbar —— */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  min-height: var(--toolbar-h);
  padding: 0.4rem 0.85rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: var(--topbar-h);
  z-index: 15;
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding-right: 0.65rem;
  border-right: 1px solid var(--line);
}
.toolbar-group:last-child { border-right: none; padding-right: 0; }
.toolbar-group.grow {
  flex: 1;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-width: 0;
}

.tb-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 0.45rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tb-btn:hover { background: var(--paper-raised); color: var(--ink); }
.tb-btn[aria-pressed="true"], .tb-btn.active {
  background: var(--teal-mist);
  color: var(--teal-deep);
}
.tb-btn i { font-style: italic; font-weight: 600; }
.tb-btn u { text-decoration: underline; font-weight: 700; }

.page-indicator {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  min-width: 3.5rem;
  text-align: center;
}

.pdf-note-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.pdf-note-input {
  flex: 1;
  min-width: 140px;
  max-width: 320px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  font: inherit;
  font-size: 0.85rem;
  background: var(--paper-raised);
  color: var(--ink);
}
.pdf-note-input:focus {
  outline: 2px solid var(--teal-soft);
  border-color: var(--teal);
}

/* —— Editor stage —— */
.editor-stage {
  flex: 1;
  overflow: auto;
  background:
    radial-gradient(ellipse at top, #e4ece9 0%, transparent 55%),
    var(--paper);
  padding: 1.25rem 1rem 2rem;
}

.doc-editor-wrap {
  width: min(760px, 100%);
  margin: 0 auto;
}

.doc-editor {
  min-height: calc(100dvh - var(--topbar-h) - var(--toolbar-h) - var(--status-h) - 4rem);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2.75rem;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink);
  outline: none;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.doc-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  font-family: var(--font);
  pointer-events: none;
}
.doc-editor h1 {
  font-family: var(--font);
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
  line-height: 1.25;
}
.doc-editor h2 {
  font-family: var(--font);
  font-size: 1.35rem;
  letter-spacing: -0.015em;
  margin: 1.25rem 0 0.5rem;
  line-height: 1.3;
}
.doc-editor p { margin: 0 0 0.85rem; }
.doc-editor ul, .doc-editor ol { margin: 0 0 0.85rem; padding-left: 1.4rem; }
.doc-editor li { margin: 0.2rem 0; }
.doc-editor a { color: var(--teal); }

/* —— PDF viewer —— */
.pdf-viewer-wrap {
  width: min(900px, 100%);
  margin: 0 auto;
}
.pdf-pages {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: center;
}
.pdf-page {
  position: relative;
  background: #fff;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  line-height: 0;
  cursor: crosshair;
}
.pdf-page canvas {
  display: block;
  max-width: 100%;
  height: auto;
}
.pdf-page.placing {
  outline: 2px dashed var(--teal);
  outline-offset: 3px;
}
.pdf-note-marker {
  position: absolute;
  transform: translate(-2px, -100%);
  background: #fff8e8;
  border: 1px solid #e0c48a;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.35;
  color: var(--ink);
  max-width: 200px;
  white-space: pre-wrap;
  word-break: break-word;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  z-index: 2;
}

/* —— Status / toast / dialog —— */
.status-bar {
  min-height: var(--status-h);
  padding: 0.25rem 1rem;
  background: var(--paper-raised);
  border-top: 1px solid var(--line);
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  align-items: center;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1.15rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  max-width: min(90vw, 420px);
  text-align: center;
}
.toast[hidden] { display: none; }

.dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  max-width: 380px;
  width: calc(100% - 2rem);
  box-shadow: var(--shadow-lg);
  background: var(--paper-raised);
  color: var(--ink);
}
.dialog::backdrop { background: rgba(26, 43, 42, 0.35); }
.dialog form { padding: 1.35rem 1.4rem 1.2rem; }
.dialog h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.dialog p {
  margin: 0 0 1.25rem;
  color: var(--ink-soft);
  font-size: 0.925rem;
  line-height: 1.45;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* —— Responsive —— */
@media (max-width: 640px) {
  .hero { padding: 1.5rem 1rem 1.5rem; }
  .btn-label { display: none; }
  .btn-label-long { display: none; }
  .btn { padding: 0.5rem 0.7rem; }
  .doc-title { max-width: 40vw; font-size: 0.88rem; }
  .doc-editor {
    padding: 1.35rem 1.15rem;
    font-size: 1rem;
    min-height: 60dvh;
  }
  .toolbar { gap: 0.35rem; }
  .toolbar-group { padding-right: 0.4rem; }
  .pdf-note-label { display: none; }
  .brand-tag { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
