@font-face {
  font-family: "Increase";
  src: url("fonts/Increase-Regular.woff2") format("woff2"),
       url("fonts/Increase-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Increase";
  src: url("fonts/Increase-Bold.woff2") format("woff2"),
       url("fonts/Increase-Bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #14161a;
  --paper: #ffffff;
  --purple: #7c3aed;
  --tool-bg: #f1f1f4;
  --tool-bg-active: var(--ink);
  --tool-ink-active: #ffffff;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--paper);
  color: var(--ink);
  font-family: "Increase", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: fixed;
  inset: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#app.app-locked .topbar,
#app.app-locked .toolbar {
  pointer-events: none;
}

/* ---------- topbar ---------- */
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + var(--safe-t)) 18px 0;
  pointer-events: none;
}

.profile-btn {
  appearance: none;
  border: 2.25px solid var(--ink);
  background: transparent;
  height: 44px;
  padding: 0 18px 0 4px;
  margin: 0;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 9px;
  pointer-events: auto;
  cursor: pointer;
}
.profile-photo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 1.5px solid rgba(20, 22, 26, 0.15);
}
.profile-name {
  font-family: "Increase", sans-serif;
  font-size: clamp(15px, 3.6vw, 19px);
  letter-spacing: -0.01em;
  color: var(--ink);
  user-select: none;
}

.icon-btn {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2.25px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: "Increase", sans-serif;
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ---------- canvas ---------- */
#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}

.hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 1;
}
.hint p {
  margin: 0;
  text-align: center;
  font-size: clamp(16px, 4vw, 22px);
  line-height: 1.4;
  color: #c9c9d1;
  font-weight: 400;
  transition: opacity 0.35s ease;
}
.hint.hidden { opacity: 0; }

/* ---------- text editor overlay ---------- */
.text-editor {
  position: absolute;
  z-index: 6;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  transform: translate(-0.45em, -0.3em);
}
.text-editor .text-input {
  display: inline-block;
  min-width: 1.1em;
  max-width: min(78vw, 600px);
  outline: none;
  background: var(--ink);
  border-radius: 0.32em;
  font-family: "Increase", sans-serif;
  font-weight: 700;
  line-height: 1.2;
  padding: 0.3em 0.45em;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
  color: #fff;
  caret-color: #fff;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
}
.text-done {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--purple);
  color: #fff;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-bottom: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ---------- text selection (edit/move affordance) ---------- */
.text-selection {
  position: absolute;
  z-index: 4;
  border: 2px dashed rgba(20, 22, 26, 0.5);
  border-radius: 0.5em;
  pointer-events: none;
}
.text-selection-actions {
  position: absolute;
  z-index: 6;
  display: flex;
  gap: 6px;
  transform: translate(-4px, -4px);
}
.text-action-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--purple);
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}
.text-action-btn.delete { background: #e2483a; }

/* ---------- vertical text size slider ---------- */
.text-size-slider-wrap {
  position: fixed;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 7;
  width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  border-radius: 20px;
  padding: 12px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
.text-size-label {
  font-family: "Increase", sans-serif;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  user-select: none;
}
.text-size-label-max { font-size: 21px; }
.text-size-label-min { font-size: 11px; }
.text-size-slider-track {
  width: 34px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.text-size-slider {
  appearance: none;
  -webkit-appearance: none;
  width: 200px;
  height: 34px;
  transform: rotate(-90deg);
  background: transparent;
  margin: 0;
  cursor: pointer;
}
.text-size-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(20, 22, 26, 0.15);
}
.text-size-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--purple);
  border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  margin-top: -11px;
  cursor: pointer;
}
.text-size-slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(20, 22, 26, 0.15);
}
.text-size-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--purple);
  border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

/* ---------- toolbar ---------- */
.toolbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 16px calc(16px + var(--safe-b));
  pointer-events: none;
}

.tools {
  display: flex;
  gap: 8px;
  pointer-events: auto;
  background: var(--tool-bg);
  padding: 6px;
  border-radius: 20px;
}

.tool-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: "Increase", sans-serif;
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.tool-btn svg { width: 20px; height: 20px; }
.tool-btn:active { transform: scale(0.92); }
.tool-btn.active {
  background: var(--tool-bg-active);
  color: var(--tool-ink-active);
}
.tool-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}
.tool-btn:disabled:active { transform: none; }
#clearBtn:hover { color: #e2483a; }

