:root { font: 16px/1.35 system-ui,sans-serif; color: #17253f; background: #f6f8fc; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.appbar,.toolbar,.inspector,.bottom { display: flex; align-items: center; gap: .45rem; padding: .46rem clamp(.45rem,2vw,1.3rem); background: white; border-bottom: 1px solid #dbe3ee; flex: none; }
.appbar { display: grid; grid-template-columns: minmax(0,1fr) minmax(8rem,16rem) minmax(0,1fr); gap: .9rem; }
h1 { margin: 0; font-size: 1.15rem; white-space: nowrap; }
h1 span { color: #2457d6; }
.project-name { min-width: 0; }
.project-actions { display: flex; justify-self: end; align-items: center; gap: .9rem; }
#project-name { width: 100%; font-weight: 650; text-align: center; }
.files,.controls,.zoom { display: flex; align-items: center; gap: .4rem; }
.toolbar,.inspector,.bottom { overflow-x: auto; }
.inspector { background: #edf3fd; }
button,select,input,textarea { font: inherit; }
button,select,input[type="number"],input[type="text"] { border: 1px solid #d0daea; background: #fff; border-radius: 8px; color: inherit; min-height: 38px; padding: .38rem .63rem; font-size: .875rem; }
button,select,input[type="color"],input[type="checkbox"] { cursor: pointer; }
button { white-space: nowrap; font-weight: 650; }
button:hover:not(:disabled),button[aria-pressed="true"] { background: #e6eeff; border-color: #7499ed; }
button.primary { background: #2457d6; color: white; border-color: #2457d6; }
button.primary:hover:not(:disabled) { background: #1944b1; color: white; }
button:disabled { opacity: .43; cursor: default; }
:focus-visible { outline: 2px solid #2457d6; outline-offset: -2px; }
.divider { width: 1px; align-self: stretch; background: #dbe3ee; margin-inline: .15rem; flex: none; }
.inspector label { display: inline-flex; gap: .3rem; align-items: center; white-space: nowrap; font-size: .875rem; }
input[type="color"] { width: 35px; height: 35px; border: 1px solid #d0daea; border-radius: 8px; background: #fff; padding: 3px; }
#weight { width: 62px; }
#label { width: 9rem; }
#stage { position: relative; overflow: hidden; flex: 1; min-height: 0; }
#board { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#board:active { cursor: grabbing; }
#board[data-mode] { cursor: crosshair; }
#editor { position: absolute; resize: none; background: white; border: 2px solid #2457d6; border-radius: 6px; padding: .45rem; z-index: 1; }
.hint { position: absolute; top: .7rem; left: 50%; transform: translateX(-50%); max-width: 90%; width: max-content; pointer-events: none; background: #1c3159; color: white; padding: .55rem .8rem; border-radius: 9px; box-shadow: 0 5px 20px #182b6122; font-size: .875rem; }
.bottom { justify-content: space-between; border: 0; border-top: 1px solid #dbe3ee; }
#status { font-size: .82rem; color: #425572; }
.zoom { flex: none; }
#reset { min-width: 70px; }
dialog { width: min(94vw,540px); color: inherit; background: #fff; border: 1px solid #dbe3ee; border-radius: 16px; padding: 1.25rem; box-shadow: 0 18px 55px #17253f35; }
dialog::backdrop { background: #17253f78; }
dialog h2 { margin: 0; font-size: 1.25rem; }
dialog form { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 630px) {
  .bottom { flex-wrap: wrap; gap: .25rem; }
  .zoom { max-width: 100%; overflow-x: auto; }
  button,select { min-height: 41px; }
}
.inspector { position: absolute; z-index: 2; top: .55rem; left: .55rem; right: .55rem; width: max-content; max-width: calc(100% - 1.1rem); border: 1px solid #dbe3ee; border-radius: 12px; box-shadow: 0 5px 16px #182b611a; padding-inline: .5rem; }
#stage:has(.inspector:not([hidden])) .hint { top: 4.35rem; }
#font { max-width: 7rem; }
@media (max-width: 630px) {
  .toolbar { flex-wrap: wrap; }
  .toolbar .divider { display: none; }
}
.icon-button { display: grid; place-items: center; flex: none; width: 41px; padding: 0; }
.icon-button svg { display: block; width: 21px; height: 21px; }
#edit .confirm-icon, #edit[data-editing="true"] .edit-icon { display: none; }
#edit[data-editing="true"] .confirm-icon { display: block; }
#close-dialog { width: min(94vw, 630px); }
#close-dialog form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
#close-dialog button { white-space: normal; overflow-wrap: anywhere; }

.icon-picker { position: relative; display: grid; place-items: center; flex: none; width: 52px; min-height: 38px; padding-right: 12px; border: 1px solid #d0daea; border-radius: 8px; background: #fff; }
.icon-picker:hover { background: #e6eeff; border-color: #7499ed; }
.icon-picker:has(select:focus-visible) { outline: 2px solid #2457d6; outline-offset: -2px; }
.icon-picker svg { display: block; width: 21px; height: 21px; }
.icon-picker::after { content: ""; position: absolute; right: 7px; top: 44%; width: 5px; height: 5px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); pointer-events: none; }
.icon-picker select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
@media (max-width: 630px) { .icon-picker { min-height: 41px; } }

@media (max-width: 880px) {
  .appbar { grid-template-columns: minmax(0,1fr) auto; gap: .4rem; }
  .appbar h1 { grid-row: 1; grid-column: 1; }
  .project-actions { display: contents; }
  .project-name { grid-row: 2; grid-column: 1 / -1; width: min(100%,16rem); justify-self: center; }
  .files { grid-row: 1; grid-column: 1 / -1; justify-self: center; }
  #close { grid-row: 1; grid-column: 2; justify-self: end; }
}
@media (max-width: 520px) {
  .files { grid-row: 3; grid-column: 1 / -1; justify-self: center; }
}

.alignment { display: flex; }
.alignment .icon-button { border-radius: 0; width: 36px; }
.alignment .icon-button + .icon-button { margin-left: -1px; }
.alignment .icon-button:first-child { border-radius: 8px 0 0 8px; }
.alignment .icon-button:last-child { border-radius: 0 8px 8px 0; }
.alignment .icon-button[aria-pressed="true"], .alignment .icon-button:focus-visible { z-index: 1; }
.fill-button { position: relative; }
.fill-button::after { content: ""; position: absolute; bottom: 3px; width: 21px; height: 4px; background: var(--fill-color); border: 1px solid #64748b; border-radius: 2px; }
#fill-dialog { max-width: 420px; }
#fill-dialog p { margin: .85rem 0 .4rem; font-weight: 650; }
.color-palette { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: .35rem; }
.color-palette button { width: 100%; padding: 0; background-color: var(--swatch); }
.color-palette button:hover:not(:disabled), .color-palette button[aria-pressed="true"] { background-color: var(--swatch); outline: 2px solid #2457d6; outline-offset: -3px; }
#fill-dialog .fill-actions { margin-top: 1rem; align-items: center; justify-content: space-between; }
.fill-actions label { display: flex; align-items: center; gap: .45rem; }
