:root {
  color: #292923;
  font-family: Inter, ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #d4d0c8;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background-color: #d4d0c8;
  background-image:
    radial-gradient(rgba(63, 59, 52, 0.12) 0.6px, transparent 0.7px),
    radial-gradient(rgba(255, 255, 255, 0.25) 0.7px, transparent 0.8px);
  background-position: 0 0, 5px 6px;
  background-size: 9px 9px, 11px 11px;
}

button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, .page-navigation a:focus-visible { outline: 3px solid #34867c; outline-offset: 3px; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(248, 245, 238, 0.94);
  border-bottom: 1px solid rgba(41, 41, 35, 0.15);
}

.brand, .actions, .drawing-tools { display: flex; align-items: center; }
.brand { gap: 12px; }
.brand h1 { margin: 0; font-size: 20px; line-height: 1.1; }
.brand p { margin: 3px 0 0; color: #6d6d64; font-size: 12px; }

.logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 2px solid #292923;
  border-radius: 5px 5px 10px 5px;
  background: #f8e96b;
  box-shadow: 3px 3px 0 #292923;
  font-size: 12px;
  font-weight: 900;
  transform: rotate(-3deg);
}

.actions { gap: 8px; }
.button, .tool-button, .frame-button, .close-button {
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  background: #e5e0d6;
  cursor: pointer;
  font-weight: 750;
}
.button { padding: 0 16px; }
.button-dark { color: #fff; background: #292923; box-shadow: 0 3px 0 #11110e; }
.button-export { color: #fff; background: #ee6f5a; box-shadow: 0 3px 0 #ba4f3e; }
.button:active, .tool-button:active { transform: translateY(2px); }
.button:disabled { cursor: wait; opacity: 0.7; }

.frames {
  display: flex;
  justify-content: center;
  gap: 9px;
  overflow-x: auto;
  padding: 13px 16px;
  background: rgba(241, 238, 231, 0.9);
  border-bottom: 1px solid rgba(41, 41, 35, 0.12);
}

.frame-button {
  position: relative;
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  min-height: 0;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 7px;
  background: #f8e96b;
  box-shadow: 0 2px 5px rgba(48, 44, 36, 0.18);
}
.frame-button:nth-child(even) { transform: rotate(1deg); }
.frame-button canvas { width: 100%; height: 100%; display: block; border-radius: 5px; }
.frame-button span {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border: 1.5px solid #292923;
  border-radius: 50%;
  background: #fffdf7;
  font-size: 10px;
  font-weight: 900;
}
.frame-button.active { border-color: #ee6f5a; box-shadow: 0 0 0 3px rgba(238, 111, 90, 0.25); }
.frame-button.playing { border-color: #34867c; box-shadow: 0 0 0 3px rgba(52, 134, 124, 0.22); }

.workspace {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 22px;
  padding: clamp(28px, 5vw, 58px) 18px;
}

.note {
  position: relative;
  width: min(72vh, 620px, calc(100vw - 36px));
  aspect-ratio: 1;
  overflow: hidden;
  background: #f8e96b;
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.27), transparent 38%, rgba(133, 105, 22, 0.06));
  box-shadow: 0 24px 28px rgba(53, 47, 38, 0.22);
  clip-path: polygon(0 0, 100% 0, 100% 96%, 96% 100%, 0 100%);
}
.note::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 4%;
  height: 4%;
  background: linear-gradient(135deg, rgba(125, 99, 25, 0.18) 0 48%, rgba(255, 255, 255, 0.52) 50%);
  pointer-events: none;
}

#drawing-canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.frame-label { position: absolute; left: 16px; bottom: 14px; color: rgba(41, 41, 35, 0.45); font-family: monospace; font-size: 10px; font-weight: 800; letter-spacing: 0.08em; pointer-events: none; }

.drawing-tools { gap: 8px; padding: 7px; border: 1px solid rgba(41, 41, 35, 0.12); border-radius: 15px; background: rgba(248, 245, 238, 0.92); box-shadow: 0 8px 20px rgba(48, 44, 36, 0.12); }
.tool-button { padding: 0 15px; background: transparent; font-size: 13px; }
.tool-button:hover:not(:disabled) { background: #fff; }
.tool-button.active, .tool-button.eraser-active { color: #fff; background: #292923; }
.tool-button.danger:hover { color: #ad4034; background: #fff0ec; }
.tool-button:disabled { opacity: 0.35; cursor: default; }

.page-navigation {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 0 18px 28px;
}
.page-navigation .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 4px 0;
  border-radius: 0;
  color: #6d6d64;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.page-navigation .button:hover { text-decoration: underline; }
.page-navigation .button:active { transform: none; }

dialog { width: min(420px, calc(100% - 32px)); padding: 22px; border: 0; border-radius: 22px; background: #f8f5ee; color: #292923; box-shadow: 0 24px 70px rgba(25, 24, 20, 0.3); }
dialog::backdrop { background: rgba(35, 34, 29, 0.45); backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dialog-heading h2 { margin: 0; font-size: 21px; }
.close-button { width: 40px; padding: 0; font-size: 25px; }
.setting { display: grid; gap: 13px; margin-top: 24px; }
.setting > span, .setting-row { font-size: 13px; font-weight: 700; }
.setting output { float: right; padding: 5px 8px; border-radius: 7px; color: #fff; background: #292923; font: 700 11px monospace; }
.setting input { width: 100%; accent-color: #ee6f5a; }
.setting-row { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }
.setting-row span { display: flex; align-items: center; gap: 8px; }
.setting-row select { min-width: 64px; padding: 7px; border: 1px solid #c9c4ba; border-radius: 8px; background: #fff; }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.dot.red { background: #d4564c; }
.dot.green { background: #368579; }
.done-button { width: 100%; margin-top: 25px; }

@media (max-width: 700px) {
  .header { align-items: flex-start; flex-direction: column; gap: 12px; }
  .actions { width: 100%; }
  .actions .button { flex: 1; padding-inline: 10px; font-size: 12px; }
  .frames { justify-content: flex-start; }
  .frame-button { flex-basis: 48px; width: 48px; height: 48px; }
  .workspace { place-content: start center; padding-top: 24px; }
  .drawing-tools { width: 100%; max-width: 500px; justify-content: center; flex-wrap: wrap; }
  .tool-button { flex: 1 1 auto; }
  .page-navigation { flex-wrap: wrap; }
}

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