* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, sans-serif;
  background: #f5f5f5;
  color: #222;
}

.top-header {
  position: relative;
  z-index: 10;
  height: 64px;
  background: #000;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
}

.logo-area a {
  color: #fff;
  text-decoration: none;
  font-size: 24px;
  font-weight: bold;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.main-nav a {
  color: #fff;
  text-decoration: none;
  padding: 8px 10px;
}

.main-nav a:hover,
.main-nav a.active {
  background: #333;
  border-radius: 5px;
}

/* Hand / writing navigation button */
.writing-nav-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}

.writing-nav-btn:hover,
.writing-nav-btn.open {
  background: #333;
}

/* Normal page */
.page-content {
  padding: 50px 20px;
}

.hero {
  max-width: 900px;
  margin: auto;
  text-align: center;
}

.hero h1 {
  margin-bottom: 10px;
}

.hero p {
  line-height: 1.6;
}

.demo-card {
  margin: 35px auto;
  max-width: 700px;
  padding: 30px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.08);
  text-align: left;
}

/* =========================
   WRITING CANVAS
   ========================= */

.writing-layer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  pointer-events: none;
}

.writing-layer.open {
  display: block;
}

#writingCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
  touch-action: none;
  pointer-events: auto;
  cursor: crosshair;
}

/* White Paper mode: only the bottom 50% becomes a writing sheet.
   The clipped upper area does not receive pointer events, so the webpage
   above remains clickable. */
.writing-layer.paper-mode #writingCanvas {
  background: white;
  clip-path: inset(50% 0 0 0);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.16);
}

.mode-btn {
  min-width: 84px;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: #303030;
  color: white;
  cursor: pointer;
  font-size: 12px;
}

.mode-btn:hover {
  background: #4a4a4a;
}

.mode-btn.active {
  background: white;
  color: #111;
}

/* Toolbar stays above canvas */
.writing-toolbar {
  position: absolute;
  z-index: 2;
  top: 78px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 24px);
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  background: rgba(20, 20, 20, 0.90);
  color: white;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
  pointer-events: auto;
  user-select: none;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.toolbar-group:last-child {
  border-right: 0;
  padding-right: 0;
}

.tool-btn,
.utility-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  background: #303030;
  color: white;
  cursor: pointer;
  font-size: 17px;
}

.tool-btn:hover,
.utility-btn:hover {
  background: #4a4a4a;
}

.tool-btn.active {
  background: #fff;
  color: #111;
}

.utility-btn.danger:hover {
  background: #9f2f2f;
}

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

.writing-toolbar label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  white-space: nowrap;
}

.range-label input[type="range"] {
  width: 80px;
}

.writing-toolbar input[type="color"] {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.writing-toolbar input[type="range"] {
  accent-color: white;
}

#sizeValue,
#opacityValue,
/* scale removed */
#scaleValue {
  display:none;
  min-width: 32px;
  text-align: right;
  font-size: 11px;
}

/* Small screens */
@media (max-width: 850px) {
  .writing-toolbar {
    top: 72px;
    left: 8px;
    right: 8px;
    transform: none;
    flex-wrap: wrap;
    justify-content: center;
  }

  .toolbar-group {
    border-right: 0;
  }
}

@media (max-width: 600px) {
  .top-header {
    padding: 0 12px;
  }

  .logo-area a {
    font-size: 20px;
  }

  .writing-toolbar {
    gap: 5px;
    padding: 6px;
  }

  .range-label input[type="range"] {
    width: 60px;
  }
}


/* Minimized writing toolbar */
.writing-toolbar.minimized {
  display: none;
}

.toolbar-expand-btn {
  display: none;
  position: absolute;
  z-index: 10002;
  top: 78px;
  left: 18px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #444;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-size: 22px;
  line-height: 42px;
  text-align: center;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

.writing-toolbar.minimized + .toolbar-expand-btn {
  display: block;
}

.toolbar-expand-btn:hover {
  background: #333;
}
