@font-face {
  font-family: "Px437 IBM VGA 8x16";
  src: url("assets/fonts/Px437_IBM_VGA_8x16.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #0d1017;
  --panel: #151a24;
  --panel-2: #1f2633;
  --panel-3: #111722;
  --line: #30384a;
  --text: #eceff7;
  --muted: #a8b1c2;
  --accent: #5968ff;
  --accent-2: #65d1c6;
  --danger: #c86b5b;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 1px solid #465178;
  background: #252d43;
  color: var(--text);
  padding: 0.55rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  background: #303a57;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

.font-browser {
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.browser-header {
  display: grid;
  gap: 0.45rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  background: #0a0c12;
}

.brand-mark {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.brand-mark img {
  display: block;
  width: min(210px, 100%);
  height: auto;
  image-rendering: pixelated;
}

h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
}

.font-count,
.selected-meta,
.status {
  color: var(--muted);
  font-size: 0.85rem;
}

.browser-header .font-count {
  display: block;
}

.field {
  display: grid;
  gap: 0.4rem;
  padding: 1rem;
}

.field span {
  color: var(--muted);
  font-size: 0.82rem;
}

.browser-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0 1rem 1rem;
}

.drop-zone {
  display: block;
  margin: 0 1rem 1rem;
  border: 1px dashed #465178;
  border-radius: 6px;
  background: #101622;
  color: var(--muted);
  padding: 0.7rem;
  text-align: center;
  cursor: pointer;
}

.drop-zone.drag-over {
  border-color: var(--accent-2);
  color: var(--text);
  background: #162033;
}

.drop-zone input {
  display: none;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #080b12;
  color: var(--text);
  padding: 0.65rem 0.7rem;
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

.font-list {
  min-height: 0;
  overflow: auto;
  border-top: 1px solid var(--line);
}

.font-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  width: 100%;
  border: 0;
  border-bottom: 1px solid #222938;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 0.7rem 1rem;
  text-align: left;
}

.font-label {
  min-width: 0;
}

.favorite-mark {
  color: var(--accent-2);
  font-size: 1rem;
}

.font-option:hover,
.font-option[aria-selected="true"] {
  background: var(--panel-2);
}

.font-option[aria-selected="true"] {
  box-shadow: inset 4px 0 0 var(--accent);
}

.font-file {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.notice-panel {
  border-top: 1px solid var(--line);
  background: #0f141f;
  padding: 0.75rem 1rem;
}

.notice-panel summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 0.86rem;
}

.notice-copy {
  display: grid;
  gap: 0.65rem;
  padding-top: 0.7rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.notice-copy p {
  margin: 0;
}

.notice-copy a {
  color: var(--accent-2);
}

.support-note {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #222938;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.support-note p {
  margin: 0;
}

.support-note a {
  justify-self: start;
  color: var(--accent-2);
  text-decoration: none;
}

.support-note a:hover {
  text-decoration: underline;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel-3);
}

.selection-summary {
  min-width: 12rem;
}

.selected-name {
  font-size: 1.15rem;
  font-weight: 700;
}

.variant-field {
  display: grid;
  gap: 0.35rem;
  min-width: 12rem;
  margin-left: auto;
}

.variant-field span {
  color: var(--muted);
  font-size: 0.82rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

button[aria-pressed="true"] {
  border-color: var(--accent-2);
  color: #f5fffd;
  background: #263c4d;
}

.status {
  min-height: 1.75rem;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid var(--line);
}

.status.error {
  color: #ffd0c8;
  background: #3b1f2a;
}

.sample-field {
  border-bottom: 1px solid var(--line);
  background: var(--panel-3);
}

.export-options {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) minmax(7rem, 10rem) auto;
  gap: 0.75rem;
  align-items: end;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel-3);
}

.export-options label {
  display: grid;
  gap: 0.35rem;
}

.export-options span {
  color: var(--muted);
  font-size: 0.82rem;
}

.checkbox-field {
  grid-auto-flow: column;
  grid-template-columns: auto 1fr;
  align-items: center;
  padding-bottom: 0.55rem;
}

.checkbox-field input {
  width: auto;
}

.preview-shell {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: #000;
}

.ansi-preview {
  display: inline-block;
  min-width: 100%;
  min-height: 100%;
  margin: 0;
  padding: 1rem;
  background: #000;
  color: #aaa;
  font-family: "Px437 IBM VGA 8x16", "Courier New", monospace;
  font-size: 16px;
  line-height: 16px;
  white-space: pre;
}

.reference-preview {
  border-top: 1px solid var(--line);
  background: var(--panel-3);
  padding: 0.7rem 1rem;
}

.reference-preview summary {
  cursor: pointer;
  color: var(--muted);
}

.reference-preview img {
  display: block;
  max-width: 100%;
  margin-top: 0.7rem;
  image-rendering: pixelated;
  background: #000;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 38vh) minmax(0, 1fr);
  }

  .font-browser {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .variant-field {
    width: 100%;
    margin-left: 0;
  }

  .export-options {
    grid-template-columns: 1fr;
  }

  .actions {
    justify-content: flex-start;
  }
}
