:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e0e8;
  --accent: #a600ff;
  --accent-strong: #8400cc;
  --warning: #b45309;
  --shadow: 0 18px 50px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: auto;
  padding: 24px;
  background: #11110f;
  color: #f8fafc;
}

.brand {
  display: flex;
  align-items: center;
  margin-bottom: 28px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: #a8b3c1;
  font-size: 13px;
}

.panel {
  padding: 18px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  color: #dbe4ee;
}

.type-tabs {
  display: grid;
  gap: 8px;
}

.type-tab,
.primary-button,
.secondary-button,
.download-button,
.delete-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.type-tab {
  text-align: left;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #e5edf5;
}

.type-tab.active {
  background: var(--accent);
  color: #ffffff;
}

.field {
  display: grid;
  gap: 8px;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
}

.field + .field {
  margin-top: 14px;
}

select,
input[type="password"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

select {
  height: 42px;
  padding: 0 12px;
}

.sidebar select,
.sidebar input[type="password"] {
  border-color: rgba(255, 255, 255, 0.16);
  background: #19232e;
  color: #f8fafc;
}

input[type="password"] {
  height: 42px;
  padding: 0 12px;
}

input[type="password"]::placeholder {
  color: #8190a3;
}

.category-segmented {
  grid-template-columns: 1fr;
}

.admin-type-segmented {
  grid-template-columns: 1fr;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.segment-button {
  min-width: 0;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.segment-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.sidebar .segment-button {
  border-color: rgba(255, 255, 255, 0.16);
  background: #19232e;
  color: #f8fafc;
}

.sidebar .segment-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: 154px;
  margin-top: 14px;
  padding: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  text-align: center;
}

.upload-box input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: #263442;
  color: var(--accent);
  font-weight: 900;
}

.upload-box small,
.hint {
  color: #a8b3c1;
}

.compact-upload {
  min-height: 132px;
}

.hint {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.6;
}

.library-count {
  margin-bottom: 12px;
  color: #a8b3c1;
}

.secondary-button {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.admin-entry-button {
  background: var(--accent);
}

.admin-panel[hidden],
.admin-logout-area[hidden],
.modal-backdrop[hidden] {
  display: none;
}

.admin-logout-area {
  margin-top: auto;
  padding-top: 18px;
}

.logout-button {
  background: #2b2b2a;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 17, 15, 0.72);
  backdrop-filter: blur(12px);
}

.progress-overlay {
  position: fixed;
  inset: auto 24px 24px auto;
  z-index: 24;
  width: min(420px, calc(100vw - 48px));
}

.progress-overlay[hidden] {
  display: none;
}

.progress-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(166, 0, 255, 0.22);
  border-radius: 8px;
  background: #11110f;
  color: #f8fafc;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.progress-card p,
.progress-card h2 {
  margin: 0;
}

#progressEyebrow {
  color: #c58cff;
  font-size: 12px;
  font-weight: 900;
}

#progressTitle {
  margin-top: 5px;
  font-size: 18px;
}

#progressDetail {
  color: #cbd5e1;
  font-size: 13px;
  line-height: 1.5;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.admin-modal {
  display: grid;
  width: min(520px, 100%);
  gap: 22px;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #11110f;
  color: #f8fafc;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
}

.admin-modal h2 {
  margin: 0;
  font-size: 24px;
}

.admin-modal p {
  margin: 8px 0 0;
  color: #a8b3c1;
  line-height: 1.6;
}

.admin-modal input[type="password"] {
  min-height: 56px;
  border-color: #40566f;
  background: #142231;
  color: #f8fafc;
  font-size: 20px;
  font-weight: 800;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.workspace {
  min-width: 0;
  padding: 32px;
}

.control-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  margin-bottom: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.text-input span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

textarea {
  min-height: 118px;
  resize: vertical;
  padding: 14px;
  line-height: 1.5;
}

.settings-grid {
  display: grid;
  align-content: start;
  gap: 14px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 320px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  text-align: center;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state span {
  margin-top: 8px;
  color: var(--muted);
}

.font-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.font-card {
  display: grid;
  min-height: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(17, 24, 39, 0.06);
}

.preview-canvas {
  display: grid;
  align-items: center;
  min-height: 170px;
  padding: 22px;
  overflow: hidden;
}

.preview-canvas.light {
  background: #ffffff;
  color: #111827;
}

.preview-canvas.paper {
  background: #f2ecd8;
  color: #1f2933;
}

.preview-canvas.dark {
  background: #111820;
  color: #f8fafc;
}

.preview-canvas.failed {
  background: #fff7ed;
  color: #9a3412;
}

.preview-text {
  word-break: break-word;
  line-height: 1.18;
}

.card-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.font-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.font-status {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.font-status.ready {
  background: #ecfdf5;
  color: #047857;
}

.font-status.pending,
.font-status.queued,
.font-status.loading {
  background: #eef2ff;
  color: #475569;
}

.font-status.failed {
  background: #ffedd5;
  color: #c2410c;
}

.download-button,
.delete-button {
  min-height: 36px;
  padding: 0 10px;
  font-size: 13px;
}

.download-button {
  background: var(--surface-2);
  color: var(--ink);
}

.download-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.delete-button {
  background: #fff1f2;
  color: #be123c;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .workspace {
    padding: 22px;
  }

  .control-strip {
    grid-template-columns: 1fr;
    display: grid;
  }
}
