:root {
  --ink: #12131a;
  --ink-soft: #5b5f6e;
  --line: #e6e2d8;
  --cream: #faf9f6;
  --paper: #fffdf7;
  --gold: #c9a227;
  --gold-soft: #f3e7c0;
  --radius: 16px;
  --pad-radius: 20px;
}

/* Five luxury paper themes */
[data-theme="gold"] {
  --pad-bg: linear-gradient(160deg, #1f2027 0%, #0d0e12 100%);
  --pad-border: rgba(212, 175, 55, 0.4);
  --pad-shadow: 0 24px 60px rgba(15, 16, 22, 0.45), 0 0 1px rgba(212, 175, 55, 0.5);
  --sheet-bg: #fffdf7;
  --sheet-line: #efe6d2;
  --sheet-text: #12131a;
  --sheet-muted: #8b8f9c;
  --accent: #c9a227;
  --accent-soft: #f3e7c0;
  --coil-a: #f5d67a;
  --coil-b: #9d7f1e;
  --highlight-bg: #fef08a;
  --btn-cover-bg: rgba(255, 255, 255, 0.1);
  --btn-cover-hover: rgba(255, 255, 255, 0.2);
  --btn-cover-color: #f3e7c0;
}

[data-theme="leather"] {
  --pad-bg: linear-gradient(160deg, #54331a 0%, #2e1a0c 100%);
  --pad-border: rgba(200, 150, 102, 0.4);
  --pad-shadow: 0 24px 60px rgba(46, 26, 12, 0.55), 0 0 1px rgba(200, 150, 102, 0.4);
  --sheet-bg: #faf3e6;
  --sheet-line: #e8dbc9;
  --sheet-text: #2c1a0e;
  --sheet-muted: #9c8a7b;
  --accent: #a05a2c;
  --accent-soft: #faebd7;
  --coil-a: #dca774;
  --coil-b: #7c481e;
  --highlight-bg: #fed7aa;
  --btn-cover-bg: rgba(255, 255, 255, 0.12);
  --btn-cover-hover: rgba(255, 255, 255, 0.22);
  --btn-cover-color: #fce7d2;
}

[data-theme="emerald"] {
  --pad-bg: linear-gradient(160deg, #0d3826 0%, #061c13 100%);
  --pad-border: rgba(52, 211, 153, 0.4);
  --pad-shadow: 0 24px 60px rgba(6, 28, 19, 0.55), 0 0 1px rgba(52, 211, 153, 0.4);
  --sheet-bg: #f4f9f6;
  --sheet-line: #d2e4db;
  --sheet-text: #09261b;
  --sheet-muted: #749487;
  --accent: #0f764e;
  --accent-soft: #d1fae5;
  --coil-a: #f6d87e;
  --coil-b: #9e7f22;
  --highlight-bg: #a7f3d0;
  --btn-cover-bg: rgba(255, 255, 255, 0.12);
  --btn-cover-hover: rgba(255, 255, 255, 0.22);
  --btn-cover-color: #d1fae5;
}

[data-theme="mica"] {
  --pad-bg: linear-gradient(145deg, rgba(230, 238, 248, 0.9) 0%, rgba(200, 214, 232, 0.85) 100%);
  --pad-border: rgba(255, 255, 255, 0.85);
  --pad-shadow: 0 24px 60px rgba(90, 115, 145, 0.25), 0 0 1px rgba(255, 255, 255, 0.9);
  --sheet-bg: rgba(255, 255, 255, 0.94);
  --sheet-line: rgba(205, 218, 235, 0.8);
  --sheet-text: #171c26;
  --sheet-muted: #7b889b;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --coil-a: #ffffff;
  --coil-b: #8b99ad;
  --highlight-bg: #bfdbfe;
  --btn-cover-bg: rgba(255, 255, 255, 0.6);
  --btn-cover-hover: rgba(255, 255, 255, 0.85);
  --btn-cover-color: #171c26;
}

[data-theme="canary"] {
  --pad-bg: linear-gradient(160deg, #b47a05 0%, #3a2003 100%);
  --pad-border: rgba(253, 224, 71, 0.45);
  --pad-shadow: 0 24px 60px rgba(45, 24, 3, 0.5), 0 0 1px rgba(253, 224, 71, 0.4);
  --sheet-bg: #fefce8;
  --sheet-line: #fde68a;
  --sheet-text: #211905;
  --sheet-muted: #8c7d5c;
  --accent: #ca8a04;
  --accent-soft: #fef9c3;
  --coil-a: #fef08a;
  --coil-b: #854d0e;
  --highlight-bg: #fef08a;
  --btn-cover-bg: rgba(255, 255, 255, 0.15);
  --btn-cover-hover: rgba(255, 255, 255, 0.25);
  --btn-cover-color: #fef9c3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 22px;
}

a {
  color: inherit;
}

button {
  font-family: inherit;
}

/* Nav */
.nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 0;
}

.nav .logo {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav .sp {
  margin-left: auto;
}

.nav a.back {
  font-size: 14px;
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

.nav a.back:hover {
  color: var(--ink);
}

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 44px;
  align-items: start;
  padding: 36px 0 60px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7a6417;
  background: var(--gold-soft);
  border-radius: 999px;
  padding: 6px 13px;
  margin-bottom: 18px;
}

.badge-installed {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #047857;
  background: #d1fae5;
  border-radius: 999px;
  padding: 7px 14px;
}

h1 {
  font-size: clamp(34px, 5vw, 50px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
  font-weight: 700;
}

.sub {
  font-size: 18px;
  color: var(--ink-soft);
  margin: 0 0 26px;
  max-width: 48ch;
  line-height: 1.55;
}

.cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  padding: 13px 20px;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.btn-p {
  background: var(--ink);
  color: #fff;
}

.btn-p:hover {
  background: #000;
  transform: translateY(-1px);
}

.btn-s {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.btn-s:hover {
  border-color: #c9c3b4;
  background: #fdfcf9;
}

.note {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 14px;
}

.feature-notice {
  font-size: 13px;
  color: #854d0e;
  background: #fef9c3;
  border-left: 3px solid #eab308;
  padding: 8px 12px;
  border-radius: 6px;
  margin: 10px 0 0;
  max-width: 44ch;
}

/* Notebook Host & Placeholder */
#notebook-host {
  min-height: 480px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.pip-placeholder {
  width: 100%;
  max-width: 380px;
  min-height: 420px;
  background: #fff;
  border: 2px dashed var(--line);
  border-radius: var(--pad-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 24px;
}

.pip-placeholder .pip-icon {
  font-size: 40px;
  margin-bottom: 14px;
}

.pip-placeholder h3 {
  margin: 0 0 8px;
  font-size: 20px;
}

.pip-placeholder p {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 22px;
  max-width: 30ch;
}

/* The FlipNote Pad Widget */
.flipnote-pad {
  width: 100%;
  max-width: 380px;
  background: var(--pad-bg);
  border: 1px solid var(--pad-border);
  box-shadow: var(--pad-shadow);
  border-radius: var(--pad-radius);
  padding: 24px 20px 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.3s ease, transform 0.2s ease;
  perspective: 1600px;
}

/* Spiral Coils */
.coils {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: -36px 0 14px;
  pointer-events: none;
}

.coil {
  width: 10px;
  height: 24px;
  border-radius: 5px;
  background: linear-gradient(180deg, var(--coil-a), var(--coil-b));
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

/* Pad Top Header */
.pad-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}

.pad-title-btn {
  background: transparent;
  border: none;
  color: var(--btn-cover-color);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  text-align: left;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease;
}

.pad-title-btn:hover {
  background: var(--btn-cover-bg);
}

.pad-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.cover-btn {
  background: var(--btn-cover-bg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--btn-cover-color);
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s ease, transform 0.1s ease;
}

.cover-btn:hover {
  background: var(--btn-cover-hover);
}

.cover-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

/* Pad Toolbar */
.pad-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.tool-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.tool-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--btn-cover-color);
  font-size: 13px;
  font-weight: 700;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s ease;
}

.tool-btn:hover {
  background: var(--btn-cover-bg);
}

.tool-btn:focus-visible {
  outline: 2px solid #fff;
}

.tool-select {
  background: var(--btn-cover-bg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--btn-cover-color);
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer;
}

.tool-select option {
  background: #1a1b20;
  color: #fff;
}

/* Theme quick picker dots in pad */
.theme-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}

.theme-dot-btn {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 0;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.theme-dot-btn:hover {
  transform: scale(1.2);
  border-color: #fff;
}

.theme-dot-btn:focus-visible {
  outline: 2px solid #fff;
}

/* Ruled Paper Sheet */
.paper-sheet-container {
  perspective: 1400px;
  min-height: 280px;
  position: relative;
}

.paper-sheet {
  background: var(--sheet-bg);
  color: var(--sheet-text);
  border-radius: 12px;
  padding: 16px 16px 14px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08), 0 10px 24px rgba(0, 0, 0, 0.18);
  min-height: 280px;
  display: flex;
  flex-direction: column;
  position: relative;
  transform-style: preserve-3d;
  transform-origin: left center;
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.32s ease;
}

/* Page Header on Sheet */
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  border-bottom: 2px solid var(--sheet-line);
  padding-bottom: 6px;
}

.page-title-input {
  font-size: 15px;
  font-weight: 700;
  color: var(--sheet-text);
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-family: inherit;
  letter-spacing: -0.01em;
}

.page-title-input:focus {
  background: rgba(0, 0, 0, 0.03);
  border-radius: 4px;
}

/* Ruled Note Lines */
.rule-list {
  list-style: none;
  padding: 0;
  margin: 0;
  flex-grow: 1;
}

.rule-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--sheet-line);
  padding: 6px 0;
  min-height: 34px;
  transition: background 0.12s ease;
}

.rule-check {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  color: var(--sheet-text);
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 4px;
}

.rule-check:hover {
  background: rgba(0, 0, 0, 0.05);
}

.rule-check:focus-visible {
  outline: 2px solid var(--sheet-text);
}

.rule-text {
  flex-grow: 1;
  font-size: 14px;
  line-height: 1.45;
  color: var(--sheet-text);
  outline: none;
  min-height: 20px;
  word-break: break-word;
  white-space: pre-wrap;
}

.rule-text:focus {
  background: rgba(0, 0, 0, 0.02);
  border-radius: 3px;
}

.rule-row.done .rule-text {
  color: var(--sheet-muted);
  text-decoration: line-through;
}

.rule-row.done .rule-check {
  color: var(--sheet-muted);
}

.rule-del {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--sheet-muted);
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

.rule-row:hover .rule-del,
.rule-row:focus-within .rule-del {
  opacity: 1;
}

.rule-del:hover {
  color: #dc2626;
  background: rgba(220, 38, 38, 0.08);
}

.rule-del:focus-visible {
  opacity: 1;
  outline: 2px solid var(--sheet-text);
}

/* Highlight style */
mark.fn-highlight {
  background-color: var(--highlight-bg);
  color: inherit;
  padding: 1px 3px;
  border-radius: 2px;
}

/* Add Item row */
.add-rule-btn {
  background: transparent;
  border: none;
  color: var(--sheet-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
  transition: color 0.15s ease;
}

.add-rule-btn:hover {
  color: var(--sheet-text);
}

.add-rule-btn:focus-visible {
  outline: 2px solid var(--sheet-text);
  border-radius: 4px;
}

/* Pad Foot / Navigation */
.pad-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--btn-cover-color);
}

