:root {
  --ink: #22324A;
  --muted: #5A6372;
  --ground: #EFEBE4;
  --card: #FFFFFF;
  --line: #DDD6CB;
  --line-strong: #CFC7BA;
  --soft: #F8F6F2;
  --chip: #E6E0D6;
  --accent: #C0157F;
  --accent-hover: #9A0F66;
  --danger: #B42318;
  --cork-ink: #3A2614;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: #C49A6C;
  background-image: radial-gradient(rgba(90,55,25,.22) 1.2px, transparent 1.4px), radial-gradient(rgba(255,240,215,.18) 1px, transparent 1.2px);
  background-size: 14px 14px, 22px 22px;
  background-position: 0 0, 7px 9px;
  color: var(--ink);
  font-family: 'Open Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
button, input { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header: conference gradient band over the cork board */
.top { color: #FFFFFF; background: linear-gradient(90deg, #0FA58E, #0A8FCC 25%, #4F63B8 45%, #B02BA6 62%, #EC1C8E 80%, #F06A84); box-shadow: 0 4px 14px rgba(40,20,0,.25); }
.top-inner { max-width: 1200px; margin: 0 auto; padding: 18px 24px; display: flex; flex-direction: column; gap: 2px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.brand { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }

/* Layout */
.main { max-width: 1200px; margin: 0 auto; padding: 40px 24px 64px; display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; }
.card {
  flex: 999 1 560px; min-width: 0;
  background: var(--card); border: 0; border-radius: 16px; box-shadow: 0 20px 50px rgba(40,20,0,.3);
  padding: 32px; display: flex; flex-direction: column; gap: 24px; margin: 0;
}
.intro h1 { margin: 0 0 6px; font-size: 32px; line-height: 1.15; letter-spacing: -0.02em; }
.intro p { margin: 0; color: var(--muted); }

.field { position: relative; display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.label { font-size: 14px; font-weight: 500; padding: 0; }
legend.label { margin-bottom: 10px; }

/* Editor */
.editor-box { border: 1px solid var(--line-strong); border-radius: 12px; background: var(--card); }
.editor-box:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(34,50,74,.12); }
.toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border-bottom: 1px solid #E6E0D6; background: var(--soft); border-radius: 12px 12px 0 0; }
.tb {
  min-width: 44px; height: 44px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 17px;
}
.tb:hover { background: #EEE9E1; }
.tb[aria-pressed="true"], .tb[aria-expanded="true"] { background: var(--chip); }
.tb:focus-visible { outline: 3px solid var(--ink); outline-offset: 1px; }
.tb-b { font-weight: 700; }
.tb-i { font-family: Georgia, serif; font-style: italic; font-size: 18px; }
.tb-u { text-decoration: underline; }
.tb-s { text-decoration: line-through; }
.tb-emoji { font-size: 15px; font-weight: 500; }
.sep { width: 1px; background: var(--line); margin: 6px 4px; }

.editor {
  min-height: 180px; max-height: 360px; overflow-y: auto;
  padding: 18px; font-size: 17px; line-height: 1.6; outline: none; word-wrap: break-word;
}
.editor.empty::before { content: attr(data-placeholder); color: #8A8F98; pointer-events: none; position: absolute; }
.editor p, .editor div { margin: 0; }
.editor ul, .editor ol { margin: 4px 0; padding-left: 24px; }
.editor a { color: #1F5FBF; }
.counter { display: flex; justify-content: flex-end; padding: 0 14px 10px; font-size: 13px; color: var(--muted); }
.counter.over { color: var(--danger); font-weight: 700; }

/* Emoji picker */
.picker {
  position: absolute; top: 92px; right: 12px; width: 340px; z-index: 5;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
  box-shadow: 0 16px 40px rgba(34,50,74,.18); display: flex; flex-direction: column; gap: 10px;
}
.picker[hidden] { display: none; }
.picker input { height: 42px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 16px; }
.cats { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.cat { flex: none; padding: 7px 11px; border: 0; border-radius: 999px; background: #F1EDE6; font-size: 13px; font-weight: 500; cursor: pointer; }
.cat[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; }
.grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; max-height: 220px; overflow-y: auto; }
.em { height: 40px; border: 0; border-radius: 8px; background: transparent; font-size: 23px; cursor: pointer; padding: 0; }
.em:hover, .em:focus-visible { background: #F1EDE6; outline: none; }
.none { grid-column: 1 / -1; margin: 8px 0; color: var(--muted); font-size: 14px; text-align: center; }

/* Colours */
.swatches { display: flex; flex-wrap: wrap; gap: 14px; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px #FFFFFF, 0 0 0 5px var(--ink); }
.swatch:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }

/* Fonts */
.fonts { display: flex; flex-wrap: wrap; gap: 10px; }
.font-opt {
  min-height: 48px; padding: 6px 18px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--ink); cursor: pointer; font-size: calc(21px * var(--fs, 1)); line-height: 1.1;
}
.font-opt:hover { background: var(--soft); }
.font-opt[aria-pressed="true"] { border: 2px solid var(--ink); background: #F1EDE6; padding: 5px 17px; }
.font-opt:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* Messages + buttons */
.msg { margin: 0; color: var(--danger); font-size: 15px; font-weight: 500; }
.msg:empty { display: none; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; padding-top: 8px; border-top: 1px solid #E6E0D6; }
.btn { height: 48px; padding: 0 22px; border-radius: 10px; font-size: 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.ghost { border: 1px solid var(--line-strong); background: var(--card); font-weight: 500; }
.ghost:hover { background: var(--soft); }
.primary { border: 0; background: var(--accent); color: #FFFFFF; font-weight: 700; padding: 0 24px; }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.primary:disabled { background: #C9B8AE; cursor: not-allowed; }

/* Preview */
.preview-col { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.preview-label { align-self: flex-start; font-size: 14px; font-weight: 700; color: var(--cork-ink); }
.note-preview {
  position: relative; width: 100%; max-width: 300px; padding: 34px 24px 20px;
  transform: rotate(-2deg); box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 12px 24px rgba(0,0,0,.14);
  color: #FFFFFF;
}
.tape { position: absolute; top: -12px; left: 50%; margin-left: -42px; width: 84px; height: 26px; background: rgba(255,255,255,.6); border: 1px solid rgba(0,0,0,.05); transform: rotate(3deg); }
.hand { font-size: calc(25px * var(--fs, 1)); line-height: 1.25; color: #FFFFFF; word-wrap: break-word; text-shadow: 0 1px 2px rgba(0,0,0,.18); }
.hand:empty::before { content: 'Your moment will appear here…'; opacity: .7; }
.hand p, .hand div { margin: 0; }
.hand ul, .hand ol { margin: 2px 0; padding-left: 22px; }
.hand a { color: inherit; }
.meta { display: flex; justify-content: space-between; margin-top: 18px; font: 600 13px 'Open Sans', system-ui, sans-serif; color: rgba(255,255,255,.9); }
.preview-hint { margin: 8px 0 0; font-size: 14px; font-weight: 700; color: var(--cork-ink); text-align: center; max-width: 280px; }

/* Powered by */
.powered {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: fit-content; margin: 0 auto 32px; padding: 8px 16px; border-radius: 999px; background: #FFFFFF;
  box-shadow: 0 4px 12px rgba(40,20,0,.25); font-size: 13px; font-weight: 600; color: #2B2860;
}
.powered img { display: block; width: 96px; height: auto; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #1B1430; color: #FFFFFF; padding: 14px 22px; border-radius: 12px; font-weight: 500;
  box-shadow: 0 12px 30px rgba(0,0,0,.25); z-index: 50; animation: toast-in .25s ease-out;
}
.toast[hidden] { display: none; }
@keyframes toast-in { from { opacity: 0; translate: 0 12px; } to { opacity: 1; translate: 0 0; } }

/* Phones */
@media (max-width: 600px) {
  .top-inner { padding: 16px 16px 0; }
  .main { padding: 20px 12px 40px; gap: 28px; }
  .card { padding: 20px 16px; border-radius: 14px; gap: 20px; }
  .intro h1 { font-size: 26px; }
  .editor { min-height: 150px; }
  .picker { position: static; width: auto; box-shadow: none; margin-top: 4px; }
  .grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .em { height: 44px; }
  .actions > .btn { flex: 1 1 130px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
