@font-face {
  font-family: "Lufga";
  src: url("/fonts/Lufga-Regular-web.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Lufga";
  src: url("/fonts/Lufga-Bold-web.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f7f9fb;
  --surface: #ffffff;
  --soft: #f2f6f8;
  --text: #2d374f;
  --muted: #2d374f;
  --border: #dce4ea;
  --accent: #f7a502;
  --accent-dark: #d28b00;
  --accent-soft: #fff3d4;
  --shadow: 0 16px 48px rgba(31, 44, 71, 0.08);
  font-family: "Lufga", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

#app {
  height: 100svh;
  display: flex;
  flex-direction: column;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
  font-weight: 700;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
}

.topbar {
  flex: 0 0 auto;
  min-height: 0;
  padding: 6px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.brand,
.top-actions,
.row,
.queue-actions,
.range {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  gap: 18px;
}

.brand p,
.title p,
.field small,
.toggle small,
.note,
td small,
.detected em {
  color: var(--muted);
}

.mark {
  width: 150px;
  height: auto;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.mark img {
  width: 100%;
  height: auto;
  display: block;
}

.workspace {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(270px, 340px) minmax(520px, 1fr) minmax(290px, 360px);
  gap: 10px;
  padding: 10px;
  max-width: 1640px;
  margin: 0 auto;
  overflow: hidden;
}

.panel,
.mini,
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.source,
.settings {
  padding: 14px;
  overflow: auto;
}

.title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.title.compact {
  margin-bottom: 0;
}

.title > span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 7px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 700;
}

.drop {
  min-height: 168px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 18px;
  color: var(--text);
  background: linear-gradient(180deg, #fbfefe, #f4fbfa);
  border: 1.5px dashed var(--accent);
  border-radius: 8px;
  text-align: center;
}

.drop.over {
  background: var(--accent-soft);
}

.drop svg {
  width: 38px;
  height: 38px;
}

.secondary,
.primary,
.ghost {
  min-height: 38px;
  border-radius: 7px;
  border: 1px solid #c6d3dc;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
  background: var(--surface);
  color: var(--text);
}

.secondary:hover,
.ghost:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.primary {
  width: 100%;
  min-height: 48px;
  margin-top: 16px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--text);
  font-size: 16px;
}

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.ghost {
  border-color: transparent;
  background: transparent;
}

.file-label {
  display: inline-grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.file-label input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.mini {
  margin-top: 10px;
  padding: 12px;
  box-shadow: none;
}

.mini-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
}

.tree {
  min-height: 170px;
  max-height: 260px;
  overflow: auto;
  font-size: 13px;
}

.tree.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.tree-root,
.tree-line {
  padding: 8px 0;
  border-bottom: 1px solid #edf1f4;
}

.tree-root {
  font-weight: 700;
}

.tree-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
}

.tree-line span,
code {
  overflow-wrap: anywhere;
}

.tree-line small {
  color: var(--accent-dark);
  font-weight: 700;
}

.stat {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  padding: 12px;
  box-shadow: none;
}

.stat svg {
  width: 28px;
  height: 28px;
  color: var(--text);
}

.stat span,
.stat small {
  display: block;
  color: var(--muted);
}

.stat strong {
  display: block;
  margin: 4px 0;
  font-size: 30px;
  line-height: 1.1;
}

.queue {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}

.queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.queue-actions label {
  color: var(--text);
  font-size: 14px;
}

.queue-actions b {
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 0 12px;
  background: var(--soft);
  border-radius: 7px;
  font-size: 13px;
}

.table-wrap {
  min-height: 0;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid #e8eef2;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #fbfcfd;
  font-size: 12px;
  font-weight: 700;
}

.empty-row td {
  height: 260px;
  color: var(--muted);
  text-align: center;
}

.thumb {
  width: 100px;
  height: 66px;
  display: block;
  object-fit: cover;
  border-radius: 7px;
  background: var(--soft);
}

.detected {
  display: grid;
  gap: 3px;
}

.detected small {
  color: var(--accent);
  font-weight: 700;
}

.detected em {
  font-style: normal;
  font-size: 12px;
}

.file-name {
  display: block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name-input {
  width: min(270px, 100%);
  min-height: 42px;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
}

.progress {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr 54px;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.progress span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.bar {
  height: 8px;
  overflow: hidden;
  background: #e5ebef;
  border-radius: 999px;
}

.bar i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

.settings {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field > span,
.toggle strong {
  font-size: 14px;
  font-weight: 700;
}

select,
.field input[type="number"] {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
}

.input-group {
  display: grid;
  grid-template-columns: 1fr 64px;
  gap: 10px;
}

.input-group span,
output {
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-weight: 700;
}

.input-group span {
  background: var(--soft);
}

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

output {
  min-width: 52px;
  min-height: 34px;
}

.toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.toggle small {
  display: block;
  margin-top: 3px;
}

.toggle input {
  width: 44px;
  height: 24px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.wide {
  width: 100%;
}

.preview {
  display: grid;
  gap: 8px;
  padding: 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 8px;
}

code {
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.note {
  text-align: center;
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 10;
  width: min(520px, calc(100vw - 28px));
  padding: 13px 16px;
  color: #ffffff;
  background: var(--text);
  border-radius: 8px;
  box-shadow: 0 18px 52px rgba(23, 32, 51, 0.22);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1120px) {
  body {
    overflow: auto;
  }

  #app {
    height: auto;
    min-height: 100svh;
  }

  .workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .panel {
    height: auto;
    min-height: auto;
  }

  .settings {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings .title,
  .settings .primary,
  .settings .note,
  .preview {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .topbar,
  .queue-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .queue-actions,
  .row {
    flex-wrap: wrap;
  }

  .workspace {
    padding: 10px;
  }

  .settings,
  .progress {
    grid-template-columns: 1fr;
  }
}