.page-nav-btn {
  background: var(--btn-cover-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--btn-cover-color);
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.page-nav-btn:hover:not(:disabled) {
  background: var(--btn-cover-hover);
}

.page-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-nav-btn:focus-visible {
  outline: 2px solid #fff;
}

.page-indicator {
  font-weight: 600;
  padding: 0 4px;
  user-select: none;
}

.timer-pill {
  margin-left: auto;
  background: rgba(0, 0, 0, 0.35);
  color: #fef08a;
  border: 1px solid rgba(254, 240, 138, 0.3);
  border-radius: 999px;
  padding: 3px 9px;
  font-weight: 700;
  font-size: 11.5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Nudge Alert Modal inside Pad */
.nudge-alert {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  background: #181920;
  color: #fff;
  border: 1px solid #facc15;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
  border-radius: 12px;
  padding: 14px 16px;
  z-index: 50;
  animation: bannerDrop 0.25s ease-out;
}

@keyframes bannerDrop {
  from { transform: translateY(-12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.nudge-alert-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  color: #facc15;
  margin-bottom: 4px;
}

.nudge-alert p {
  margin: 0 0 10px;
  font-size: 13px;
  color: #e2e8f0;
}

.nudge-progress-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}

.nudge-progress-fill {
  height: 100%;
  background: #facc15;
  width: 100%;
  transition: width 1s linear;
}

.nudge-alert-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nudge-alert-btn {
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  border: 1px solid transparent;
}

.nudge-btn-dismiss {
  background: #facc15;
  color: #000;
}

.nudge-btn-dismiss:hover {
  background: #eab308;
}

.nudge-btn-pin {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.nudge-btn-pin:hover {
  background: rgba(255, 255, 255, 0.2);
}

.nudge-btn-snooze {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
}

/* Minimized Pill Mode */
.flipnote-pad.minimized {
  height: 52px;
  min-height: 52px;
  max-width: 220px;
  padding: 0 16px;
  flex-direction: row;
  align-items: center;
  cursor: pointer;
  border-radius: 999px;
  gap: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

.flipnote-pad.minimized .coils,
.flipnote-pad.minimized .pad-toolbar,
.flipnote-pad.minimized .paper-sheet-container,
.flipnote-pad.minimized .pad-footer,
.flipnote-pad.minimized .nudge-alert {
  display: none !important;
}

.flipnote-pad.minimized .pad-top-bar {
  width: 100%;
  margin: 0;
}

.flipnote-pad.minimized .pad-actions {
  display: none;
}

.flipnote-pad.minimized .pad-title-btn {
  font-size: 14px;
}

.minimized-indicator {
  display: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--btn-cover-color);
  margin-left: auto;
}

.flipnote-pad.minimized .minimized-indicator {
  display: inline-flex;
}

/* Document PiP Fullscreen Mode */
.pip-body {
  margin: 0;
  padding: 10px;
  background: #0c0d11;
  height: 100vh;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.pip-body .flipnote-pad {
  max-width: 100%;
  height: 100%;
  flex-grow: 1;
  border-radius: 14px;
}

.pip-body .paper-sheet-container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.pip-body .paper-sheet {
  flex-grow: 1;
}

/* Features Section */
.sec {
  padding: 56px 0;
  border-top: 1px solid var(--line);
}

.sec h2 {
  font-size: clamp(24px, 3.2vw, 32px);
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.sec .lede {
  color: var(--ink-soft);
  margin: 0 0 30px;
  max-width: 60ch;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.f {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.f .ic {
  font-size: 22px;
  margin-bottom: 10px;
}

.f h3 {
  margin: 0 0 6px;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.f p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* Themes Swatches in Features */
.themes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.sw {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--ink);
}

.sw:hover {
  border-color: #c0b8a6;
  transform: translateY(-1px);
}

.sw:focus-visible {
  outline: 2px solid var(--ink);
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

/* How It Works Section */
.steps {
  counter-reset: s;
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
}

.steps li {
  counter-increment: s;
  position: relative;
  padding: 0 0 18px 36px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.6;
}

.steps li::before {
  content: counter(s);
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.steps b {
  color: var(--ink);
  font-weight: 600;
}

/* Footer */
footer {
  border-top: 1px solid var(--line);
  padding: 28px 0 46px;
  color: var(--ink-soft);
  font-size: 13.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

footer a {
  color: var(--ink-soft);
  text-decoration: none;
}

footer a:hover {
  color: var(--ink);
}

/* Responsive */
@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 36px;
    padding: 20px 0 44px;
  }
  
  #notebook-host {
    min-height: auto;
  }
}

@media (max-width: 480px) {
  .wrap {
    padding: 0 16px;
  }
  
  .flipnote-pad {
    padding: 20px 14px 16px;
  }
  
  .paper-sheet {
    padding: 12px 12px 10px;
  }
  
  .cta {
    flex-direction: column;
    align-items: stretch;
  }
  
  .btn {
    width: 100%;
  }
}

/* ==========================================================
   Book motion: floating pad, hinged cover, bending page turn,
   standing pen that writes with you.
   ========================================================== */
:root {
  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-turn: cubic-bezier(0.45, 0.05, 0.25, 1);
}

/* Floating: the pad drifts, its ground shadow breathes in counter-phase */
.flipnote-pad:not(.minimized) {
  animation: padFloat 6.5s ease-in-out infinite;
}

.flipnote-pad:not(.minimized)::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -34px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(10, 10, 14, 0.32), transparent);
  filter: blur(4px);
  pointer-events: none;
  z-index: -1;
  animation: padShadow 6.5s ease-in-out infinite;
}

@keyframes padFloat {
  0%, 100% { translate: 0 0; rotate: -0.4deg; }
  50% { translate: 0 -9px; rotate: 0.4deg; }
}

@keyframes padShadow {
  0%, 100% { translate: 0 0; scale: 1; opacity: 1; }
  50% { translate: 0 9px; scale: 0.82; opacity: 0.6; }
}

/* Typing pauses the float so the page is steady under the pen */
.flipnote-pad.is-writing,
.flipnote-pad.is-writing::after,
.flipnote-pad:hover,
.flipnote-pad:hover::after,
.flipnote-pad:focus-within,
.flipnote-pad:focus-within::after {
  animation-play-state: paused;
}

/* Stack of page edges peeking out on the fore-edge */
.page-stack {
  position: absolute;
  inset: 6px -5px -5px 6px;
  border-radius: 12px;
  background:
    repeating-linear-gradient(90deg, transparent 0 1px, rgba(0, 0, 0, 0.07) 1px 2px) right / 5px 100% no-repeat,
    repeating-linear-gradient(0deg, transparent 0 1px, rgba(0, 0, 0, 0.07) 1px 2px) bottom / 100% 5px no-repeat,
    var(--sheet-bg);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
  filter: brightness(0.94);
}

.paper-sheet {
  z-index: 1;
  background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.07), transparent 14px);
}

/* Turning leaf: a clone of the page that bends around the spine */
.turning-leaf {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  flex-direction: column;
  border-radius: 12px;
  background: var(--sheet-bg);
  color: var(--sheet-text);
  padding: 16px 16px 14px;
  overflow: hidden;
  transform-origin: left center;
  backface-visibility: hidden;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

.turning-leaf::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 40%, rgba(0, 0, 0, 0.2) 78%, rgba(255, 255, 255, 0.35) 92%, rgba(0, 0, 0, 0.12));
  opacity: 0;
  pointer-events: none;
}

.turning-leaf.turn-next,
.turning-leaf.turn-prev {
  display: flex;
}

.turning-leaf.turn-next {
  animation: leafTurnNext 0.62s var(--ease-turn) forwards;
}

.turning-leaf.turn-prev {
  animation: leafTurnPrev 0.62s var(--ease-turn) forwards;
}

.turning-leaf.turn-next::after,
.turning-leaf.turn-prev::after {
  animation: leafShade 0.62s var(--ease-turn) forwards;
}

@keyframes leafTurnNext {
  0% { transform: rotateY(0deg) skewY(0deg); border-radius: 12px; }
  35% { transform: rotateY(-55deg) skewY(-3deg) scaleX(0.97); border-radius: 12px 48px 48px 12px / 12px 22px 22px 12px; }
  70% { transform: rotateY(-120deg) skewY(2deg) scaleX(0.92); }
  100% { transform: rotateY(-180deg) skewY(0deg); }
}

@keyframes leafTurnPrev {
  0% { transform: rotateY(-180deg) skewY(0deg); }
  30% { transform: rotateY(-120deg) skewY(2deg) scaleX(0.92); }
  65% { transform: rotateY(-55deg) skewY(-3deg) scaleX(0.97); border-radius: 12px 48px 48px 12px / 12px 22px 22px 12px; }
  100% { transform: rotateY(0deg) skewY(0deg); border-radius: 12px; }
}

@keyframes leafShade {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

.turning-leaf .rule-del,
.turning-leaf .add-rule-btn {
  visibility: hidden;
}

/* Hardcover that closes over the pad on a left hinge */
.book-cover {
  position: absolute;
  inset: -1px;
  z-index: 40;
  border-radius: var(--pad-radius);
  background:
    radial-gradient(120% 80% at 30% 20%, rgba(255, 255, 255, 0.08), transparent 60%),
    repeating-linear-gradient(35deg, rgba(255, 255, 255, 0.018) 0 2px, transparent 2px 5px),
    var(--pad-bg);
  border: 1px solid var(--pad-border);
  box-shadow: inset 0 0 0 6px rgba(0, 0, 0, 0.12), inset 0 0 40px rgba(0, 0, 0, 0.35);
  transform-origin: left center;
  transform: rotateY(-178deg);
  backface-visibility: hidden;
  visibility: hidden;
  pointer-events: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.75s var(--ease-soft), visibility 0s linear 0.75s;
}

.flipnote-pad.book-closed .book-cover {
  transform: rotateY(0deg);
  visibility: visible;
  pointer-events: auto;
  transition: transform 0.75s var(--ease-soft), visibility 0s;
}

.book-cover:focus-visible {
  outline: 2px solid var(--btn-cover-color);
  outline-offset: 3px;
}

.cover-spine {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 26px;
  border-radius: var(--pad-radius) 0 0 var(--pad-radius);
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.45), rgba(255, 255, 255, 0.06) 70%, rgba(0, 0, 0, 0.25));
  cursor: grab;
}

.cover-emboss {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 30px;
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  color: var(--btn-cover-color);
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 1px 0 rgba(0, 0, 0, 0.4);
}

.cover-mark {
  font-size: 26px;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.5));
}

