@font-face {
  font-family: Silkscreen;
  src: url('/fonts/silkscreen-400.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Silkscreen;
  src: url('/fonts/silkscreen-700.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
:root {
  --desktop: #4e6270;
  --face: #d7d1c7;
  --sunken: #f6f3ec;
  --ink: #1c1915;
  --soft: #4e4942;
  --title: #F7931A;
  --title-ink: #f4f0e6;
  --light: #fffcf7;
  --shadow: #6e675e;
  --black: #1a1814;
  --select: #D97800;
  --danger: #7a2e28;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--desktop);
  color: var(--ink);
  font-family: Silkscreen, monospace;
  font-size: 12px;
  line-height: 1.45;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--select); outline-offset: 1px; }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.desktop { min-height: 100vh; padding: 18px; }
.win {
  background: var(--face);
  border: 2px solid;
  border-color: var(--light) var(--black) var(--black) var(--light);
  box-shadow: 2px 2px 0 var(--black);
}
.titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--title);
  color: var(--title-ink);
  padding: 4px 6px;
}
.titlebar span:not(.brand) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  font-size: 16px;
  font-weight: 400;
  color: inherit;
  text-decoration: none;
  -webkit-font-smoothing: none;
  font-smooth: never;
}
.brand img {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  flex: none;
}
.win-body { padding: 12px; }
.winbtn {
  background: var(--face);
  color: var(--ink);
  border: 2px solid;
  border-color: var(--light) var(--shadow) var(--shadow) var(--light);
  box-shadow: 1px 1px 0 var(--black);
  min-height: 28px;
  padding: 2px 10px;
}
.winbtn:active { border-color: var(--shadow) var(--light) var(--light) var(--shadow); }
.winbtn:disabled { color: var(--soft); }
.sunken {
  background: var(--sunken);
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
}
input, select {
  background: var(--sunken);
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
  min-height: 28px;
  padding: 2px 6px;
}
.lead { margin: 0 0 14px; max-width: 36rem; }
.hint, .error { margin: 8px 0 0; }
.error { color: var(--danger); }
.btn-row, .lookup-row, .sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lookup-row { margin-top: 6px; }
.lookup-row input { flex: 1; min-width: 0; }
#lookup-form { margin-top: 16px; }
#lookup-form label { display: block; margin-bottom: 6px; color: var(--soft); }
.gate-win { max-width: 440px; margin: 8vh auto 0; }

