:root {
  color-scheme: dark;
  --background: #141414;
  --surface: #202020;
  --surface-muted: #2f2f2f;
  --border: #3a3a3a;
  --text: #f4f4f4;
  --muted: #b4b4b4;
  --accent: #ffc800;
  --button: #787878;
  --focus: #ffc800;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell[hidden],
.auth-screen[hidden] {
  display: none;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  display: grid;
  gap: 16px;
  width: min(100%, 380px);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.login-panel label {
  display: grid;
  gap: 6px;
}

.login-panel span {
  color: var(--muted);
  font-size: 13px;
}

.login-panel input {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #141414;
}

.button.compact {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.button.compact:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button.secondary {
  background: var(--button);
  color: #ffffff;
}

.login-error {
  min-height: 20px;
  color: #ff8a80;
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

h1 {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.2;
}

p {
  margin: 0;
}

#file-status,
.status-row,
.language-picker span {
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-name {
  max-width: 260px;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button.danger {
  border-color: #6b2d2d;
  color: #ff6b6b;
}

.icon-button.danger:hover {
  background: #3a2020;
  border-color: #ff6b6b;
}

.editor-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.language-picker {
  display: grid;
  gap: 6px;
  width: min(100%, 280px);
}

.language-picker span {
  font-size: 13px;
}

.language-picker select {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.login-panel input:focus,
.language-picker select:focus,
.translation-text:focus {
  outline: 0;
}

.login-panel input:focus,
.language-picker select:focus {
  border-color: var(--button);
}

main {
  padding: 18px 28px 28px;
}

.status-row {
  font-size: 14px;
}

.editor {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.editor-head,
.translation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.editor-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.editor-head div,
.translation-cell {
  min-width: 0;
}

.editor-head div {
  padding: 10px 12px;
}

.editor-head div:first-child,
.translation-cell:first-child {
  border-right: 1px solid var(--border);
}

.translation-row {
  border-bottom: 1px solid var(--border);
}

.translation-row:last-child {
  border-bottom: 0;
}

.translation-cell {
  display: grid;
  background: var(--surface);
}

.translation-cell.source {
  background: #1b1b1b;
}

.translation-cell.status-validated {
  background: #1f2a20;
}

.translation-cell.status-modified {
  background: #332b1a;
}

.translation-cell.status-none {
  background: var(--surface);
}

.translation-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 10px 10px;
  background: transparent;
}

.save-button[hidden] {
  display: none;
}

.translation-text {
  display: block;
  width: 100%;
  min-height: 72px;
  height: auto;
  padding: 12px;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--text);
  line-height: 1.45;
  resize: none;
}

.translation-text[readonly] {
  color: #d8d8d8;
  cursor: default;
}

.translation-cell:not(.source) .translation-text[readonly] {
  color: #b4b4b4;
}

.history {
  border-top: 1px solid var(--border);
  background: transparent;
}

.history summary {
  cursor: pointer;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
}

.history-item {
  display: grid;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--border);
}

.history-actions {
  display: flex;
  justify-content: flex-end;
  padding: 10px;
  border-top: 1px solid var(--border);
}

.proposal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.history-item.original {
  background: rgba(255, 255, 255, 0.02);
}

.history-meta {
  color: var(--muted);
  font-size: 12px;
}

.history-text {
  margin: 0;
  white-space: pre-wrap;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  main {
    padding: 14px;
  }

  .language-picker {
    width: 100%;
  }

  .header-controls {
    width: 100%;
    justify-content: space-between;
  }

  .editor-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .editor-head,
  .translation-row {
    grid-template-columns: 1fr;
  }

  .editor-head div:first-child,
  .translation-cell:first-child {
    border-right: 0;
  }

  .editor-head div:last-child {
    border-top: 1px solid var(--border);
  }

  .translation-cell:first-child {
    border-bottom: 1px solid var(--border);
  }
}