.cover-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.12);
}

.cover-sub {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
}

.cover-band {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 34px;
  width: 9px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.5), var(--accent) 40%, rgba(0, 0, 0, 0.4));
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
}

.cover-hint {
  position: absolute;
  bottom: 16px;
  font-size: 11px;
  color: var(--btn-cover-color);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.book-cover:hover .cover-hint {
  opacity: 0.75;
}

/* Standing pen */
.pen-rig {
  position: absolute;
  right: -10px;
  bottom: 58px;
  width: 16px;
  height: 84px;
  z-index: 30;
  pointer-events: none;
  transition: transform 0.38s var(--ease-soft), opacity 0.3s ease;
  will-change: transform;
}

.pen {
  display: block;
  transform-origin: 50% 100%;
  transform: rotate(7deg);
  filter: drop-shadow(-2px 3px 3px rgba(0, 0, 0, 0.35));
  transition: transform 0.38s var(--ease-soft);
  animation: penIdle 5s ease-in-out infinite;
}

.pen-base {
  position: absolute;
  left: 50%;
  bottom: -3px;
  width: 22px;
  height: 6px;
  translate: -50% 0;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.35), transparent);
  transition: opacity 0.2s ease;
}

@keyframes penIdle {
  0%, 100% { rotate: 0deg; }
  50% { rotate: -2.5deg; }
}

