/* Design tokens: one spacing scale, one radius scale, one palette. */
:root {
  --bg: #101216;
  --surface: #1a1d23;
  --surface-2: #21252d;
  --surface-3: #282d37;
  --border: #2c313b;
  --border-strong: #3a4150;
  --text: #e2e5ea;
  --text-muted: #99a1ae;
  --text-faint: #6d7583;
  --accent: #7ec8ff;
  --accent-soft: rgba(126, 200, 255, 0.08);
  --green: #22a06b;
  --green-hover: #2ab377;
  --blue: #2d6cdf;
  --red: #e07a6e;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --shadow-card: 0 16px 40px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-btn: 0 4px 14px rgba(34, 160, 107, 0.28);
  --ring: 0 0 0 3px rgba(126, 200, 255, 0.25);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
}
[hidden] {
  display: none !important;
}

/* Base stack covers Latin, Cyrillic, Vietnamese, plus broad CJK and Thai
   fallbacks so every supported language renders on Windows, macOS, Linux,
   and mobile. */
body {
  font-family:
    "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial,
    "Noto Sans", "PingFang SC", "Hiragino Sans", "Microsoft YaHei",
    "Microsoft JhengHei", "Yu Gothic UI", Meiryo, "Malgun Gothic",
    "Apple SD Gothic Neo", "Leelawadee UI", Thonburi, "Noto Sans Thai",
    sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--space-5) var(--space-4);
}
/* Language-specific preferred fonts (html[lang] is set by the i18n system) */
:lang(zh-Hans) { font-family: "Segoe UI", system-ui, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif; }
:lang(zh-Hant) { font-family: "Segoe UI", system-ui, "PingFang TC", "Hiragino Sans CNS", "Microsoft JhengHei", "Noto Sans TC", sans-serif; }
:lang(ja) { font-family: "Segoe UI", system-ui, "Hiragino Sans", "Yu Gothic UI", Meiryo, "Noto Sans JP", sans-serif; }
:lang(ko) { font-family: "Segoe UI", system-ui, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; }
:lang(th) { font-family: "Segoe UI", system-ui, "Leelawadee UI", Thonburi, "Noto Sans Thai", sans-serif; }
/* Thai stacked diacritics need extra line height to avoid clipping */
:lang(th) body, :lang(th) button, :lang(th) .hint2 { line-height: 1.6; }

/* The whole app is one compact centered column: selector, card, footer. */
#app {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Language selector: right-aligned to the card's edge, part of the layout. */
#lang-row {
  display: flex;
  justify-content: flex-end;
  font-size: 12px;
  color: var(--text-muted);
}
#lang-row label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
#lang-row select {
  appearance: none;
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%2399a1ae' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat right 8px center / 12px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 28px 6px 10px;
  max-width: 180px;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
#lang-row select:hover {
  border-color: var(--border-strong);
  background-color: var(--surface-2);
}
#lang-row select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

#card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  box-shadow: var(--shadow-card);
}
h1 {
  font-size: 19px;
  font-weight: 650;
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.3px;
  text-align: center;
  overflow-wrap: break-word;
}

.filedrop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  background: var(--surface-2);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.filedrop:hover,
.filedrop.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.filedrop:focus-within {
  border-color: var(--accent);
}
.filedrop input {
  display: none;
}
.filedrop .drop-icon {
  width: 36px;
  height: 36px;
  color: var(--text-faint);
  margin-bottom: var(--space-1);
  transition: color 0.2s ease, transform 0.2s ease;
}
.filedrop:hover .drop-icon,
.filedrop.dragover .drop-icon {
  color: var(--accent);
  transform: translateY(-2px);
}
.filedrop .drop-line1 {
  font-size: 15px;
  font-weight: 550;
  color: var(--text);
  overflow-wrap: anywhere;
}
.filedrop .hint {
  font-size: 12px;
  color: var(--text-faint);
}

#error {
  margin: 0;
  color: var(--red);
  font-size: 13px;
  text-align: center;
  overflow-wrap: anywhere;
}

#result {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  text-align: center;
}
#result-name {
  font-size: 13px;
  color: var(--text);
  overflow-wrap: anywhere;
}
#result-modes {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
#result-modes .arrow {
  color: var(--text-faint);
}
.chip {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-3);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 12px;
  letter-spacing: 0.3px;
}
.chip-to {
  background: rgba(45, 108, 223, 0.22);
  border-color: var(--blue);
  color: #fff;
}

button {
  width: 100%;
  padding: 13px;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.4px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--green);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: background-color 0.15s ease, transform 0.15s ease,
    box-shadow 0.15s ease;
  font-family: inherit;
}
button:hover {
  background: var(--green-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(34, 160, 107, 0.35);
}
button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-btn);
}
button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-btn), var(--ring);
}

.hint2 {
  font-size: 11px;
  color: var(--text-faint);
}

footer {
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-faint);
  text-align: center;
}
footer p {
  margin: 0;
}

/* small screens: tighter card, keep the drop target large */
@media (max-width: 480px) {
  body {
    padding: var(--space-4) var(--space-3);
  }
  #card {
    padding: var(--space-5) var(--space-4) var(--space-4);
  }
  .filedrop {
    padding: var(--space-5) var(--space-3);
  }
}
