@font-face {
  font-family: "Kiwi Soda";
  src: url("/fonts/KiwiSoda.ttf") format("truetype");
  font-display: block;
  font-style: normal;
  font-weight: 400;
}

:root {
  color-scheme: light;
  --chantilly: #f8bacf;
  --cornflower-lilac: #ffadad;
  --flesh-coral: #ffc29e;
  --flesh-gold: #ffd6a3;
  --mauve: #d4a8ff;
  --ink: #3f3046;
  --muted: #76647b;
  --paper: #fff9fc;
  --cream: #fff1f6;
  --peach: var(--flesh-coral);
  --peach-dark: #d97876;
  --line: rgba(63, 48, 70, 0.14);
  --shadow: 0 18px 50px rgba(106, 72, 118, 0.16);
  --font-playful: "Kiwi Soda", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --font-ui: Inter, ui-rounded, "SF Pro Rounded", "SF Pro Display", system-ui, sans-serif;
  font-family: var(--font-ui);
  background: var(--cream);
  color: var(--ink);
}

* { box-sizing: border-box; }

.font-loading .brand,
.font-loading .brand-mark,
.font-loading h1,
.font-loading h2 { visibility: hidden; }

html {
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 86% 3%, rgba(212, 168, 255, 0.58), transparent 29rem),
    radial-gradient(circle at 6% 36%, rgba(255, 194, 158, 0.42), transparent 25rem),
    var(--cream);
  -webkit-user-select: none;
  user-select: none;
}

button, input { font: inherit; }
button, label, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
input, textarea { -webkit-user-select: text; user-select: text; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(30px, env(safe-area-inset-bottom));
}

.topbar, .composer-heading, .friend-row, .dialog-actions, .tool-group, .toolbar-actions, .brush-options {
  display: flex;
  align-items: center;
}

.topbar { justify-content: space-between; margin-bottom: 30px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; font-family: var(--font-playful); font-size: 25px; font-weight: 400; line-height: 1; text-decoration: none; }
.brand-mark, .avatar { display: grid; place-items: center; border-radius: 50%; }
.brand-mark { width: 32px; height: 32px; background: var(--mauve); color: var(--ink); font-family: var(--font-playful); font-size: 20px; font-style: normal; }
.avatar { width: 38px; height: 38px; border: 1px solid var(--line); background: rgba(248,186,207,.58); font-weight: 700; }

.intro { margin-bottom: 26px; }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.friend-row { gap: 10px; overflow-x: auto; padding: 2px 1px 6px; scrollbar-width: none; }
.friend-row::-webkit-scrollbar { display: none; }
.friend-chip { display: flex; align-items: center; flex: 0 0 auto; gap: 8px; padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,249,252,.68); }
.friend-chip.is-active { border-color: var(--ink); background: var(--paper); box-shadow: 0 5px 18px rgba(57,43,34,.09); }
.friend-avatar { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 50%; background: var(--peach); font-size: 13px; font-weight: 800; }
.friend-avatar--mint { background: var(--mauve); }
.friend-chip--add { border-style: dashed; color: var(--muted); }

.composer { padding: 22px; border: 1px solid rgba(255,255,255,.78); border-radius: 30px; background: rgba(255,249,252,.88); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.composer-heading { align-items: flex-start; justify-content: space-between; gap: 14px; }
h1, h2 { font-family: var(--font-playful); font-synthesis: none; font-weight: 400; }
h1 { max-width: 300px; margin: 0; font-size: clamp(31px, 8vw, 42px); line-height: 1.04; letter-spacing: 0; }
.insert-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 20px 0 14px; }
.photo-action { display: flex; min-width: 0; min-height: 44px; align-items: center; justify-content: center; gap: 8px; margin: 0; padding: 0 10px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); color: var(--ink); font-size: 13px; font-weight: 800; cursor: pointer; }
.photo-action:active { background: var(--chantilly); transform: scale(.99); }
.photo-action[data-tool="text"].is-active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.photo-action:disabled, .tool:disabled, .icon-button:disabled, .brush-option:disabled { cursor: default; opacity: .42; }

