:root {
  --bg: #f5f1ea;
  --surface: #ffffff;
  --text: #1d1a16;
  --muted: #7a716a;
  --accent: #2f5e4e;
  --accent-strong: #1f4536;
  --border: #d9d1c4;
  --error: #b8362f;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

#app {
  max-width: 780px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

header h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 600;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

#logout-btn {
  margin-left: auto;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0.55rem 1.1rem;
  font-weight: 500;
  transition: background 0.15s;
}

button:hover { background: var(--accent-strong); }
button:disabled { background: #b9b3a8; cursor: not-allowed; }

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button.ghost:hover { background: #ece6dc; }

label.upload {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface);
  font-size: 0.95rem;
}
label.upload:hover { border-color: var(--accent); }

#login-form {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: 360px;
  display: grid;
  gap: 0.85rem;
}

#login-form label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}

#login-form input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font: inherit;
  background: #fff;
}

#login-form input:focus {
  outline: none;
  border-color: var(--accent);
}

#login-form button {
  margin-top: 0.4rem;
}

.error {
  color: var(--error);
  font-size: 0.9rem;
  margin: 0;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  font: inherit;
  font-size: 1rem;
  background: var(--surface);
  resize: vertical;
  min-height: 200px;
  box-shadow: var(--shadow);
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.85rem 0 1.25rem;
}

.actions #translate-btn {
  margin-left: auto;
}

.meta {
  color: var(--muted);
  font-size: 0.88rem;
}

#progress-card,
#output-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.55rem;
  font-size: 0.95rem;
}

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

#progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.25s ease-out;
}

.output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.output-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.output-actions {
  display: flex;
  gap: 0.5rem;
}

#output-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: #faf6ef;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  max-height: 60vh;
  overflow: auto;
  font-family: inherit;
  font-size: 0.98rem;
  line-height: 1.55;
}

@media (max-width: 520px) {
  header { flex-wrap: wrap; }
  header h1 { font-size: 1.4rem; }
  .input-row { flex-wrap: wrap; }
  .actions { flex-wrap: wrap; }
}
