:root {
  --bg: #F3F3F3;
  --surface: #FFFFFF;
  --line: #DADCE3;
  --ink: #10151c;
  --muted: #667085;
  --faint: #98a2b3;
  --brand: #304697;
  --brand-hover: #283C7E;
  --brand-ink: #FFFFFF;
  --brand-soft: #DCE0F0;
  --indigo: #304494;
  --topbar: #293D8D;
  --topbar-ink: #FFFFFF;
  --topbar-muted: #B9C2E6;
  --ok: #0E7A4F;
  --bad: #D21224;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 21, 28, .04), 0 8px 24px rgba(16, 21, 28, .06);
  --ease: cubic-bezier(.2, .7, .3, 1);
  --font-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.55 var(--font-base);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: var(--topbar);
  color: var(--topbar-ink);
}

.topbar-logo {
  display: inline-flex;
  background: #FFFFFF;
  border-radius: 10px;
  padding: 6px 12px;
}

.logo { height: 28px; width: auto; object-fit: contain; }

.topbar-title {
  color: var(--topbar-muted);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding-left: 16px;
  border-left: 1px solid rgba(255, 255, 255, .22);
}

.stage {
  width: min(720px, calc(100% - 40px));
  margin: 4vh auto 80px;
}

/* tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 auto 22px;
  width: fit-content;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  padding: 8px 22px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease);
}

.tab:hover { color: var(--ink); }

.tab.is-active {
  background: var(--brand);
  color: var(--brand-ink);
}

/* language bar */
.langbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
}

.langbar select {
  appearance: none;
  min-width: 168px;
  padding: 10px 34px 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round'><path d='m6 9 6 6 6-6'/></svg>") no-repeat right 12px center/14px;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.langbar select:focus-visible,
.tab:focus-visible,
button:focus-visible,
a:focus-visible,
textarea:focus-visible,
.drop:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.swap {
  appearance: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  transition: transform .3s var(--ease), color .18s var(--ease);
}

.swap:hover { color: var(--brand); }
.swap.spin { transform: rotate(180deg); }

/* panels & views */
.panel { display: none; }
.panel.is-active { display: block; }
.view { display: none; }
.view.is-active { display: block; animation: rise .32s var(--ease) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .view.is-active { animation: none; }
  * { transition-duration: .01ms !important; }
}

/* dropzone */
.drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 54px 24px;
  background: var(--surface);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: border-color .18s var(--ease), background .18s var(--ease), transform .18s var(--ease);
}

.drop:hover { border-color: var(--brand); }

.drop.over {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: scale(1.008);
}

.drop-icon {
  width: 44px;
  height: 44px;
  color: var(--brand);
  margin-bottom: 10px;
}

.drop-icon svg { width: 100%; height: 100%; }
.drop-title { margin: 0; font-size: 17px; font-weight: 600; }
.drop-sub { margin: 0; color: var(--muted); font-size: 14px; }
.link { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }

.drop-formats {
  margin: 14px 0 0;
  color: var(--faint);
  font-size: 12px;
  letter-spacing: .06em;
}

/* selected file */
.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.chip-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-size { color: var(--faint); font-size: 13px; margin-left: auto; white-space: nowrap; }

.chip-x {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.chip-x:hover { color: var(--bad); }

/* buttons */
.primary {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 14px 20px;
  border: 0;
  border-radius: 11px;
  background: var(--brand);
  color: var(--brand-ink);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: filter .18s var(--ease), transform .12s var(--ease);
}

.primary:hover:not(:disabled) { background: var(--brand-hover); }
.primary:active:not(:disabled) { transform: translateY(1px); }
.primary:disabled { opacity: .45; cursor: not-allowed; }

.ghost {
  display: block;
  margin: 22px auto 0;
  padding: 9px 20px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.ghost:hover { color: var(--bad); border-color: var(--bad); }

.linkbtn {
  display: block;
  margin: 16px auto 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.linkbtn:hover { color: var(--brand); }

/* running */
.run-file {
  margin: 0 0 18px;
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--brand);
  transition: width .45s var(--ease);
}

.run-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.pct { font-weight: 600; color: var(--ink); }

.steps {
  list-style: none;
  margin: 26px 0 0;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  color: var(--faint);
  font-size: 14px;
  transition: color .25s var(--ease);
}

.steps li::before {
  content: "";
  flex: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  opacity: .45;
}

.steps li.done { color: var(--muted); }

.steps li.done::before {
  border-color: var(--ok);
  background: var(--ok) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'><path d='M20 6 9 17l-5-5'/></svg>") no-repeat center/10px;
  opacity: 1;
}

.steps li.now {
  color: var(--ink);
  font-weight: 600;
}

.steps li.now::before {
  border-color: var(--brand);
  border-right-color: transparent;
  opacity: 1;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* done */
.done-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  padding: 13px;
  color: var(--brand-ink);
  background: var(--ok);
  border-radius: 50%;
}

.done-mark svg { width: 100%; height: 100%; }
.done-title { margin: 0; text-align: center; font-size: 19px; font-weight: 600; }

.done-sub {
  margin: 6px 0 22px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* text tab */
.textgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 640px) {
  .textgrid { grid-template-columns: 1fr; }
  .langbar { flex-wrap: wrap; }
}

.textcell { position: relative; }

.textcell textarea {
  width: 100%;
  height: 300px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  line-height: 1.6;
  resize: vertical;
}

.textcell textarea::placeholder { color: var(--faint); }
#text-out { background: var(--bg); }

.counter {
  position: absolute;
  right: 12px;
  bottom: 10px;
  color: var(--faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.copy {
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.copy:hover { color: var(--brand); border-color: var(--brand); }

.spinner {
  position: absolute;
  right: 16px;
  bottom: 14px;
  width: 15px;
  height: 15px;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.error {
  margin: 14px 0 0;
  color: var(--bad);
  font-size: 14px;
  text-align: center;
}
