:root {
  --blue: #1d4ed8;
  --blue-dark: #1e40af;
  --ink: #1f2937;
  --muted: #6b7280;
  --bg: #f5f7fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --danger: #b91c1c;
  --ok: #047857;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--blue);
  color: #fff;
}

header h1 { margin: 0; font-size: 1.25rem; }
.logo { margin-right: 0.25rem; }

.header-right { display: flex; align-items: center; gap: 0.5rem; }

.icon-btn {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
}

.settings-card { border: 2px solid var(--blue); }

.quota-badge {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  font-size: 0.85rem;
}
.quota-badge.exhausted { background: var(--danger); }

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.25rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

h2 { margin-top: 0; font-size: 1.1rem; }
.hint { color: var(--muted); font-size: 0.9rem; }

.samples-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.samples-label { font-size: 0.85rem; color: var(--muted); }
.sample-select {
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
  max-width: 100%;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  transition: border-color 0.15s;
}
.dropzone.dragging { border-color: var(--blue); }

textarea {
  width: 100%;
  border: none;
  resize: vertical;
  font: inherit;
  outline: none;
  min-height: 8rem;
}

.dropzone-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
}

.file-btn {
  background: #eef2ff;
  color: var(--blue-dark);
  padding: 0.35rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}

.file-name { font-size: 0.85rem; color: var(--muted); }
.char-count { margin-left: auto; font-size: 0.8rem; color: var(--muted); }
.char-count.over { color: var(--danger); font-weight: 600; }

button {
  font: inherit;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
}

button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  margin-top: 0.9rem;
}
button.primary:hover:not(:disabled) { background: var(--blue-dark); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.ghost { border: none; background: none; color: var(--muted); }

.lang-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
select, input[type="text"] {
  font: inherit;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.tier-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
}

.tier-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.tier-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.tier-head h3 { margin: 0; }
.tier-price { font-size: 1.3rem; font-weight: 700; color: var(--blue-dark); }
.tier-price span { font-size: 0.7rem; font-weight: 400; color: var(--muted); }
.tier-free-chip {
  background: #ecfdf5;
  color: var(--ok);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.lang-primary {
  background: #eef2ff;
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.6rem;
}
.lang-primary label { font-weight: 700; font-size: 1.05rem; }
.lang-primary select, .lang-primary input {
  font-size: 1.05rem;
  padding: 0.5rem 0.75rem;
}
.tier-blurb { font-size: 0.88rem; }
.tier-model { font-size: 0.75rem; color: var(--muted); font-family: ui-monospace, monospace; }

.tier-examples { margin: 0.4rem 0 0.6rem; font-size: 0.85rem; }
.tier-examples summary { cursor: pointer; color: var(--blue-dark); }
.example { margin-top: 0.6rem; }
.example-label { font-weight: 600; font-size: 0.8rem; }
.example-cols { display: grid; grid-template-columns: 1fr; gap: 0.4rem; }
.example-cols p {
  margin: 0.15rem 0 0;
  background: var(--bg);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}
.col-tag { font-size: 0.7rem; text-transform: uppercase; color: var(--muted); }

.translate-btn { margin-top: auto; }

.result-meta { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.pill {
  background: #eef2ff;
  color: var(--blue-dark);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
}

.result-text {
  white-space: pre-wrap;
  background: var(--bg);
  border-radius: 8px;
  padding: 1rem;
  max-height: 24rem;
  overflow-y: auto;
}

.result-actions { display: flex; gap: 0.6rem; margin-top: 0.9rem; }

.install-banner {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.promo-card {
  background: #fffaf0;
  border-color: #f0e0c0;
}
.promo-card h2 { color: #92600a; }
.promo-link {
  display: inline-block;
  background: #92600a;
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
}
.promo-link:hover { background: #7a4f08; }

.pack-card {
  border: 2px solid var(--blue);
  background: #f0f5ff;
}
.pack-card h2 { color: var(--blue-dark); }

.status {
  border-radius: 8px;
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.status.busy { background: #eef2ff; color: var(--blue-dark); }
.status.busy::before { content: "⏳ "; }
.status.error { background: #fef2f2; color: var(--danger); }
.status.ok { background: #ecfdf5; color: var(--ok); }

.link-btn {
  padding: 0;
  color: var(--blue-dark);
  text-decoration: underline;
  font-size: inherit;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1rem;
}
.apps-links { margin-top: 0.4rem; }
.apps-links a {
  color: var(--muted);
  text-decoration: underline;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .example-cols { grid-template-columns: 1fr 1fr; }
}