.app-win { height: calc(100vh - 36px); min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#account { margin-left: auto; }
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border-bottom: 2px solid var(--shadow);
}
.heading h1 { margin: 0; font-size: 16px; font-weight: 400; letter-spacing: 0; }
#crumb { margin: 0 0 4px; color: var(--soft); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.search { flex: 1 1 140px; }
.search input { width: 100%; }
.workspace { display: block; flex: 1; min-height: 0; overflow: hidden; }
#menu { margin: 8px; }
#rail {
  display: none;
  margin: 0 8px 8px;
  padding: 6px;
  max-height: 240px;
  overflow-x: hidden;
  overflow-y: auto;
}
#rail.open { display: block; max-height: min(70dvh, 520px); }
.nav-section { display: flex; align-items: center; gap: 2px; }
.nav-disclosure {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  min-height: 32px;
  margin-top: 8px;
  padding: 2px 2px;
  border: 0;
  background: transparent;
  color: var(--soft);
  font-size: 16px;
  font-weight: 400;
  text-align: left;
  -webkit-font-smoothing: none;
  font-smooth: never;
}
.nav-add {
  margin-top: 8px;
  width: 32px;
  height: 32px;
  border: 2px solid;
  border-color: var(--light) var(--shadow) var(--shadow) var(--light);
  background: var(--face);
  color: var(--ink);
  flex: none;
  font-size: 16px;
}
.nav-body { display: grid; }
.nav-body[hidden] { display: none; }
.twist, .twist-spacer { width: 8px; height: 8px; flex: none; }
.twist {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent currentColor;
}
.twist.open {
  border-width: 6px 4px 0 4px;
  border-color: currentColor transparent transparent transparent;
}
.nav-btn, .folder-row {
  width: 100%;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  min-height: 36px;
  padding: 2px 2px;
  border: 0;
  background: transparent;
  text-align: left;
  position: relative;
  font-size: 16px;
  font-weight: 400;
  -webkit-font-smoothing: none;
  font-smooth: never;
}
.nav-sub { padding-left: 22px; }
.folder-row.drop { outline: 2px solid var(--select); outline-offset: -2px; }
.folder-twist {
  width: 18px;
  height: 22px;
  border: 0;
  background: transparent;
  color: inherit;
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
}
.folder-more {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: inherit;
  flex: none;
  padding: 0;
  font-size: 16px;
}
.count { flex: none; font-size: 16px; }
.folder-pop {
  position: absolute;
  right: 0;
  top: 26px;
  z-index: 4;
  min-width: 156px;
  display: flex;
  flex-direction: column;
  background: var(--face);
  border: 2px solid;
  border-color: var(--light) var(--black) var(--black) var(--light);
  box-shadow: 2px 2px 0 var(--black);
}
.folder-pop button {
  min-height: 28px;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  text-align: left;
  color: inherit;
}
.folder-pop button:hover, .folder-pop button:focus-visible { background: var(--select); color: var(--title-ink); }
.tree-empty { margin: 2px 4px 6px 16px; color: var(--soft); }
.crumb-btn {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
}
.crumb-btn[aria-current="page"] { text-decoration: none; }
.pane-folders { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 8px 0; }
.pane-folder {
  min-height: 32px;
  padding: 4px 8px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--light) var(--shadow) var(--shadow) var(--light);
}
.fmb-nav {
  border: 2px solid;
  border-color: #f4e2a8 #8a6824 #8a6824 #f4e2a8;
  background: #2c2618;
  color: #f8efd4;
  padding: 4px;
  margin-top: 2px;
}
.fmb-nav[aria-current="true"] { background: #4a3b1e; color: #fff8e6; }
.fmb-mark {
  width: 42px;
  height: 42px;
  background: #12100c;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: none;
}
.fmb-mark img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.fmb-name { flex: 1; letter-spacing: 0.12em; text-align: left; }
.nav-btn[aria-current="true"], .folder-row[aria-current="true"] {
  background: var(--select);
  color: var(--title-ink);
}
.folder-main {
  display: flex;
  min-width: 0;
  flex: 1;
  background: none;
  border: 0;
  text-align: left;
  color: inherit;
  padding: 0;
}
.folder-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-del { border: 0; background: transparent; color: inherit; width: 24px; }
.folder-draft {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  flex: 1;
  min-width: 0;
  padding: 4px 0;
}
.folder-draft input {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 2px 6px;
  background: var(--sunken);
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
  font-size: 16px;
}
.folder-draft-actions { display: flex; gap: 6px; }
.folder-draft-actions .winbtn { flex: 1; min-width: 0; white-space: nowrap; min-height: 36px; }
.stage { min-width: 0; min-height: 0; padding: 0 8px 8px; display: flex; flex-direction: column; }
#filebar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  padding: 6px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
}
#list { flex: 1; min-height: 0; overflow: auto; }
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 8px;
  padding: 8px;
}
.tile {
  cursor: pointer;
  background: var(--face);
  border: 2px solid;
  border-color: var(--light) var(--shadow) var(--shadow) var(--light);
  padding: 6px;
  text-align: left;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.tile.is-checked {
  outline: 3px solid var(--select);
  outline-offset: -4px;
  background: #e7eef6;
}
.tile.is-checked[aria-selected="true"] { outline-color: var(--title); }
#list.picking .tile { cursor: copy; }
.check-hit {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: -4px 0 0 -4px;
  cursor: pointer;
}
.check { width: 22px; height: 22px; accent-color: var(--select); margin: 0; }
.frame {
  height: 184px;
  background: #1b242c;
  color: var(--title-ink);
  overflow: hidden;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8px;
}
.frame img, .preview-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.pixel {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}
.frame.text-frame {
  background: var(--sunken);
  color: var(--ink);
  place-items: start;
  text-align: left;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.4;
}
.caption { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.caption strong, .caption span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iid {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
  color: var(--ink);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-all;
}
.num {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.25;
  color: var(--ink);
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
  font-smooth: never;
}
.caption span { color: var(--soft); font-size: 16px; font-weight: 400; line-height: 1.25; }
#viewer-title { font-size: 16px; font-weight: 400; -webkit-font-smoothing: none; font-smooth: never; }
.check-hit { cursor: pointer; }
.tile-top { display: flex; justify-content: flex-start; gap: 4px; }
.empty { margin: 0; padding: 16px; color: var(--soft); max-width: 28rem; }
.statusbar {
  margin: 0;
  padding: 4px 8px;
  border-top: 2px solid var(--light);
  color: var(--soft);
  min-height: 22px;
}
#backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 28, 0.45);
  z-index: 20;
}
.viewer {
  position: fixed;
  z-index: 21;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  width: min(760px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
  display: flex;
  flex-direction: column;
}
#viewer-body { overflow: auto; max-height: min(74vh, 760px); }
.preview-stage { display: grid; place-items: center; min-height: 160px; }
#viewer-body audio { width: 100%; }
.inscription-text {
  margin: 0;
  width: 100%;
  box-sizing: border-box;
  background: var(--sunken);
  color: var(--ink);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 12px;
  max-height: 62vh;
  overflow: auto;
}
.html-preview {
  width: 100%;
  height: min(62vh, 520px);
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
  background: #fff;
}
#viewer-actions { padding: 8px 12px 12px; }
.meta-list { list-style: none; padding: 0; margin: 8px 0 0; }
.meta-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px solid var(--shadow);
}
.meta-list span { color: var(--soft); }
.meta-list .id-row { flex-direction: column; align-items: stretch; }
.meta-list code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-all;
}
#drop {
  position: fixed;
  inset: 10px;
  z-index: 15;
  display: grid;
  place-items: center;
  background: rgba(215, 209, 199, 0.92);
  border: 2px dashed var(--title);
  font-size: 16px;
}
#sheet { border: 0; padding: 0; background: transparent; width: min(440px, calc(100% - 24px)); }
#sheet::backdrop { background: rgba(20, 24, 28, 0.45); }
#sheet .win { box-shadow: 3px 3px 0 var(--black); }
#sheet-body ul { margin: 0; padding-left: 16px; }
#sheet-go[hidden] { display: none; }

