:root {
  --bg: #19191d; --panel: #222227; --field: #26262c; --line: #44444e; --line2: #3a3a42;
  --text: #e8e6e1; --dim: #9c9aa3; --red: #b3261e; --red2: #cc342b; --gold: #e8b931;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }

.app { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; height: 100vh; height: 100dvh; padding: 14px; }
.fonts, .work { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; }
h1 { font-size: 19px; margin: 0 0 4px; display: flex; align-items: center; gap: 9px; font-weight: 600; }
h1 img { border-radius: 6px; }
.lbl { color: var(--dim); font-size: 12px; margin: 0; }
.row { display: flex; gap: 6px; }
.grow { flex: 1; }

select, input[type=search], .textinput {
  background: var(--field); border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px; width: 100%; outline: none;
}
select:focus-visible, input:focus-visible, button:focus-visible { outline: 2px solid #8a8a96; outline-offset: 1px; }
.textinput { font-size: 20px; padding: 9px 12px; color: #f4f2ec; }

.fontlist { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 120px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 4px; }
.fontlist li { display: flex; align-items: center; padding: 5px 8px 5px 2px; cursor: pointer; border-left: 3px solid transparent; }
.fontlist li:hover { background: #2a2a31; }
.fontlist li.sel { background: #33333c; border-left-color: var(--red); }
.fontlist .star { background: none; border: 0; cursor: pointer; font-size: 20px; line-height: 1; padding: 4px 8px; color: #6e6e78; flex: none; }
.fontlist .star.on { color: var(--gold); }
.fontlist .names { min-width: 0; flex: 1; }
.fontlist .sample { font-size: 23px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fontlist .meta { font-size: 10.5px; color: #8b8992; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fontlist .del { background: none; border: 0; color: #77757e; cursor: pointer; padding: 4px 6px; font-size: 14px; flex: none; }
.fontlist .del:hover { color: #e0554d; }
.fontlist .empty { color: var(--dim); padding: 14px; cursor: default; display: block; }

.btn { background: #2a2a31; border: 1px solid var(--line); border-radius: 4px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #34343d; border-color: #8a8a96; }
.primary { background: var(--red); border: 0; border-radius: 4px; color: #fff; font-size: 15px; font-weight: 600; padding: 10px 22px; cursor: pointer; white-space: nowrap; }
.primary:hover { background: var(--red2); }

.stage { flex: 1; min-height: 180px; display: flex; gap: 10px; }
.preview {
  flex: 1; min-width: 0; position: relative; border: 1px solid var(--line2); border-radius: 4px; overflow: hidden;
  background-color: #fbfaf7;
  background-image: linear-gradient(45deg, #eceae5 25%, transparent 25%, transparent 75%, #eceae5 75%),
                    linear-gradient(45deg, #eceae5 25%, transparent 25%, transparent 75%, #eceae5 75%);
  background-size: 28px 28px; background-position: 0 0, 14px 14px;
}
.preview canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.bend { width: 76px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.bend strong { font-size: 14px; font-weight: 600; }
.bend input[type=range] { flex: 1; min-height: 80px; writing-mode: vertical-lr; direction: rtl; width: 28px; accent-color: var(--red); cursor: pointer; }
.bendtext { font-size: 12px; min-height: 17px; }
.bend .btn { width: 100%; padding: 5px 6px; }

.options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.fmt { display: flex; gap: 6px; }
.tog { width: 42px; height: 34px; background: #2a2a31; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; font: 16px "Times New Roman", serif; }
.tog.wide { width: 84px; font: 13px "Segoe UI", system-ui, sans-serif; }
.tog:hover { border-color: #8a8a96; }
.tog[aria-pressed=true] { background: var(--red); border-color: #e0554d; }
.opt { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 12px; white-space: nowrap; }
.opt input[type=range] { width: 110px; accent-color: var(--red); }
.opt.disabled { opacity: .4; }
.opt select { width: auto; color: var(--text); font-size: 14px; }
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { accent-color: var(--red); width: 16px; height: 16px; margin: 0; }

.savebar { display: flex; align-items: center; gap: 12px; }
.status { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.drophint { position: fixed; inset: 0; background: rgba(25, 25, 29, .88); display: flex; align-items: center; justify-content: center; font-size: 26px; border: 3px dashed var(--red); pointer-events: none; z-index: 10; }
[hidden] { display: none !important; }

@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); height: auto; padding: 12px; }
  .work { order: -1; }
  .stage { flex: none; height: 52vh; min-height: 260px; }
  .bend { width: 60px; }
  .fontlist { flex: none; height: 60vh; }
  .savebar { flex-wrap: wrap; }
  .status { flex-basis: 100%; white-space: normal; }
  .primary { flex: 1; }
}
