:root {
  --color-text: #1b1c1d;
  --color-text-strong: #181b1f;
  --color-text-muted: #5d6167;
  --color-page: #f7f7f2;
  --color-surface: #fffdf5;
  --color-surface-solid: #ffffff;
  --color-focus: #2876b8;
  --color-success-dark: #2d8744;
  --line-default: rgba(31, 35, 40, 0.16);
  --line-strong: rgba(31, 35, 40, 0.4);
  --shadow-floating: 0 6px 16px rgba(31, 35, 40, 0.14);
  --shadow-panel: 0 8px 20px rgba(31, 35, 40, 0.16);
  --shadow-note-draft: 0 8px 18px rgba(31, 35, 40, 0.12);
  --note-radius: 2px;
  --note-input-size: 172.8px;
  --control-gap: 8px;
  color: var(--color-text);
  background: var(--color-page);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  min-width: 360px;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

a {
  color: #175a8d;
}

.app-shell {
  position: relative;
  width: 100dvw;
  min-width: 360px;
  height: 100dvh;
  overflow: hidden;
  background: var(--color-page);
}

.world-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  isolation: isolate;
  overflow: hidden;
  background-color: var(--color-page);
  cursor: default;
}

.board-surface,
.note-layer {
  position: absolute;
  left: 50%;
  top: 52%;
  width: min(1660px, 164vw);
  height: min(1100px, 132vh);
  transform: translate(-50%, -50%);
}

.board-surface {
  z-index: 0;
  border: 1px solid rgba(31, 35, 40, 0.18);
  background-color: #fffdf7;
  background-image:
    linear-gradient(rgba(31, 35, 40, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 35, 40, 0.08) 1px, transparent 1px);
  background-size: clamp(52px, 6vw, 84px) clamp(52px, 6vw, 84px);
  background-position: center;
  background-origin: border-box;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.75) inset;
  pointer-events: none;
}

.note-layer {
  z-index: 1;
  pointer-events: none;
}