.pen-rig.writing .pen {
  transform: rotate(32deg);
  animation: penScribble 0.16s ease-in-out infinite alternate;
}

.pen-rig.writing .pen-base {
  opacity: 0;
}

@keyframes penScribble {
  from { translate: -1.5px 0; rotate: -3deg; }
  to { translate: 1.5px -1px; rotate: 3deg; }
}

.flipnote-pad.book-closed .pen-rig,
.flipnote-pad.minimized .pen-rig {
  opacity: 0;
}

/* Brand printed on every page */
.sheet-brand {
  align-self: flex-end;
  margin-top: 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 10px;
  font-style: italic;
  letter-spacing: 0.08em;
  color: var(--sheet-muted);
  opacity: 0.6;
  user-select: none;
  pointer-events: none;
}

.related-btn {
  margin-left: auto;
  white-space: nowrap;
}

.timer-pill:not([style*="none"]) + .related-btn {
  margin-left: 6px;
}

/* Editable cover title */
.cover-title {
  outline: none;
  cursor: text;
  min-width: 3ch;
  max-width: 12ch;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  border-radius: 4px;
  padding: 0 4px;
  user-select: text;
  -webkit-user-select: text;
}

.cover-title:hover,
.cover-title:focus {
  background: rgba(255, 255, 255, 0.07);
  text-overflow: clip;
}

