:root {
  color-scheme: dark;
  --canvas: #191918;
  --panel: #282827;
  --ink: #edc663;
  --text: #eeece6;
  --muted: #a5a5a0;
  --line: #ffffff14;
  --bar-height: 72px;
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
button,
input {
  font: inherit;
}
button {
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  touch-action: manipulation;
}
button,
a {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button:disabled {
  cursor: default;
  opacity: 0.45;
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}
svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.icon-library {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.topbar {
  height: calc(var(--bar-height) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 28px 0;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 3;
  background: #1d1d1b;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
}
.brand-fast {
  color: #a3a39c;
  font-weight: 400;
}
.brand-mark {
  width: 30px;
  height: 34px;
  color: var(--ink);
  stroke-width: 2.5;
}
.history-controls {
  display: flex;
  gap: 4px;
  margin-left: 30px;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}
.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition:
    background 0.15s,
    color 0.15s;
}
.icon-button:hover:not(:disabled) {
  background: #ffffff09;
  color: var(--text);
}
.icon-button svg {
  width: 19px;
  height: 19px;
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}
.local-status {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b3a379;
  display: inline-block;
  flex-shrink: 0;
}
.connect-button {
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #edc66325;
  border-radius: 9px;
  padding: 8px 12px;
  color: #edce87;
  background: #edc66308;
  font-size: 13px;
}
.connect-button svg {
  width: 18px;
  height: 18px;
}
.connect-button:hover {
  background: #edc66313;
  border-color: #edc66340;
}
.coffee-button {
  color: #c2bbaa;
  border-color: #ffffff1c;
  background: #ffffff03;
  font-weight: 400;
  white-space: nowrap;
}
.coffee-button:hover {
  color: #eeece6;
  background: #ffffff09;
  border-color: #ffffff30;
}
.board {
  position: relative;
  height: calc(100dvh - var(--bar-height) - env(safe-area-inset-top));
  overflow: hidden;
  background: var(--canvas);
}
.board.grid {
  background-image: radial-gradient(circle, #b8b5a130 0.85px, transparent 0.85px);
  background-size: 24px 24px;
  background-position: 12px 12px;
}
#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}
.empty-state {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  transition: opacity 0.2s;
  width: calc(100% - 40px);
}
.empty-state.hidden {
  opacity: 0;
}
.empty-pencil {
  width: 51px;
  height: 51px;
  color: #73736b;
  stroke-width: 1.35;
  margin-bottom: 17px;
  transform: rotate(-7deg);
}
.pencil-flourish {
  stroke: #a28e5b;
  opacity: 0.75;
}
.empty-state h1 {
  font-size: 17px;
  font-weight: 500;
  color: #a5a59e;
  margin: 0 0 10px;
}
.empty-state p {
  font-size: 13px;
  color: #94948c;
  line-height: 1.5;
  margin: 0;
}
.board-footer {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: flex-end;
  pointer-events: none;
}
.board-options {
  display: flex;
  gap: 4px;
  pointer-events: auto;
}
.board-options .icon-button[aria-pressed='true'] {
  color: var(--ink);
  background: #edc6630b;
}
.drawing-toolbar {
  position: absolute;
  left: 50%;
  bottom: max(64px, calc(env(safe-area-inset-bottom) + 46px));
  transform: translateX(-50%);
  height: 72px;
  padding: 0 14px 0 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: 0 8px 28px #0003;
  z-index: 2;
}
.tool-group {
  display: flex;
  align-items: center;
  gap: 2px;
  align-self: stretch;
}
.drawing-tool {
  height: 100%;
  width: 44px;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  padding: 0;
  transition: background 0.15s;
}
.drawing-tool:hover {
  background: #ffffff05;
}
.drawing-tool:focus-visible {
  outline-offset: -3px;
}
.instrument {
  width: 32px;
  height: 64px;
  position: absolute;
  left: 50%;
  bottom: -17px;
  transform: translateX(-50%);
  stroke: none;
  transition: bottom 0.2s;
  filter: drop-shadow(1px 0 2px #0003);
}
.drawing-tool:hover .instrument {
  bottom: -13px;
}
.drawing-tool.selected .instrument {
  bottom: -5px;
}
.tool-indicator {
  position: absolute;
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0;
  box-shadow: 0 0 0 3px var(--panel);
}
.drawing-tool.selected .tool-indicator {
  opacity: 1;
}
.drawing-tool[data-tool='eraser'] .tool-indicator {
  background: #d8b9b2;
}
.toolbar-divider {
  width: 1px;
  height: 28px;
  background: var(--line);
  flex-shrink: 0;
}
.color-group {
  display: flex;
  gap: 0;
  align-items: center;
}
.color-swatch {
  position: relative;
  width: 36px;
  height: 44px;
  border-radius: 8px;
  padding: 0;
}
.color-swatch::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--swatch);
}
.color-swatch:hover {
  background: #ffffff06;
}
.color-swatch.selected::after {
  content: '';
  position: absolute;
  width: 30px;
  height: 30px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid #c5c5b688;
  border-radius: 50%;
}
.color-swatch svg {
  width: 13px;
  height: 13px;
  stroke: #242420;
  stroke-width: 2.1;
  position: absolute;
  inset: 0;
  margin: auto;
  opacity: 0;
}
.color-swatch.selected svg {
  opacity: 1;
}
.size-control {
  position: relative;
}
.size-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--muted);
  border-radius: 7px;
}
.size-button:hover {
  background: #ffffff06;
}
.size-sample {
  width: 7px;
  height: 7px;
  background: var(--ink);
  border-radius: 50%;
  flex-shrink: 0;
}
.size-button svg {
  width: 15px;
  height: 15px;
}
.size-popover {
  position: absolute;
  bottom: 65px;
  right: -10px;
  width: 220px;
  padding: 16px;
  background: #2a2a28;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 30px #0004;
}
.popover-label {
  font-size: 12px;
  color: var(--muted);
}
.size-options {
  display: flex;
  gap: 2px;
  margin-top: 12px;
}
.size-options button {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.size-options button:hover {
  background: #ffffff08;
}
.size-options button.selected {
  background: #edc66312;
  box-shadow: inset 0 0 0 1px #edc66330;
}
.size-options button span {
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: var(--ink);
}
.toolbar-caption {
  position: absolute;
  left: 50%;
  bottom: max(34px, calc(env(safe-area-inset-bottom) + 16px));
  transform: translateX(-50%);
  font-size: 11px;
  color: #99998f;
  pointer-events: none;
}
.toolbar-caption span {
  padding: 0 6px;
}
.pan-hint {
  position: absolute;
  left: 24px;
  bottom: 30px;
  font-size: 11px;
  color: #99998f;
  pointer-events: none;
}
.toast {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: #31312e;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 16px;
  max-width: calc(100% - 32px);
  width: max-content;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 4;
}
.toast.visible {
  opacity: 1;
}
.connect-dialog {
  max-width: 360px;
  width: calc(100% - 32px);
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
  background: #292929;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px 20px;
  text-align: center;
  box-shadow: 0 20px 70px #0006;
}
.connect-dialog::backdrop {
  background: #0008;
}
.coffee-dialog {
  width: min(440px, calc(100% - 24px));
  height: min(760px, calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  max-height: none;
  max-width: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #292929;
  color: var(--text);
  box-shadow: 0 20px 70px #0006;
}
.coffee-dialog[open] {
  display: flex;
  flex-direction: column;
}
.coffee-dialog::backdrop {
  background: #0008;
}
.coffee-dialog .dialog-header {
  position: static;
  padding: 6px 18px;
  flex-shrink: 0;
}
.coffee-dialog h2 {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}
.coffee-loading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  flex-shrink: 0;
}
.coffee-loading p {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
#coffee-frame {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 0;
  border: 0;
  background: #fff;
  color-scheme: light;
}
.dialog-header {
  position: sticky;
  top: -18px;
  z-index: 1;
  background: #292929;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
}
.connect-dialog h2 {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
}
.dialog-done {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 0 8px 12px;
  font-size: 14px;
  color: var(--ink);
  border-radius: 6px;
}
.dialog-done:hover {
  color: #ffe09c;
}
.connect-dialog p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}
.qr-frame {
  width: 210px;
  height: 210px;
  padding: 10px;
  margin: 14px auto 16px;
  background: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#pairing-qr {
  width: 100%;
  height: 100%;
}
.connect-dialog .pairing-help {
  margin-bottom: 16px;
}
.pairing-link-row {
  display: flex;
  gap: 8px;
  align-items: center;
  border: 1px solid #ffffff20;
  border-radius: 8px;
  padding: 2px 8px;
}
#pairing-link,
#join-link {
  width: 0;
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  border: 0;
  background: none;
  font-size: 12px;
  color: #b8b8b0;
  text-overflow: ellipsis;
  border-radius: 3px;
}
.copy-link {
  flex-shrink: 0;
  min-height: 40px;
  padding: 8px;
  font-size: 13px;
  color: var(--ink);
  border-radius: 5px;
}
.copy-link:hover {
  background: #ffffff06;
}
.preview-note {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  margin: 18px 0 8px;
}
.preview-note strong {
  font-size: 13px;
  font-weight: 400;
  color: #ddd;
}
.connect-dialog .pairing-remembered {
  font-size: 12px;
  text-align: left;
  color: #b1b1aa;
}
.connect-dialog .pairing-detail {
  font-size: 12px;
  text-align: left;
  margin: 6px 0 18px;
  color: #a5a59d;
}
.scan-button,
.disconnect-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid #ffffff26;
  background: #ffffff08;
  color: var(--text);
  transition:
    background 0.15s,
    border-color 0.15s;
}
.scan-button:hover {
  background: #ffffff12;
  border-color: #ffffff40;
}
.scan-button svg {
  width: 18px;
  height: 18px;
}
.disconnect-button {
  margin-top: 10px;
  background: #df8f8709;
  color: #f0aaa3;
  border-color: #df8f8738;
}
.disconnect-button:hover {
  background: #df8f8717;
  border-color: #df8f8755;
}
#camera-preview {
  display: block;
  width: 100%;
  height: 210px;
  object-fit: cover;
  background: #1b1b1b;
  border-radius: 8px;
  margin: 14px 0 12px;
}
#scan-status {
  margin-bottom: 14px;
}
#cancel-scan {
  margin-top: 12px;
}
#retry-camera {
  margin-bottom: 12px;
}
.local-status[data-state='connected'] .status-dot {
  background: #91baa5;
}
.local-status[data-state='connecting'] .status-dot,
.local-status[data-state='reconnecting'] .status-dot,
.local-status[data-state='waiting'] .status-dot {
  background: var(--ink);
  animation: connection-pulse 1.4s ease-in-out infinite;
}
.local-status[data-state='error'] .status-dot {
  background: #dc948a;
}
@keyframes connection-pulse {
  50% {
    opacity: 0.35;
  }
}
@media (max-width: 1000px) {
  .local-status {
    display: none;
  }
}
@media (max-width: 850px) {
  .topbar {
    padding-left: 20px;
    padding-right: 16px;
  }
  .topbar-right {
    gap: 6px;
  }
  .pan-hint {
    display: none;
  }
  .history-controls {
    margin-left: 18px;
    padding-left: 10px;
  }
  .connect-button {
    justify-content: center;
    padding: 8px;
  }
}
@media (max-width: 700px) {
  :root {
    --bar-height: 112px;
  }
  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: 44px 44px;
    gap: 8px;
    padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  }
  .topbar > .history-controls {
    margin-left: 0;
    padding-left: 12px;
  }
  .topbar-right {
    grid-column: 1 / -1;
    width: 100%;
    margin-left: 0;
    gap: 8px;
  }
  .topbar-right .connect-button {
    flex: 1;
    justify-content: center;
    white-space: nowrap;
  }
  .fullscreen-button {
    display: none;
  }
}
@media (max-width: 600px) {
  .brand {
    font-size: 16px;
    gap: 6px;
  }
  .brand-mark {
    width: 25px;
    height: 30px;
  }
  .history-controls {
    margin-left: 12px;
    padding-left: 6px;
    gap: 0;
  }
  .empty-state {
    top: 38%;
  }
  .drawing-toolbar {
    width: 292px;
    max-width: calc(100% - 24px);
    height: 112px;
    display: grid;
    grid-template-columns: 1fr 44px;
    grid-template-rows: 56px 44px;
    gap: 0;
    padding: 0 12px 10px;
    bottom: max(64px, calc(env(safe-area-inset-bottom) + 46px));
    border-radius: 14px;
  }
  .tool-group {
    grid-column: 1;
    grid-row: 1;
  }
  .drawing-tool {
    width: 44px;
  }
  .toolbar-divider {
    display: none;
  }
  .size-control {
    grid-column: 2;
    grid-row: 1;
  }
  .color-group {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: space-between;
  }
  .color-swatch {
    width: 44px;
  }
  .instrument {
    width: 28px;
    height: 60px;
  }
  .board-footer {
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
  }
}
@media (max-height: 640px) {
  .qr-frame {
    width: 170px;
    height: 170px;
    margin: 8px auto 12px;
  }
  #camera-preview {
    height: 150px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

.connect-dialog #dialog-notice {
  color: var(--ink);
  text-align: left;
  margin: 4px 0 12px;
}
.about-link {
  display: inline-block;
  margin-top: 12px;
  padding: 10px 6px;
  color: var(--muted);
  font-size: 12px;
  text-underline-offset: 3px;
}
.about-link:hover {
  color: var(--text);
}
.about-page {
  overflow: auto;
}
.about-header {
  max-width: 960px;
  margin: auto;
  padding: max(20px, env(safe-area-inset-top)) 24px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.about-page .connect-button {
  display: inline-flex;
  flex-shrink: 0;
  text-decoration: none;
  white-space: nowrap;
}
.about-content {
  max-width: 720px;
  margin: auto;
  padding: 56px 24px max(56px, env(safe-area-inset-bottom));
}
.about-content h1 {
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.15;
  letter-spacing: -0.035em;
  font-weight: 500;
  margin: 0 0 24px;
}
.about-content h2 {
  font-size: 22px;
  line-height: 1.3;
  font-weight: 500;
  margin: 0 0 18px;
}
.about-content p,
.about-content li {
  font-size: 15px;
  line-height: 1.75;
  color: #b9b9b1;
}
.about-content .about-intro {
  font-size: 18px;
}
.about-content section {
  margin-top: 48px;
}
.about-content ol {
  padding-left: 22px;
}
.about-content li {
  padding-left: 6px;
  margin-bottom: 12px;
}
.about-content strong {
  color: #eeece6;
  font-weight: 500;
}
.about-content p a,
.about-content li a {
  color: var(--ink);
  text-underline-offset: 3px;
}
.about-content details {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.about-content summary {
  cursor: pointer;
  font-size: 15px;
  line-height: 1.6;
}
.about-content summary:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}
.about-content details p {
  margin-bottom: 0;
}
.about-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 40px;
}
.about-footer span {
  font-size: 13px;
  color: var(--muted);
}
