:root{
  color-scheme: dark;
  --bg: #0b0e13;
  --panel: #141a23;
  --panel-2: #1c2531;
  --line: #2a3441;
  --ink: #eef1f5;
  --ink-soft: #8b96a5;
  --ink-faint: #57626f;
  --amber: #ffb020;
  --amber-ink: #201302;
  --red: #ef5b5b;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --display: "Archivo", system-ui, sans-serif;
  --radius: 14px;
}

*, *::before, *::after{ box-sizing: border-box; }
[hidden]{ display: none !important; }
img{ max-width: 100%; }

body{
  margin: 0;
  padding: 0;
  font-size: 14px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
}

h1, h2, p{ margin: 0; }

input{ font-family: inherit; color: inherit; }
button{ font-family: inherit; color: inherit; cursor: pointer; }

::selection{ background: var(--amber); color: var(--amber-ink); }

.mono-label{
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.field-label{
  font-family: var(--mono);
  text-transform: none;
  letter-spacing: 0;
  font-size: .78rem;
  color: var(--ink-soft);
}

/* ---------- setup screen ---------- */

#setup{
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: clamp(20px, 5vw, 48px) 18px 40px;
}

.app{
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.ticker{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.ticker .dot{
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--amber);
  margin-right: 8px;
  box-shadow: 0 0 8px var(--amber);
}

.ticker time{
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .08em;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.titleblock h1{
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(1.7rem, 6vw, 2.15rem);
  letter-spacing: -.01em;
  text-wrap: balance;
}
.titleblock h1 em{
  font-style: normal;
  color: var(--amber);
}
.titleblock p{
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: .95rem;
  line-height: 1.5;
  max-width: 46ch;
}

.card{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field{ display: flex; flex-direction: column; gap: 8px; }

.input-wrap{ position: relative; }

#nameInput{
  width: 100%;
  background: var(--panel-2);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 14px 42px 14px 14px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.55rem;
  letter-spacing: -.01em;
}
#nameInput::placeholder{
  color: var(--ink-faint);
  font-weight: 700;
}
#nameInput:focus{
  outline: none;
  border-color: var(--amber);
}

#subInput{
  width: 100%;
  background: var(--panel-2);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: .9rem;
  letter-spacing: .03em;
  text-transform: uppercase;
}
#subInput::placeholder{
  color: var(--ink-faint);
  text-transform: none;
  font-family: var(--sans);
  letter-spacing: 0;
}
#subInput:focus{ outline: none; border-color: var(--amber); }

.clear-btn{
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--ink-faint);
}
.clear-btn:hover{ background: var(--line); color: var(--ink); }

/* ---- customize block ---- */