.placed-note {
  position: absolute;
  display: grid;
  place-items: center;
  width: clamp(48px, 6.2vw, 88px);
  height: clamp(48px, 6.2vw, 88px);
  border: 1px solid rgba(31, 35, 40, 0.18);
  border-color: var(--note-border, rgba(31, 35, 40, 0.18));
  border-radius: var(--note-radius);
  color: var(--color-text);
  background: var(--note-bg, #fff3a6);
  box-shadow: 0 4px 8px rgba(31, 35, 40, 0.2);
  font-size: clamp(0.74rem, 1.25vw, 1.05rem);
  font-weight: 700;
  overflow: hidden;
  transform: translate(-50%, -50%) rotate(var(--note-rotate, 0deg));
  transform-origin: 50% 58%;
  user-select: none;
  animation: placed-note-stick 0.68s cubic-bezier(0.2, 1.5, 0.34, 1) both;
  animation-delay: var(--note-delay, 0ms);
}

.note-text {
  display: block;
  width: calc(100% - 12px);
  max-height: calc(100% - 12px);
  overflow: hidden;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

@keyframes placed-note-stick {
  0% {
    opacity: 0;
    box-shadow: 0 22px 28px rgba(31, 35, 40, 0.08);
    transform: translate(-50%, -72%) rotate(calc(var(--note-rotate, 0deg) - 10deg)) scale(1.18);
  }

  42% {
    opacity: 1;
    box-shadow: 0 3px 5px rgba(31, 35, 40, 0.26);
    transform: translate(-50%, -48%) rotate(calc(var(--note-rotate, 0deg) + 4deg)) scale(0.9, 1.08);
  }

  62% {
    box-shadow: 0 7px 10px rgba(31, 35, 40, 0.18);
    transform: translate(-50%, -51%) rotate(calc(var(--note-rotate, 0deg) - 2deg)) scale(1.04, 0.96);
  }

  82% {
    transform: translate(-50%, -50%) rotate(calc(var(--note-rotate, 0deg) + 1deg)) scale(0.99, 1.01);
  }

  100% {
    opacity: 1;
    box-shadow: 0 4px 8px rgba(31, 35, 40, 0.2);
    transform: translate(-50%, -50%) rotate(var(--note-rotate, 0deg)) scale(1);
  }
}

.brand-header {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 16px;
  z-index: 34;
  display: flex;
  align-items: center;
  min-height: 48px;
  gap: 8px;
  pointer-events: auto;
}

.brand-title-button {
  margin: 0;
  padding: 0 2px;
  border: 0;
  color: var(--color-text-strong);
  background: transparent;
  text-shadow:
    0 2px 8px rgba(255, 253, 245, 0.92),
    0 4px 12px rgba(31, 35, 40, 0.16);
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
  cursor: default;
}

.brand-info-button {
  margin-top: -14px;
}

.icon-btn {
  --icon-btn-size: 40px;
  --icon-btn-border-color: var(--line-strong);
  --icon-btn-color: var(--color-text);
  --icon-btn-bg: rgba(255, 253, 245, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--icon-btn-size);
  height: var(--icon-btn-size);
  padding: 0;
  border: 1px solid var(--icon-btn-border-color);
  border-radius: 50%;
  color: var(--icon-btn-color);
  background: var(--icon-btn-bg);
  box-shadow: var(--shadow-floating);
  cursor: default;
  opacity: 0.8;
}

.icon-btn--sm {
  --icon-btn-size: 32px;
}

.icon-btn--lg {
  --icon-btn-size: 48px;
}

.icon-btn svg {
  display: block;
  width: 56%;
  height: 56%;
  fill: currentColor;
}

.time-slider-shell {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  z-index: 20;
  transform: translateX(-50%);
  pointer-events: none;
}

.time-controller {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  pointer-events: auto;
}

.time-controller-date-viewer {
  min-width: 200px;
  padding: 10px 16px 9px;
  border: 1px solid var(--line-default);
  border-radius: 32px;
  color: #1f2328;
  background: rgba(255, 253, 245, 0.9);
  box-shadow: 0 6px 12px rgba(31, 35, 40, 0.14);
  text-align: center;
  line-height: 1.1;
}

.time-controller-date,
.time-controller-time {
  display: block;
  white-space: nowrap;
}

.time-controller-date {
  font-size: 1.125rem;
  font-weight: 700;
}

.time-controller-time {
  margin-top: 4px;
  font-size: 0.875rem;
  font-weight: 500;
}

.product-panel {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  z-index: 36;
  width: min(392px, calc(100dvw - 32px));
  max-height: calc(100dvh - 32px - env(safe-area-inset-top));
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line-default);
  border-radius: 8px;
  color: var(--color-text);
  background: rgba(255, 253, 245, 0.94);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(8px);
}

.product-panel-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(31, 35, 40, 0.12);
}

.product-panel-kicker,
.product-fineprint {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.35;
}

.product-panel h1,
.product-panel h2,
.product-panel p {
  margin: 0;
}

.product-panel h1 {
  color: var(--color-text-strong);
  font-size: 1.28rem;
  font-weight: 900;
  line-height: 1.1;
}

.product-panel-header p:last-child {
  color: var(--color-text-subtle, #44484e);
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.45;
}

.product-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0;
}

.product-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.product-section-title h2 {
  color: var(--color-text-strong);
  font-size: 0.95rem;
  font-weight: 900;
}

.product-section-title span {
  color: var(--color-text-muted);
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.price-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  padding: 10px;
  border: 1px solid rgba(31, 35, 40, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.78);
}

.price-card-featured {
  border-color: rgba(47, 179, 89, 0.32);
  background: rgba(233, 250, 238, 0.78);
}

.price-card strong {
  color: var(--color-text-strong);
  font-size: 0.78rem;
  font-weight: 900;
}

.price-card span {
  color: var(--color-text-muted);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
}

.price-card b {
  color: var(--color-text-strong);
  font-size: 0.88rem;
  font-weight: 900;
}

.product-details {
  border-top: 1px solid rgba(31, 35, 40, 0.12);
  padding: 10px 0 0;
}

.product-details + .product-details {
  margin-top: 8px;
}

.product-details summary {
  color: var(--color-text-strong);
  font-size: 0.86rem;
  font-weight: 900;
  cursor: pointer;
}

.product-details ul {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 9px 0 0;
  padding: 0 0 0 18px;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.4;
}

.add-note-control {
  position: absolute;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: calc(var(--note-input-size) * 2);
  transform: translateX(-50%);
  --place-guide-color: #b28a00;
  --draft-note-bg: #fff3a6;
  --draft-note-border: #d8bd45;
  --draft-note-accent: #b28a00;
}

