.hw-app {
  --hw-brand: #2f76ff;
}

.hw-lead {
  margin: -0.25rem 0 1.25rem;
  max-width: 46rem;
  color: rgb(var(--color-text-muted));
  line-height: 1.6;
}

.hw-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.hw-modes {
  display: inline-flex;
  padding: 0.25rem;
  border-radius: 999px;
  background: #e8effd;
}

.dark .hw-modes {
  background: rgb(var(--color-muted));
}

.hw-mode {
  border: 0;
  background: transparent;
  color: rgb(var(--color-text-muted));
  font-weight: 650;
  font-size: 0.875rem;
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.hw-mode svg {
  width: 1rem;
  height: 1rem;
}

.hw-mode.is-active {
  background: var(--hw-brand);
  color: #fff;
}

.hw-text-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hw-text-actions .tool-button {
  padding: 0.45rem 0.9rem;
  font-size: 0.8125rem;
}

.hw-editor-wrap {
  border: 1.5px solid rgb(var(--color-border-strong));
  border-radius: 0.9rem;
  background: rgb(var(--color-surface));
  overflow: hidden;
}

.hw-editor-wrap:focus-within {
  border-color: var(--hw-brand);
  box-shadow: 0 0 0 3px rgba(47, 118, 255, 0.16);
}

.hw-format {
  display: none;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid rgb(var(--color-border));
  background: rgb(var(--color-muted));
}

.hw-app.is-editor .hw-format {
  display: flex;
}

.hw-format button,
.hw-format label {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
  color: rgb(var(--color-text));
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 750;
}

.hw-format button:hover,
.hw-format label:hover {
  background: rgb(var(--color-surface));
}

.hw-format .hw-sep {
  width: 1px;
  align-self: stretch;
  margin: 0.2rem 0.2rem;
  background: rgb(var(--color-border-strong));
}

.hw-format input[type="color"] {
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.hw-input,
.hw-editor {
  width: 100%;
  min-height: 220px;
  max-height: 360px;
  overflow: auto;
  border: 0;
  resize: vertical;
  padding: 0.9rem 1rem;
  background: transparent;
  color: rgb(var(--color-text));
  font: 0.95rem/1.55 Inter, sans-serif;
  outline: none;
}

.hw-editor {
  display: none;
}

.hw-app.is-editor .hw-input {
  display: none;
}

.hw-app.is-editor .hw-editor {
  display: block;
}

.hw-editor.is-empty:before {
  content: attr(data-placeholder);
  color: rgb(var(--color-text-subtle));
  pointer-events: none;
}

.hw-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.45rem;
  font-size: 0.78rem;
  color: rgb(var(--color-text-subtle));
}

.hw-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem 1rem;
  margin-top: 1.1rem;
}

@media (min-width: 640px) {
  .hw-fields {
    grid-template-columns: 1.4fr 0.7fr 0.9fr 1fr;
  }
}

.hw-field-wide {
  grid-column: 1 / -1;
}

@media (min-width: 640px) {
  .hw-field-font {
    grid-column: span 2;
  }
}

.hw-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgb(var(--color-text-muted));
}

.hw-fontpick {
  position: relative;
}

.hw-fontpick-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.3rem 0.85rem;
  border: 1px solid rgb(var(--color-border-strong));
  border-radius: 0.5rem;
  background: rgb(var(--color-surface));
  color: rgb(var(--color-text));
  text-align: left;
  cursor: pointer;
}

.hw-fontpick-btn:focus-visible {
  outline: none;
  border-color: var(--hw-brand);
  box-shadow: 0 0 0 3px rgba(47, 118, 255, 0.2);
}

.hw-fontpick-btn span {
  min-width: 0;
  overflow: hidden;
  font-size: 1.2rem;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.hw-fontpick-caret {
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
  color: rgb(var(--color-text-muted));
}

.hw-fontpick.is-open .hw-fontpick-caret {
  transform: rotate(180deg);
}

.hw-fontpick-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  max-height: 22rem;
  overflow: auto;
  padding: 0.35rem;
  border: 1px solid rgb(var(--color-border-strong));
  border-radius: 0.9rem;
  background: rgb(var(--color-surface));
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.14);
}

.hw-font-group {
  padding: 0.65rem 0.7rem 0.15rem;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgb(var(--color-text-subtle));
}

.hw-font-option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  margin: 0.1rem 0;
  padding: 0.28rem 0.7rem 0.32rem;
  border: 0;
  border-radius: 0.55rem;
  background: transparent;
  color: rgb(var(--color-text));
  text-align: left;
  cursor: pointer;
}

.hw-font-option:hover,
.hw-font-option.is-active {
  background: #e8effd;
}

.dark .hw-font-option:hover,
.dark .hw-font-option.is-active {
  background: rgb(var(--color-muted));
}

.hw-font-option.is-selected {
  box-shadow: inset 0 0 0 1.5px var(--hw-brand);
}

.hw-font-sample {
  min-width: 0;
  overflow: hidden;
  font-size: 1.45rem;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.hw-font-meta {
  flex: none;
  font-family: inherit;
  font-size: 0.68rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: rgb(var(--color-text-subtle));
}

.hw-hand-link {
  margin-top: 0.4rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--hw-brand);
  font-size: 0.8125rem;
  font-weight: 650;
  cursor: pointer;
}

.hw-hand-link:hover {
  text-decoration: underline;
}