.customize{
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.mini-btn{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 13px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: .76rem;
  font-weight: 600;
  white-space: nowrap;
}
.mini-btn svg{ width: 13px; height: 13px; flex: none; }
.mini-btn.danger{ color: var(--red); }

.logo-upload-row{ display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.logo-actions{ display: flex; gap: 8px; }

.logo-adjust{ display: flex; flex-direction: column; gap: 14px; }
.pos-row{ display: flex; gap: 8px; }
.pos-btn{
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: var(--panel-2);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 6px;
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.pos-btn svg{ width: 20px; height: 20px; color: var(--ink); }
.pos-btn[aria-pressed="true"]{
  border-color: var(--amber);
  background: color-mix(in srgb, var(--amber) 14%, var(--panel-2));
  color: var(--amber);
}
.pos-btn[aria-pressed="true"] svg{ color: var(--amber); }

.logo-row{
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.logo-item{ position: relative; flex: 0 0 auto; width: 64px; }
.logo-pick{
  width: 64px; height: 64px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--panel-2);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  padding: 6px;
}
.logo-pick img{ max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-pick[aria-pressed="true"]{ border-color: var(--amber); }
.logo-item-name{
  display: block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: .58rem;
  text-align: center;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logo-del{
  position: absolute;
  top: -6px; right: -6px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-faint);
}
.logo-del svg{ width: 9px; height: 9px; }

.font-row{
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.font-btn{
  flex: 0 0 auto;
  min-width: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: var(--panel-2);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 8px;
}
.font-btn .font-preview{ font-size: 1.35rem; line-height: 1; color: var(--ink); }
.font-btn .font-name{
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}
.font-btn[aria-pressed="true"]{
  border-color: var(--amber);
  background: color-mix(in srgb, var(--amber) 14%, var(--panel-2));
}
.font-btn[aria-pressed="true"] .font-name{ color: var(--amber); }

.color-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.color-block{ display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.color-controls{ display: flex; align-items: center; gap: 10px; }
.color-input{
  position: relative;
  flex: none;
  width: 42px; height: 42px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  overflow: hidden;
}
.color-input input{
  position: absolute;
  inset: -6px;
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}
.color-meta{ display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hex-value{
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .03em;
  color: var(--ink-soft);
}
.preset-dots{ display: flex; gap: 6px; flex-wrap: wrap; }
.preset-dot{
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  padding: 0;
}
.preset-dot[aria-pressed="true"]{ box-shadow: 0 0 0 2px var(--amber); }

.toggle-btn{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--panel-2);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 11px 10px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: .82rem;
}
.toggle-btn svg{ width: 16px; height: 16px; flex: none; }
.toggle-btn[aria-pressed="true"]{
  border-color: var(--amber);
  background: color-mix(in srgb, var(--amber) 14%, var(--panel-2));
  color: var(--amber);
}

.card-actions{ display: flex; gap: 10px; }
.card-actions .toggle-btn{ flex: 1; }

.size-row{ display: flex; align-items: baseline; justify-content: space-between; }

input[type="range"]{
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  margin-top: 10px;
  border-radius: 999px;
  background: var(--panel-2);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--amber);
  border: 3px solid var(--panel);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  margin-top: -7px;
}
input[type="range"]::-moz-range-track{
  height: 6px;
  border-radius: 999px;
  background: var(--panel-2);
}
input[type="range"]::-moz-range-thumb{
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--amber);
  border: 3px solid var(--panel);
  cursor: pointer;
}

.contrast-warn{
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: color-mix(in srgb, var(--red) 12%, var(--panel-2));
  border: 1px solid color-mix(in srgb, var(--red) 45%, var(--line));
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .78rem;
  line-height: 1.4;
  color: var(--red);
}
.contrast-warn svg{ width: 15px; height: 15px; flex: none; margin-top: 1px; }

.preview-box{
  position: relative;
  height: 96px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
  padding: 0 18px;
}
.preview-tag{
  position: absolute;
  top: 8px; left: 10px;
  font-size: .58rem;
}
.preview-logo{ height: 40px; width: auto; max-width: 80px; object-fit: contain; flex: none; }
.preview-text{
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.cta{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: var(--amber);
  color: var(--amber-ink);
  border: none;
  border-radius: 10px;
  padding: 16px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: .01em;
}
.cta:active{ transform: translateY(1px); }
.cta svg{ width: 18px; height: 18px; }

.recents{ display: flex; flex-direction: column; gap: 10px; }
.chip-row{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.chip{
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1.5px dashed var(--line);
  border-radius: 9px;
  padding: 8px 30px 8px 12px;
}
.chip-text{
  display: flex;
  flex-direction: column;
  text-align: left;
}
.chip-name{
  font-family: var(--display);
  font-weight: 700;
  font-size: .88rem;
}
.chip-sub{
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.chip-load{
  position: absolute; inset: 0;
  background: transparent;
  border: none;
  border-radius: inherit;
}
.chip-del{
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2);
  border: none;
  border-radius: 50%;
  color: var(--ink-faint);
  z-index: 2;
}
.chip-del:hover{ color: var(--red); }
.chip-del svg{ width: 10px; height: 10px; }

.hint{
  display: flex;
  gap: 8px;
  color: var(--ink-faint);
  font-size: .78rem;
  line-height: 1.5;
}
.hint svg{ width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--ink-faint); }

/* ---------- modals ---------- */

.modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, .72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 0;
}
@media (min-width: 520px){
  .modal-overlay{ align-items: center; padding: 20px; }
}
.modal-card{
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
@media (min-width: 520px){
  .modal-card{ border-radius: 16px; }
}
.modal-card h2{
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.1rem;
}
.modal-card input[type="text"]{
  width: 100%;
  background: var(--panel-2);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
}
.modal-card input[type="text"]:focus{ outline: none; border-color: var(--amber); }
.modal-actions{ display: flex; gap: 10px; margin-top: 4px; }
.modal-actions button{ flex: 1; }
.modal-actions .cta{ padding: 13px; }
.share-preview img{
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

/* ---------- toast ---------- */

.toast{
  position: fixed;
  left: 50%;
  bottom: max(96px, calc(env(safe-area-inset-bottom) + 90px));
  transform: translate(-50%, 0);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: .82rem;
  font-weight: 600;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  max-width: 88vw;
  text-align: center;
}
.toast.show{ opacity: 1; transform: translate(-50%, -6px); }
.toast.error{ border-color: color-mix(in srgb, var(--red) 50%, var(--line)); color: var(--red); }

/* ---------- display screen ---------- */

#stage{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #ffffff;
}

.rotator{
  position: relative;
  width: 100%;
  height: 100%;
  padding: 6vmin;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.rotator.rot-90{ width: 100vh; height: 100vw; transform: rotate(90deg); }
.rotator.rot-270{ width: 100vh; height: 100vw; transform: rotate(270deg); }

.fit-box{
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  row-gap: 3vmin;
  overflow: hidden;
}

.sign-logo{ display: block; object-fit: contain; }
.sign-logo-corner{
  position: absolute;
  bottom: max(3vmin, calc(env(safe-area-inset-bottom) + 92px));
  object-fit: contain;
  pointer-events: none;
}
.sign-logo-corner.pos-right{ right: 3vmin; }
.sign-logo-corner.pos-left{ left: 3vmin; }

.sign-name{
  line-height: .98;
  text-align: center;
  white-space: nowrap;
}

.sign-sub{
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
}

.toolbar{
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translate(-50%, 0);
  display: flex;
  gap: 8px;
  background: rgba(20, 26, 35, .92);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px;
  backdrop-filter: blur(6px);
  opacity: 1;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 5;
}
.toolbar.is-hidden{
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
}
.icon-btn{
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
}
.icon-btn svg{ width: 19px; height: 19px; }
.icon-btn[aria-pressed="true"]{
  background: var(--amber);
  border-color: var(--amber);
  color: var(--amber-ink);
}
.icon-btn.back{ background: var(--panel); }

@media (prefers-reduced-motion: reduce){
  *{ transition: none !important; animation: none !important; }
}
