:root {
  color-scheme: light;
  --ink: #291e49;
  --muted: #605376;
  --violet: #633bb3;
  --deep-violet: #492785;
  --line: #ddd1f0;
  --surface: #fffdff;
  --soft: #f6efff;
  --shadow: 0 14px 38px #4a2a7c14;
}

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

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 9% 0, #fce5f5 0%, transparent 42%),
    radial-gradient(ellipse at 93% 16%, #e0e1ff 0%, transparent 42%),
    #f5efff;
  font: 16px/1.5 "Malgun Gothic", system-ui, sans-serif;
}

button, input, select, textarea { font: inherit; }
button {
  cursor: pointer;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 13px;
  font-size: .875rem;
  font-weight: 750;
}
button:hover { background: var(--soft); border-color: #ab91d5; }
button[aria-pressed=true] { background: #e9dbfc; border-color: #b99cde; color: var(--deep-violet); }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 3px; }

.primary {
  background: linear-gradient(135deg, #6d42bc, #784499);
  color: #fff;
  border-color: #6639a0;
}
.primary:hover { background: linear-gradient(135deg, #5e36a9, #663485); border-color: #56308b; }
.secondary { background: var(--soft); }
.full { width: 100%; min-height: 38px; margin-top: 8px; }

header {
  min-height: 67px;
  padding: 8px max(24px, calc((100% - 1270px) / 2));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #fdf9ff;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 900; letter-spacing: .075em; white-space: nowrap; }
.brand span {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-right: 6px;
  border: 1px solid #d0b9ed;
  border-radius: 50%;
  color: #6542a4;
  background: linear-gradient(145deg, #ffcde9, #ded6ff);
}
.brand small { color: var(--muted); font-size: .72rem; }
.exports { display: flex; align-items: center; gap: 7px; white-space: nowrap; }

main { max-width: 1318px; margin: auto; padding: 24px 24px 48px; }
.intro {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: center;
  min-height: 145px;
  margin-bottom: 18px;
  padding: 20px 34px;
  border: 1px solid #d7c4ed;
  border-radius: 22px;
  background: linear-gradient(100deg, #fff0f9 4%, #ebe0ff 56%, #baabf0);
  box-shadow: var(--shadow);
}
.intro::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 0 0 43%;
  background: url("character-background.png") right 36% / cover no-repeat;
  mask-image: linear-gradient(to right, transparent, #000 51%);
}
.intro-copy { max-width: 59%; }
h1 { margin: 0 0 6px; font-size: clamp(1.65rem, 3.2vw, 2.65rem); line-height: 1.2; letter-spacing: -.055em; }
h2 { margin: 0 0 14px; font-size: 1.125rem; letter-spacing: -.025em; }
p { margin: 0; color: var(--muted); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 362px); align-items: start; gap: 18px; }
.board, .panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.bar, .board-actions { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.bar { padding: 11px 14px; }
.bar strong { white-space: nowrap; }
.bar span { color: var(--muted); font-size: .8125rem; }
.board-actions { justify-content: flex-end; flex-wrap: wrap; }
.board-actions button, .foot button { padding: 5px 9px; white-space: nowrap; }
.stage {
  padding: 15px;
  border-block: 1px solid #392853;
  background: radial-gradient(#6e5a91 1px, transparent 1px) #2a2040;
  background-size: 15px 15px;
}
canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 7px;
  background: #231b39;
  touch-action: none;
  cursor: grab;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 3px;
  padding: 8px;
  background: #f8f1ff;
  border-bottom: 1px solid var(--line);
}
.tabs button { padding-inline: 2px; background: transparent; border-color: transparent; white-space: nowrap; }
.tabs button:hover { background: #efe4fb; }
.tabs button[aria-pressed=true] { background: #e6d9fb; border-color: #c9afea; }
.panel section { padding: 15px; }
.panel label, dialog label { display: block; margin: 11px 0 5px; font-size: .875rem; font-weight: 700; }
.panel label output { margin-left: 4px; color: var(--muted); }
.panel input:not([type=file], [type=checkbox]), textarea, select, #fontSearch, #presetName {
  width: 100%;
  padding: 7px 9px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .9rem;
}
textarea { resize: vertical; }
.panel input[type=color] { height: 36px; padding: 4px; cursor: pointer; }
.panel input[type=range] { height: 30px; padding: 0; }
input[type=range], input[type=checkbox] { accent-color: var(--violet); }
.panel .check-label { display: flex; align-items: center; gap: 8px; }
.panel .check-label input { margin: 0; }

.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.upload { padding: 13px; border: 1px dashed #ad96cc; border-radius: 10px; background: var(--soft); }
.upload input { display: block; width: 100%; margin-top: 8px; font-size: .8125rem; }
.frames { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.note { margin-top: 7px; font-size: .8125rem; }
.idea { display: block; width: 100%; margin-top: 6px; text-align: left; }
.text-format { margin-top: 7px; border: 1px solid var(--line); border-radius: 10px; background: #faf5ff; }
.text-tools { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; padding: 4px; }
.text-tools button {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-height: 46px;
  padding: 3px 1px;
  background: transparent;
  border-color: transparent;
  font-size: .8125rem;
  white-space: nowrap;
}
.text-tools button:hover { background: #efe4fb; }
.text-tools button[aria-expanded=true] { background: #e9dbfc; border-color: #c9afea; color: var(--deep-violet); }
.tool-icon { color: var(--violet); font: 800 17px/1 system-ui, sans-serif; }
.color-icon { border-bottom: 3px solid var(--swatch, #fff); box-shadow: 0 1px 0 #826e9e; }
.outline-icon { color: transparent; -webkit-text-stroke: 1px var(--violet); }
.font-icon { font-family: Georgia, serif; }
.text-tool-panel { border-top: 1px solid var(--line); padding: 0 10px 10px; }
.tool-grid { padding-top: 10px; }
.date-input-row { display: flex; gap: 6px; }
.date-input-row input { flex: 1; min-width: 0; }
.date-input-row button { white-space: nowrap; }

dialog {
  max-height: calc(100dvh - 24px);
  padding: 18px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #cdb5e9;
  border-radius: 18px;
  box-shadow: 0 22px 70px #29174a40;
}
dialog::backdrop { background: #32204c98; }
#fontDialog { width: min(720px, calc(100% - 24px)); }
#presetDialog { width: min(470px, calc(100% - 24px)); }
.font-head, .font-footer, .font-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.font-head, .font-footer { justify-content: space-between; }
.font-head h2 { margin: 0; }
.font-actions { margin-top: 13px; }
.font-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
  align-content: start;
  gap: 8px;
  min-height: 86px;
  max-height: 43dvh;
  overflow: auto;
  padding: 4px;
  margin: 9px -4px;
}
.font-card { display: grid; align-content: start; gap: 6px; min-width: 0; text-align: left; overflow-wrap: anywhere; }
.font-label { color: var(--muted); font-size: .8125rem; }
.font-sample { font-size: 1.35rem; font-weight: 900; line-height: 1.2; white-space: pre-wrap; }
.font-footer { padding-top: 11px; border-top: 1px solid var(--line); }
.font-footer span { min-width: 0; overflow-wrap: anywhere; }
.preset-row { display: flex; gap: 6px; }
.preset-row input, .preset-row select { flex: 1; min-width: 0; }
.preset-row button { white-space: nowrap; }
.site-footer { padding: 14px 24px 20px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; font-size: .875rem; }

@media (max-width: 760px) {
  header { padding-inline: 13px; }
  main { padding: 15px 13px 36px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .intro { min-height: 122px; margin-bottom: 13px; padding: 15px 17px; }
  .intro-copy { max-width: 63%; }
  .intro::before { inset-inline-start: 41%; }
  .stage { padding: 9px; }
}

@media (max-width: 400px) {
  .brand small { display: none; }
  .brand span { width: 27px; height: 27px; }
  .exports button { padding-inline: 8px; }
  .intro-copy { max-width: 70%; }
}