.sent-today-status { display: flex; width: fit-content; align-items: center; gap: 7px; margin: 18px 0 14px; padding: 7px 11px; border-radius: 999px; background: rgba(212,168,255,.3); color: var(--ink); font-size: 12px; }
.sent-today-status[hidden] { display: none; }
.sent-today-status span { display: grid; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: white; font-size: 12px; place-items: center; }
.composer.is-sent .insert-actions { display: none; }
.composer.is-sent .canvas-card { border-color: var(--ink); box-shadow: 0 0 0 5px rgba(212,168,255,.22); }
.composer.is-sent #editor-canvas { cursor: default; }
.composer.is-sent .toolbar { display: none; }
.composer.is-sent .send-button:disabled { opacity: 1; background: rgba(63,48,70,.1); color: var(--ink); box-shadow: none; }
.composer.is-sent .send-note { margin-top: 12px; font-size: 12px; line-height: 1.45; }

.canvas-card { position: relative; overflow: hidden; width: 100%; aspect-ratio: 1; border: 5px solid #3d3a36; border-radius: 20px; background: #f4f2e8; box-shadow: inset 0 0 0 1px #aaa49a; touch-action: none; }
#editor-canvas { display: block; width: 100%; height: 100%; background: #fff; image-rendering: pixelated; cursor: crosshair; }
.canvas-hint { position: absolute; inset: 50% auto auto 50%; translate: -50% -50%; width: max-content; max-width: 80%; color: #a79d94; font-family: var(--font-ui); font-size: 15px; font-style: normal; pointer-events: none; }
.canvas-hint.is-hidden { display: none; }

.toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-top: 12px; }
.tool-group, .toolbar-actions { gap: 7px; }
.tool, .icon-button { display: flex; align-items: center; justify-content: center; min-height: 38px; border: 1px solid var(--line); background: var(--paper); }
.tool { min-height: 44px; gap: 6px; padding: 0 12px; border-radius: 12px; font-size: 12px; font-weight: 700; }
.tool.is-active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.tool-icon { width: 18px; height: 18px; stroke-width: 1.8; }
.tool-letter { display: grid; width: 18px; height: 18px; font-family: var(--font-playful); font-size: 20px; font-weight: 400; line-height: 1; place-items: center; }
.icon-button { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; border-radius: 50%; color: var(--ink); cursor: pointer; }
.icon-button:active { background: var(--chantilly); transform: scale(.96); }
.ui-icon { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.brush-size-control { grid-column: 1 / -1; min-width: 0; margin: 0; padding: 0; border: 0; }
.brush-size-control legend { margin-bottom: 7px; padding: 0; color: var(--muted); font-size: 11px; font-weight: 800; }
.brush-options { gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 14px; background: rgba(63,48,70,.035); }
.brush-option { display: flex; min-width: 0; min-height: 44px; flex: 1; align-items: center; justify-content: center; gap: 7px; padding: 0 8px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 800; cursor: pointer; }
.brush-option.is-active { border-color: rgba(63,48,70,.18); background: rgba(212,168,255,.3); color: var(--ink); box-shadow: none; }
.brush-preview { display: block; flex: 0 0 auto; border-radius: 50%; background: currentColor; }
.brush-preview--small { width: 4px; height: 4px; }
.brush-preview--medium { width: 8px; height: 8px; }
.brush-preview--large { width: 14px; height: 14px; }
.toolbar.is-text-mode .brush-size-control { display: none; }

.send-button, .secondary-button { min-height: 52px; border-radius: 16px; font-weight: 800; }
.send-button { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 22px; padding: 0 18px; border: 0; background: var(--ink); color: var(--paper); box-shadow: 0 10px 24px rgba(63,48,70,.22); }
.send-button:disabled { opacity: .3; }
.send-note { margin: 9px 0 0; color: var(--muted); font-size: 11px; text-align: center; }

dialog { width: min(calc(100% - 36px), 440px); padding: 24px; border: 0; border-radius: 24px; color: var(--ink); box-shadow: 0 30px 90px rgba(30,24,20,.35); }
dialog::backdrop { background: rgba(63,48,70,.44); backdrop-filter: blur(4px); }
dialog h2 { margin: 0; font-size: 30px; line-height: 1.08; }
dialog h2:focus { outline: none; }
dialog p:not(.eyebrow) { color: var(--muted); line-height: 1.5; }
.dialog-actions { gap: 10px; margin-top: 22px; }
.dialog-actions .send-button { margin: 0; justify-content: center; }
.invitation-actions { align-items: stretch; }
.invitation-actions > button { flex: 1; }
.secondary-button { padding: 0 16px; border: 1px solid var(--line); background: white; }

.profile-panel { position: relative; }
.profile-panel h2 { margin: 0 0 10px; font-size: 30px; line-height: 1.08; }
.profile-panel p { color: var(--muted); line-height: 1.5; }
.dialog-close { position: absolute; top: -12px; right: -12px; display: grid; border-color: rgba(63,48,70,.1); background: var(--chantilly); box-shadow: 0 6px 16px rgba(106,72,118,.14); place-items: center; }
#profile-dialog .profile-panel > .eyebrow { display: flex; align-items: center; min-height: 32px; margin-bottom: 12px; padding-right: 48px; }
#friend-dialog .profile-panel > .eyebrow { display: flex; align-items: center; min-height: 32px; margin-bottom: 12px; padding-right: 48px; }
.field-label { display: block; margin: 20px 0 7px; font-size: 12px; font-weight: 800; }
.text-input { width: 100%; min-height: 50px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px; background: white; color: var(--ink); font-size: 16px; outline: none; }
.text-input:focus { border-color: #9b6cc7; box-shadow: 0 0 0 3px rgba(212,168,255,.35); }
.text-content-input { min-height: 112px; padding: 13px 14px; line-height: 1.4; resize: none; transition: text-align .12s ease; }
.text-color-control, .text-format-control { margin: 18px 0 0; padding: 0; border: 0; }
.text-color-control legend, .text-format-control legend { margin-bottom: 8px; padding: 0; font-size: 12px; font-weight: 800; }
.text-color-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.text-color-option { display: flex; min-height: 52px; align-items: center; gap: 9px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 14px; background: white; color: var(--muted); font-weight: 800; }
.text-color-option.is-active { border-color: var(--ink); color: var(--ink); box-shadow: 0 0 0 2px rgba(212,168,255,.35); }
.text-color-swatch { display: grid; width: 34px; height: 34px; border: 1px solid rgba(63,48,70,.2); border-radius: 50%; background: #d9cedd; font-family: var(--font-playful); font-size: 21px; line-height: 1; paint-order: stroke fill; place-items: center; }
.text-color-swatch--black { color: #000; }
.text-color-swatch--white { color: #fff; }
.text-dialog.has-text-outline .text-color-swatch--black { -webkit-text-stroke: 2px #fff; }
.text-dialog.has-text-outline .text-color-swatch--white { -webkit-text-stroke: 2px #000; }
.text-align-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 3px; border: 1px solid var(--line); border-radius: 14px; background: rgba(63,48,70,.035); }
.text-align-option { display: grid; min-width: 0; min-height: 48px; gap: 1px; padding: 4px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 800; place-items: center; }
.text-align-icon { width: 24px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.text-align-option.is-active { border-color: rgba(63,48,70,.18); background: rgba(212,168,255,.3); color: var(--ink); }
.text-outline-toggle { display: grid; grid-template-columns: minmax(0, 1fr) 42px; width: 100%; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 14px; background: white; color: var(--ink); text-align: left; }
.text-outline-toggle strong, .text-outline-toggle small { display: block; }
.text-outline-toggle strong { font-size: 13px; }
.text-outline-toggle small { margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.25; }
.switch { position: relative; width: 40px; height: 24px; border-radius: 999px; background: rgba(63,48,70,.18); transition: background .16s ease; }
.switch span { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: white; box-shadow: 0 1px 4px rgba(63,48,70,.25); transition: translate .16s ease; }
.text-outline-toggle.is-active .switch { background: var(--ink); }
.text-outline-toggle.is-active .switch span { translate: 16px 0; }
.text-dialog .field-label { margin-top: 17px; }
.text-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.profile-panel .text-dialog-heading h2 { margin: 0; white-space: nowrap; }
.text-header-delete { display: grid; width: 34px; height: 34px; flex: 0 0 34px; padding: 0; border: 1px solid rgba(171,53,74,.22); border-radius: 50%; background: white; color: #a52f45; place-items: center; }
.text-header-delete[hidden] { display: none; }
.text-header-delete .ui-icon { width: 16px; height: 16px; }
.text-dialog .text-gesture-hint { margin: 13px 0 0; font-size: 12px; }
.text-dialog .form-message { margin-top: 7px; }
.text-dialog-actions { flex-wrap: wrap; }
.text-dialog-actions > button { min-height: 48px; flex: 1; }
.text-dialog-actions .send-button { width: auto; flex: 1; }
.form-message { min-height: 22px; margin-bottom: 0; font-size: 13px; }
.profile-identity { display: grid; grid-template-columns: 58px minmax(0,1fr) 44px; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 20px; background: white; }
.profile-avatar { display: grid; width: 58px; height: 58px; border-radius: 50%; background: var(--peach); font-size: 22px; font-weight: 800; place-items: center; }
.profile-identity-copy { min-width: 0; }
.profile-panel .profile-identity-copy h2 { overflow: hidden; margin: 0 0 4px; font-size: 24px; text-overflow: ellipsis; white-space: nowrap; }
.profile-panel .profile-identity-copy p { overflow: hidden; margin: 0; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.profile-edit-button { display: grid; background: var(--chantilly); place-items: center; }
.profile-edit-actions { align-items: stretch; }
.profile-edit-actions > button { flex: 1; }
.logout-button { width: 100%; margin-top: 16px; }
.profile-save-button { margin-top: 12px; }
.share-button { width: 100%; margin-top: 10px; }

.crop-dialog { padding: 18px; }
.crop-dialog h2 { margin-bottom: 18px; }
#apply-crop-button { white-space: nowrap; }
.crop-viewport { position: relative; overflow: hidden; width: 100%; aspect-ratio: 1; border-radius: 18px; background: #ddd; touch-action: none; }
#crop-canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; touch-action: none; }
.crop-frame { position: absolute; inset: 0; border: 2px solid rgba(255,255,255,.88); border-radius: 18px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.16); pointer-events: none; }
.rotation-control { display: grid; grid-template-columns: 28px 1fr 28px; align-items: center; gap: 8px; margin-top: 15px; color: var(--muted); }
.rotation-icon { width: 22px; height: 22px; justify-self: center; stroke-width: 1.8; }
.rotation-slider-wrap { position: relative; display: flex; min-width: 0; align-items: center; }
.rotation-slider-wrap input { position: relative; z-index: 1; width: 100%; min-height: 44px; margin: 0; accent-color: var(--ink); }
.rotation-zero-mark { position: absolute; z-index: 2; top: 50%; left: 50%; width: 2px; height: 10px; border-radius: 2px; background: var(--muted); opacity: .72; translate: -50% -50%; pointer-events: none; }
.photo-adjustment { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; font-weight: 800; }
.adjustment-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.adjustment-row input { width: 100%; min-height: 44px; accent-color: var(--ink); }
.adjustment-icon { width: 22px; height: 22px; color: var(--muted); stroke-width: 1.8; }

.confirmation-page { display: grid; min-height: 100dvh; padding: 24px; place-items: center; }
.confirmation-card { width: min(100%, 440px); padding: 30px; border-radius: 28px; background: var(--paper); box-shadow: var(--shadow); text-align: center; }
.confirmation-card .brand-mark { margin: 0 auto 22px; }
.confirmation-card h1 { max-width: none; font-size: 32px; }
.confirmation-link { text-decoration: none; }

@media (min-width: 700px) {
  .app-shell { padding-top: 34px; }
}

@media (max-width: 390px) {
  .toolbar { grid-template-columns: 1fr; }
  .tool-group { display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar-actions { grid-row: 3; justify-content: flex-end; }
}

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