.add-note-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--note-input-size) minmax(0, 1fr);
  align-items: start;
  gap: var(--control-gap);
  width: 100%;
  overflow: visible;
}

.note-color-palette {
  position: relative;
  grid-column: 1;
  display: grid;
  grid-template-columns: 32px 40px;
  grid-template-rows: 1fr 1fr;
  gap: var(--control-gap);
  align-items: stretch;
  justify-self: end;
  width: 80px;
  height: var(--note-input-size);
}

.note-color-nav {
  color: var(--place-guide-color);
}

.note-color-nav:first-child {
  align-self: start;
  grid-column: 1;
  grid-row: 1;
}

.note-color-nav:last-child {
  align-self: end;
  grid-column: 1;
  grid-row: 2;
}

.note-color-window {
  position: relative;
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  gap: var(--control-gap);
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  width: 40px;
  height: 100%;
  padding: 0 4px;
  overflow: hidden;
}

.note-color-dot {
  position: relative;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--note-color-border);
  border-radius: 999px;
  background: var(--note-color-bg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.note-color-dot-selected {
  flex-basis: 36px;
  width: 36px;
  height: 36px;
  border-color: var(--place-guide-color);
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.86),
    0 0 0 2px var(--place-guide-color);
}

.add-note-stack-container {
  position: relative;
  grid-column: 2;
  flex-shrink: 0;
  width: var(--note-input-size);
  height: var(--note-input-size);
}

.note-stack-ghost {
  position: absolute;
  left: 0;
  top: 0;
  z-index: calc(10 - var(--stack-index, 0));
  width: var(--note-input-size);
  height: var(--note-input-size);
  border: 1px solid var(--draft-note-border);
  border-radius: var(--note-radius);
  background: var(--draft-note-bg);
  box-shadow: 0 4px 10px rgba(31, 35, 40, 0.06);
  opacity: calc(1 - var(--stack-index, 0) * 0.12);
  transform: translateY(var(--stack-offset-px, 0));
  pointer-events: none;
}

.add-note-input {
  position: relative;
  z-index: 15;
  display: block;
  width: var(--note-input-size);
  height: var(--note-input-size);
  padding: 12px;
  border: 1px solid var(--draft-note-border);
  border-radius: var(--note-radius);
  color: var(--color-text);
  background: var(--draft-note-bg);
  box-shadow: var(--shadow-note-draft);
  font-weight: 600;
  text-align: center;
}

.add-note-right-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  grid-column: 3;
  flex-shrink: 0;
  min-width: 0;
  height: var(--note-input-size);
}

.note-enhance-group {
  display: flex;
  flex-direction: row;
  gap: 6px;
}

.note-enhance-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.note-enhance-btn {
  color: var(--place-guide-color);
}

.note-enhance-cost {
  color: var(--color-text-muted);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.add-note-meter-group {
  display: flex;
  flex-direction: column;
  gap: var(--control-gap);
  min-width: 0;
}

.add-note-count,
.add-note-status {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  line-height: 1;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .placed-note {
    animation: none;
  }
}

@media (max-width: 1120px) {
  .product-panel {
    top: calc(84px + env(safe-area-inset-top));
    width: min(372px, calc(100dvw - 32px));
  }
}

@media (max-width: 720px) {
  :root {
    --note-input-size: 132px;
  }

  .time-slider-shell {
    top: calc(72px + env(safe-area-inset-top));
  }

  .time-controller {
    gap: 8px;
  }

  .time-controller-date-viewer {
    min-width: 164px;
    padding: 9px 12px;
  }

  .time-controller-date {
    font-size: 0.95rem;
  }

  .time-controller-time {
    font-size: 0.78rem;
  }

  .product-panel {
    top: calc(130px + env(safe-area-inset-top));
    right: 12px;
    width: min(336px, calc(100dvw - 24px));
    max-height: calc(100dvh - 292px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 12px;
  }

  .price-grid {
    grid-template-columns: 1fr;
  }

  .add-note-control {
    width: min(calc(100dvw - 24px), calc(var(--note-input-size) * 2.34));
  }

  .add-note-input-row {
    grid-template-columns: 64px var(--note-input-size) minmax(80px, 1fr);
  }

  .note-color-palette {
    grid-template-columns: 28px 32px;
    width: 64px;
  }

  .note-color-dot {
    flex-basis: 26px;
    width: 26px;
    height: 26px;
  }

  .note-color-dot-selected {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
  }
}