.tool-label {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  padding: 6px 10px;
  border-radius: 10px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.tool-label.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
@media (hover: hover) {
  .tool-btn:hover .tool-label {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.send-wrap {
  position: relative;
  pointer-events: auto;
}

.send-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 20px;
  border-radius: 24px;
  border: none;
  background: var(--ink);
  color: #fff;
  font-family: "Increase", sans-serif;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.2s ease;
}
.send-btn:active { transform: scale(0.96); }
.send-btn svg { width: 17px; height: 17px; }
.send-btn.confirm {
  background: linear-gradient(115deg, #e500ff, #ffe500);
  color: #14161a;
}
.send-btn.sending { opacity: 0.65; pointer-events: none; }

.tooltip {
  position: absolute;
  bottom: calc(100% + 14px);
  right: 0;
  width: max-content;
  max-width: min(78vw, 340px);
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(115deg, #e500ff, #ffe500);
  color: #14161a;
  font-size: 13.5px;
  line-height: 1.5;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
@media (hover: hover) {
  .send-wrap:hover .tooltip {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- info overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(20, 22, 26, 0.4);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.overlay-card {
  position: relative;
  width: min(380px, 100%);
  background: var(--paper);
  border-radius: 24px;
  padding: 28px 26px 26px;
}
.overlay-card h2 {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 700;
}
.overlay-card ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 15px;
  line-height: 1.5;
  color: #3a3d44;
}
.overlay-card .icon-btn {
  position: absolute;
  top: 16px;
  right: 16px;
}

.info-card {
  background: var(--purple);
  color: #fff;
}
.info-card h2 {
  font-family: "Increase", sans-serif;
}
.info-card ul {
  color: rgba(255, 255, 255, 0.92);
}
.info-card .icon-btn {
  border-color: #fff;
  color: #fff;
}
.info-legal {
  margin: 20px 0 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}
.info-legal a {
  color: inherit;
}
.info-intro {
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.92);
}

/* ---------- about overlay ---------- */
.about-overlay {
  background: #7c3aed;
  padding: 0;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow-y: auto;
}
@media (min-width: 720px) {
  .about-overlay {
    inset: 0 10% 10% 0;
    width: 90%;
    height: 90%;
    border-radius: 0 0 32px 0;
    backdrop-filter: none;
  }
}
.about-card {
  width: 100%;
  margin: 0;
  background: transparent;
  border-radius: 0;
  padding: calc(64px + var(--safe-t)) 28px calc(84px + var(--safe-b)) 28px;
  color: #fff;
  text-align: left;
}
@media (min-width: 720px) {
  .about-card { padding: 60px 180px 60px 60px; }
}
.about-card .icon-btn {
  position: fixed;
  top: calc(16px + var(--safe-t));
  right: 18px;
  border-color: #fff;
  color: #fff;
}
@media (min-width: 720px) {
  .about-card .icon-btn { right: calc(10% + 18px); }
}
.about-card h1 {
  margin: 0 0 32px;
  font-family: "Increase", sans-serif;
  font-weight: 700;
  font-size: clamp(48px, 12vw, 100px);
  line-height: 1.0;
  letter-spacing: -0.015em;
}
.about-body {
  margin: 0 0 40px;
}
.about-body p {
  margin: 0 0 24px;
  font-size: clamp(18px, 3.8vw, 24px);
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.94);
}
.about-body strong {
  color: #fff;
}
.about-inline-link {
  color: #fff;
  font-weight: 400;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  white-space: nowrap;
}
.about-cta {
  margin: 0 0 10px;
  font-size: clamp(20px, 4.6vw, 28px);
  font-weight: 400;
}
.about-cta-link {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  font-family: "Increase", sans-serif;
  font-weight: 400;
  font-size: inherit;
  color: #fff;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  white-space: nowrap;
  cursor: pointer;
}
.about-fallback {
  margin: 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.75);
}
.about-fallback a {
  color: #fff;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(110px + var(--safe-b));
  transform: translateX(-50%) translateY(10px);
  z-index: 20;
  background: var(--ink);
  color: #fff;
  padding: 13px 20px;
  border-radius: 18px;
  font-size: 14.5px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 480px) {
  .tools { gap: 4px; padding: 5px; }
  .tool-btn { width: 40px; height: 40px; border-radius: 12px; }
  .send-btn { height: 44px; padding: 0 16px; font-size: 15px; }
  .profile-btn { height: 50px; }
  .profile-photo { width: 38px; height: 38px; }
  .profile-name { font-size: 18px; }
  .icon-btn { width: 50px; height: 50px; font-size: 19px; }
}