@media (min-width: 880px) {
  #menu { display: none; }
  .workspace { display: flex; align-items: stretch; gap: 8px; padding: 8px; }
  #rail, #rail.open {
    display: block;
    width: 320px;
    flex: none;
    margin: 0;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .stage { flex: 1; padding: 0; }
  .toolbar { flex-direction: row; justify-content: space-between; align-items: end; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}

/* FMBOX retro inscription loading activity */
.fmbox-loading { box-sizing: border-box; width: min(460px, calc(100% - 32px)); margin: clamp(28px, 12vh, 110px) auto 24px; padding: 18px; border: 2px solid #444; box-shadow: 3px 3px 0 #888; background: #d6d0c6; color: #202020; font-family: inherit; }
.fmbox-loading-title { font-weight: 700; font-size: 12px; letter-spacing: .05em; margin-bottom: 14px; }
.fmbox-loading-track { height: 24px; padding: 3px; overflow: hidden; border: 2px inset #8a8985; background: #f8f7f3; position: relative; }
.fmbox-loading-runner { width: 32%; height: 100%; background: repeating-linear-gradient(90deg,#294d7a 0,#294d7a 12px,transparent 12px,transparent 15px); animation: fmbox-loading-move 1.8s linear infinite; }
.fmbox-loading-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; font-size: 11px; font-weight: 700; }
.fmbox-loading-count { white-space: nowrap; }
.fmbox-loading-hint { font-size: 11px; margin-top: 12px; opacity: .7; }
.fmbox-dots::after { content: ''; animation: fmbox-loading-dots 1.2s steps(4,end) infinite; }
@keyframes fmbox-loading-move { from { transform: translateX(-110%); } to { transform: translateX(330%); } }
@keyframes fmbox-loading-dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75%,100% { content: '...'; } }
@media (prefers-reduced-motion: reduce) { .fmbox-loading-runner,.fmbox-dots::after { animation: none; } }

/* FMBOX mobile titlebar fix */
@media (max-width: 600px) {
  .desktop {
    padding: 10px;
  }

  .gate-win {
    width: 100%;
    max-width: 440px;
  }

  .titlebar .brand {
    min-width: 0;
    max-width: 100%;
  }

  .titlebar .brand img {
    width: 56px;
    height: 56px;
  }

  .titlebar .brand-tagline {
    min-width: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
    font-size: 11px;
    line-height: 1.5;
  }

  .titlebar {
    min-width: 0;
  }
}

/* Two-line mobile FMBOX tagline */
@media (max-width: 600px) {
  .titlebar .brand-tagline {
    display: block;
    flex: 1;
    min-width: 0;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    font-size: 10px;
    line-height: 1.8;
  }

  .titlebar .brand-yellow {
    display: block;
    white-space: nowrap;
  }
}

/* FMBOX blockchain network selector */
.network-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-left: auto;
  margin-right: 12px;
  flex-wrap: wrap;
}

.network-switch .winbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font: inherit;
  font-size: 11px;
  white-space: nowrap;
  padding: 8px 12px;
}

.network-switch .network-active {
  background: #ffe16b;
  color: #191919;
  border: 2px solid #191919;
  box-shadow: inset 1px 1px #fff6bd;
  font-weight: bold;
}

@media (max-width: 650px) {
  .titlebar:has(.network-switch) {
    flex-wrap: wrap;
    gap: 8px;
  }

  .network-switch {
    margin: 0;
  }

  .network-switch .winbtn {
    font-size: 10px;
    padding: 6px 8px;
  }
}

/* Keep network selector inside the compact welcome window */
.gate-win .titlebar {
  flex-wrap: wrap;
  gap: 8px;
}

.gate-win .network-switch {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  margin: 0 0 0 auto;
  gap: 6px;
}

.gate-win .network-switch .winbtn {
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .gate-win .network-switch {
    width: 100%;
    justify-content: center;
  }
}

/* Keep network selector inside the compact welcome window */
.gate-win .titlebar {
  flex-wrap: wrap;
  gap: 8px;
}

.gate-win .network-switch {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  margin: 0 0 0 auto;
  gap: 6px;
}

.gate-win .network-switch .winbtn {
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .gate-win .network-switch {
    width: 100%;
    justify-content: center;
  }
}

/* Final layout for introduction screen network selector */
.gate-win .titlebar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.gate-win .titlebar > .brand {
  width: 100%;
}

.gate-win .network-switch {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-self: center;
  width: auto;
  max-width: 100%;
  margin: 0;
  gap: 8px;
}

.gate-win .network-switch .winbtn {
  flex: 0 0 auto;
}
