:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --border: #d8dbe0;
  --accent: #4f6df5;
  --accent-hover: #3d58d8;
  --accent-text: #ffffff;
  --error: #c93b3b;
  --warn-bg: #fff4d6;
  --warn-text: #7a5b00;
  --success: #1e8e4e;
  --output-bg: #eef1ff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1e2127;
    --text: #e8eaed;
    --muted: #9aa1ab;
    --border: #343941;
    --accent: #6b85ff;
    --accent-hover: #8199ff;
    --accent-text: #0d1020;
    --error: #ff7b7b;
    --warn-bg: #3a3320;
    --warn-text: #f2d478;
    --success: #5bd48e;
    --output-bg: #232a3d;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.center-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}

.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.login-card form {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

input,
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

button {
  font: inherit;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.primary {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

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

.full {
  width: 100%;
}

.toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 1.25rem;
}

.toggle-btn {
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  padding: 0.45rem 1rem;
  border-radius: 7px;
}

.toggle-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.field-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.history {
  margin-top: 0.85rem;
}

.history summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  user-select: none;
}

.history textarea {
  margin-top: 0.5rem;
}

#translate-btn {
  margin-top: 1rem;
}

.hint {
  font-size: 0.8rem;
  margin: 0.4rem 0 0;
  text-align: center;
}

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

.error {
  color: var(--error);
  margin: 0.75rem 0 0;
}

.success {
  color: var(--success);
  margin: 0.5rem 0 0;
}

.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
}

.output-wrap {
  margin-top: 1.5rem;
}

.output {
  background: var(--output-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  min-height: 3rem;
}

.admin {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.admin .row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.admin .row input {
  flex: 1;
}

@media (max-width: 480px) {
  .admin .row {
    flex-direction: column;
  }
}