.cover-min {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--btn-cover-bg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--btn-cover-color);
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  width: 30px;
  height: 26px;
  cursor: pointer;
}

.cover-min:hover {
  background: var(--btn-cover-hover);
}

.cover-min:focus-visible {
  outline: 2px solid #fff;
}

.flipnote-pad.minimized .book-cover,
.flipnote-pad.minimized .resize-grip {
  display: none;
}

/* Resize grip (desktop shell only) */
.resize-grip {
  display: none;
}

html.desktop .resize-grip {
  display: block;
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 18px;
  height: 18px;
  z-index: 60;
  cursor: nwse-resize;
  border-radius: 0 0 var(--pad-radius) 0;
  background:
    linear-gradient(135deg, transparent 52%, var(--btn-cover-color) 52% 58%, transparent 58% 68%, var(--btn-cover-color) 68% 74%, transparent 74%);
  opacity: 0.55;
}

html.desktop .resize-grip:hover {
  opacity: 1;
}

/* Desktop shell (FlipNote Desktop, ?desktop=1): the notebook fills its window */
html.desktop,
html.desktop body {
  background: transparent;
  overflow: hidden;
  height: 100%;
}

html.desktop .nav,
html.desktop .hero-content,
html.desktop .sec,
html.desktop footer,
html.desktop #btn-pad-popout,
html.desktop #notebook-pip-placeholder,
html.desktop #t2s-fab {
  display: none !important;
}

html.desktop .wrap {
  max-width: none;
  padding: 0;
  height: 100%;
}

html.desktop .hero {
  display: block;
  height: 100%;
  padding: 14px 0 0;
}

html.desktop .hero-visual,
html.desktop #notebook-host {
  height: 100%;
  min-height: 0;
}

html.desktop #notebook-host {
  align-items: stretch;
}

html.desktop .flipnote-pad {
  max-width: none;
  height: 100%;
  min-height: 0;
  padding: 22px 14px 14px;
}

html.desktop .paper-sheet-container {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

html.desktop .paper-sheet {
  flex: 1 1 auto;
  min-height: 0;
}

html.desktop .rule-list {
  min-height: 0;
  overflow-y: auto;
}

html.desktop .pen-rig {
  right: 8px;
}

/* Chrome is controls, not text: no stray selection highlight when clicking/dragging */
.pad-top-bar,
.pad-toolbar,
.pad-footer,
.book-cover {
  user-select: none;
  -webkit-user-select: none;
}

html.desktop [data-drag] {
  cursor: grab;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .pen-rig {
    transform: none !important;
  }
}