.hw-ink-row {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.hw-ink-row select {
  flex: 1;
}

.hw-ink-row input[type="color"] {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0.15rem;
  border: 1.5px solid rgb(var(--color-border-strong));
  border-radius: 0.55rem;
  background: rgb(var(--color-surface));
  cursor: pointer;
}

.hw-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  align-items: center;
  margin-top: 0.9rem;
  color: rgb(var(--color-text-muted));
  font-size: 0.875rem;
}

.hw-checks label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
}

.hw-checks input {
  accent-color: var(--hw-brand);
}

.hw-desk {
  margin-top: 1.25rem;
  border: 1px solid rgb(var(--color-border-strong));
  border-radius: 1.25rem;
  background:
    radial-gradient(900px 280px at 50% 0%, rgba(47, 118, 255, 0.09), transparent 62%),
    rgb(var(--color-canvas));
  padding: 1rem 0.85rem 1.25rem;
}

.hw-desk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: 760px;
  margin: 0 auto 0.85rem;
}

.hw-desk-title {
  font-weight: 750;
  color: rgb(var(--color-text));
}

.hw-desk-title span {
  display: block;
  font-weight: 500;
  font-size: 0.78rem;
  color: rgb(var(--color-text-subtle));
}

.hw-exports {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hw-exports .tool-button {
  margin: 0;
  padding: 0.5rem 0.95rem;
  font-size: 0.8125rem;
}

.hw-pages {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.hw-sheet-wrap {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.hw-sheet {
  width: 100%;
  height: auto;
  display: block;
  background: #fff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.05);
}

.dark .hw-sheet {
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.4);
}

.hw-sheet-wrap.is-clear {
  background-color: #eef2f7;
  background-image:
    linear-gradient(45deg, rgba(148, 163, 184, 0.28) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(148, 163, 184, 0.28) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(148, 163, 184, 0.28) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(148, 163, 184, 0.28) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.hw-sheet-wrap.is-clear .hw-sheet {
  background: transparent;
  box-shadow: none;
}

.hw-page-caption {
  margin-top: 0.4rem;
  text-align: center;
  font-size: 0.75rem;
  color: rgb(var(--color-text-subtle));
}

.hw-empty {
  position: absolute;
  inset: 18% 12% auto;
  text-align: center;
  color: rgb(var(--color-text-subtle));
  font-size: 0.95rem;
  pointer-events: none;
}

.hw-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.hw-pager button {
  border: 1.5px solid rgb(var(--color-border-strong));
  background: rgb(var(--color-surface));
  color: rgb(var(--color-text));
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-weight: 650;
  font-size: 0.8125rem;
  cursor: pointer;
}

.hw-pager button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hw-status {
  min-height: 1.2rem;
  text-align: center;
  font-size: 0.78rem;
  color: rgb(var(--color-text-subtle));
  margin-top: 0.35rem;
}

.hw-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.hw-modal.is-open {
  display: flex;
}

.hw-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.46);
}

.hw-modal-card {
  position: relative;
  width: min(980px, 100%);
  max-height: min(92vh, 820px);
  overflow: auto;
  background: rgb(var(--color-surface));
  color: rgb(var(--color-text));
  border-radius: 1.25rem;
  border: 1px solid rgb(var(--color-border));
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
  padding: 1.1rem 1.1rem 1.2rem;
}

.hw-modal-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}

.hw-modal-head h2 {
  margin: 0;
  font-size: 1.25rem;
  color: rgb(var(--color-text));
}

.hw-modal-head p {
  margin: 0.25rem 0 0;
  color: rgb(var(--color-text-muted));
  font-size: 0.875rem;
}

.hw-modal-close {
  border: 0;
  background: rgb(var(--color-muted));
  color: rgb(var(--color-text));
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.hw-draw-layout {
  display: grid;
  gap: 1rem;
}

@media (min-width: 800px) {
  .hw-draw-layout {
    grid-template-columns: 1fr 320px;
  }
}

.hw-glyph-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
}

.hw-glyph-tabs button {
  border: 1px solid rgb(var(--color-border-strong));
  background: rgb(var(--color-surface));
  color: rgb(var(--color-text-muted));
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.hw-glyph-tabs button.is-active {
  background: var(--hw-brand);
  border-color: var(--hw-brand);
  color: #fff;
}

.hw-glyph-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 0.35rem;
  max-height: 390px;
  overflow: auto;
  padding-right: 0.15rem;
}

.hw-glyph {
  position: relative;
  height: 46px;
  border: 1.5px solid rgb(var(--color-border-strong));
  border-radius: 0.55rem;
  background: rgb(var(--color-canvas));
  cursor: pointer;
  padding: 0;
}

.hw-glyph canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.hw-glyph span {
  position: absolute;
  left: 4px;
  top: 2px;
  font-size: 0.62rem;
  color: rgb(var(--color-text-subtle));
  pointer-events: none;
}

.hw-glyph.is-active {
  border-color: var(--hw-brand);
  box-shadow: 0 0 0 2px rgba(47, 118, 255, 0.25);
}

.hw-glyph.is-drawn span {
  color: var(--hw-brand);
}

.hw-pad-wrap {
  border: 1.5px solid rgb(var(--color-border-strong));
  border-radius: 0.9rem;
  background: #fffef9;
  overflow: hidden;
}

.hw-pad {
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: crosshair;
  display: block;
}

.hw-pad-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.hw-pad-actions .tool-button {
  margin: 0;
  padding: 0.45rem 0.8rem;
  font-size: 0.8125rem;
}

.hw-progress {
  margin-top: 0.55rem;
  font-size: 0.8rem;
  color: rgb(var(--color-text-muted));
}

.hw-file {
  display: none;
}
