/* The palette, type scale and component shapes follow Treamer's social web app. */
:root {
  color-scheme: light dark;
  --bg: #f1f1f1;
  --surface: #ffffff;
  --surface-alt: #f8f8f8;
  --hover: #f1f1f1;
  --border: #e4e4e4;
  --text: #000000;
  --muted: #545454;
  --placeholder: #9d9fa2;
  --primary: #000000;
  --on-primary: #ffffff;
  --brand: #ed1c24;
  --danger: #ed1c24;
  --danger-bg: #fde8e9;
  --success-bg: #e6f8eb;
  --warning: #ff8200;
  --verified: #bcbec0;
  --badge-bg: #e4e4e4;
  --tag-bg: #e6f8eb;
  --tag-text: #1d6b37;
  --mark-bg: #fff3e6;
  --mark-text: #b85c00;
  --shadow: 0 4px 8px rgba(0, 0, 0, 0.14);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --surface-alt: #202020;
    --hover: #2a2a2a;
    --border: #333333;
    --text: #ffffff;
    --muted: #b0b0b0;
    --placeholder: #7a7a7a;
    --primary: #ffffff;
    --on-primary: #000000;
    --brand: #ff4a50;
    --danger: #ff5a60;
    --danger-bg: #3d1517;
    --success-bg: #12301c;
    --warning: #ff9a33;
    --verified: #555555;
    --badge-bg: #2e2e2e;
    --tag-bg: #16321f;
    --tag-text: #8fd6a5;
    --mark-bg: #45300f;
    --mark-text: #ffc27a;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/20px "Suisse Intl", system-ui, -apple-system, sans-serif;
}

a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
h1 { font-size: 24px; line-height: 32px; font-weight: 500; margin: 0; }
h2 { font-size: 20px; line-height: 28px; font-weight: 500; margin: 0 0 8px; }
code { font-family: var(--mono); }
.muted { color: var(--muted); }
.hint { margin: -8px 0 0; font-size: 12px; }
.spacer { flex: 1; }
[hidden] { display: none !important; }
a:focus-visible, button:focus-visible, .value:focus-visible, input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Buttons. A bare <button> has no look of its own; `.button` is the component, alone or with `primary`, `danger` or `text`. */
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; text-align: inherit; cursor: pointer; }
button:disabled { cursor: default; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--primary);
  border-radius: 3px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 16px;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}
.button.primary { background: var(--primary); color: var(--on-primary); }
.button.danger { border-color: var(--danger); color: var(--danger); }
.button.text { height: auto; padding: 0; border: 0; text-decoration: underline; text-underline-offset: 2px; }
@media (hover: hover) {
  .button:hover:not(:disabled) { background: var(--primary); color: var(--on-primary); }
  .button.primary:hover:not(:disabled) { opacity: 0.85; }
  .button.danger:hover:not(:disabled) { background: var(--danger); color: #ffffff; }
  .button.text:hover:not(:disabled) { background: none; color: var(--muted); }
}
.button:disabled { background: var(--border); border-color: var(--border); color: var(--placeholder); }
.button.text:disabled { background: none; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  color: var(--muted);
  transition: background-color 0.2s ease, color 0.2s ease;
}
.icon-button:hover { background: var(--hover); color: var(--text); }
.icon-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Form fields. `.field` is a name over a control, `.field.is-inline` a name beside it, `.check` a tick box with its text. */
.stack { display: flex; flex-direction: column; gap: 16px; }
.inline { display: inline-flex; gap: 8px; margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label, legend { font-size: 14px; line-height: 17.5px; font-weight: 500; }
.field.is-inline { flex-direction: row; align-items: center; gap: 8px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; }
.form-label { color: var(--muted); font-size: 12px; margin-right: 6px; }
fieldset { border: 1px solid var(--border); border-radius: 4px; display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0; padding: 8px 12px 12px; }
legend { padding: 0 4px; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  height: 36px;
  padding: 0 12px;
  outline: none;
  transition: border-color 0.2s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
::placeholder { color: var(--placeholder); opacity: 1; }
textarea { height: auto; padding: 8px 12px; resize: vertical; width: 100%; }
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: url("/images/chevron.svg");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  cursor: pointer;
}
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }

/* Badges: small facts about a row. A tag is a badge of its own colour whose name can be a button. */
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 20px;
  padding: 0 6px;
  border-radius: 3px;
  background: var(--badge-bg);
  color: var(--muted);
  font-size: 12px;
  line-height: 20px;
  overflow-wrap: anywhere;
}
.badge-remove { font-size: 14px; line-height: 1; }
.badge-remove:hover { color: var(--danger); }
.badge.tag { background: var(--tag-bg); color: var(--tag-text); }
button.tag-name:hover { text-decoration: underline; }
.tag.is-shown { box-shadow: inset 0 0 0 1px var(--tag-text); }
.tag.is-quiet .badge-remove { display: none; }
.tag.is-quiet:hover .badge-remove, .tag.is-quiet .badge-remove:focus-visible { display: block; }
.tag-editor { display: flex; flex-direction: column; gap: 6px; }
.tag-options { display: flex; flex-direction: column; }
.tag-option { padding: 6px 8px; border-radius: 4px; overflow-wrap: anywhere; }
.tag-option:hover, .tag-option:focus-visible { background: var(--hover); }
.tag-popover, .term-popover {
  position: absolute;
  z-index: 20;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: var(--shadow);
}
.tag-popover { width: 260px; }
.term-popover { max-width: 360px; }

/* Page frame. */
.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  min-height: 56px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 16px; font-weight: 500; text-decoration: none; }
.topbar nav { display: flex; gap: 24px; flex: 1; }
.topbar nav a { color: var(--muted); text-decoration: none; transition: color 0.15s ease; }
.topbar nav a:hover { color: var(--text); }
.topbar nav a[aria-current] { color: var(--brand); font-weight: 500; }
.topbar-user { display: flex; align-items: center; gap: 16px; }
.topbar-user a { color: var(--muted); text-decoration: none; }
.topbar-user form { margin: 0; }

main { padding: 24px; }

.page-head { margin-bottom: 20px; }
.tabs { display: flex; margin-top: 8px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a {
  padding: 12px 16px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current] { color: var(--text); border-bottom-color: var(--primary); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.toolbar h1 { margin-right: 16px; }
.toolbar input[type="search"] { flex: 1; min-width: 220px; }

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 16px;
}
.card-narrow { max-width: 480px; }
.card-centered { margin: 12vh auto 0; }
.card h1 { margin-bottom: 16px; }
.card > p { margin: 0 0 16px; }
.table + .card { margin-top: 24px; }

.banner { margin: 16px 24px 0; padding: 12px 16px; border-radius: 12px; }
main .banner { margin: 0 0 16px; }
.banner-error { background: var(--danger-bg); }
.banner-success { background: var(--success-bg); }
.banner p { margin: 0 0 4px; }
.token { user-select: all; word-break: break-all; }
.token-row { display: flex; align-items: center; gap: 12px; }

.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.table th, .table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table th { color: var(--muted); font-size: 12px; font-weight: 500; }
.user-projects { display: flex; flex-wrap: wrap; gap: 4px 16px; }

dialog {
  width: min(600px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  border: 0;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog h2 { margin: 0; overflow-wrap: anywhere; }
.dialog-actions { display: flex; align-items: center; gap: 8px; }
.other-languages summary { cursor: pointer; font-weight: 500; }
.other-languages[open] summary { margin-bottom: 12px; }
.empty-state { padding: 32px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: center; margin: 16px 0 0; min-height: 20px; }

/* Projects. */
.project-list { margin-bottom: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.project-row { display: flex; align-items: flex-start; gap: 24px; padding: 24px; border-bottom: 1px solid var(--border); }
.project-row:last-child { border-bottom: 0; }
.project-main { flex: 1; min-width: 0; }
.project-name { font-size: 20px; line-height: 28px; font-weight: 500; text-decoration: none; }
.project-name:hover { text-decoration: underline; }
.project-main .badges { margin-top: 10px; }
.project-stats { display: flex; gap: 40px; margin: 0; }
.project-stats div { min-width: 72px; text-align: right; }
.project-stats dt { color: var(--muted); font-size: 12px; }
.project-stats dd { margin: 0; font-size: 24px; line-height: 32px; font-weight: 500; font-variant-numeric: tabular-nums; }
.unverified-count { color: var(--warning); }
@media (max-width: 720px) {
  .project-row { flex-direction: column; }
  .project-stats { gap: 24px; }
  .project-stats div { text-align: left; }
}

/* Search anywhere. */
.search-form { flex: 0 1 420px; display: flex; margin: 0; position: relative; }
.search-form input { flex: 1; min-width: 0; border-radius: 8px; }
.search-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.suggestion-head { display: flex; justify-content: space-between; padding: 8px 12px; background: var(--surface-alt); color: var(--muted); font-size: 12px; }
.suggestion { display: flex; align-items: baseline; gap: 10px; padding: 10px 12px; text-decoration: none; white-space: nowrap; overflow: hidden; }
.suggestion:hover { background: var(--hover); }
.suggestion-title { overflow: hidden; text-overflow: ellipsis; }
.suggestion mark { background: var(--mark-bg); color: var(--mark-text); font-weight: 500; }
.suggestion-empty { margin: 0; padding: 12px; }
.search-group { margin-bottom: 28px; }
.search-group h2 .muted { font-weight: 400; font-size: 14px; margin-left: 8px; }
.search-result { display: grid; grid-template-columns: minmax(220px, 1fr) 2fr; gap: 16px; padding: 10px 12px; border-bottom: 1px solid var(--border); text-decoration: none; }
.search-result:last-child { border-bottom: 0; }
.search-result:hover { background: var(--hover); }
.search-text { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Keys. */
.keys { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.key { display: grid; grid-template-columns: minmax(220px, min(33%, 420px)) 1fr; border-bottom: 1px solid var(--border); }
.key:last-child { border-bottom: 0; }
.key-info { border-right: 1px solid var(--border); padding: 12px; min-width: 0; }
.key-info p { margin: 6px 0 0; font-size: 12px; white-space: pre-wrap; }
.key-name { font: 600 13px/20px var(--mono); overflow-wrap: anywhere; }
button.key-name:hover { text-decoration: underline; }
.key-name-text { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.key-info .badges { margin-top: 6px; }
.key mark { background: var(--mark-bg); color: inherit; border-radius: 2px; }
.row-actions { display: flex; gap: 2px; margin: 8px 0 0 -6px; visibility: hidden; }
.key:hover .row-actions, .glossary-table tr:hover .row-actions, .row-actions:focus-within { visibility: visible; }
@media (hover: none) { .row-actions { visibility: visible; } }
.translation { display: grid; grid-template-columns: 96px 1fr auto; border-bottom: 1px solid var(--border); }
.translation:last-child { border-bottom: 0; }
.lang { padding: 12px 10px; background: var(--surface-alt); color: var(--muted); font-size: 12px; text-align: right; overflow-wrap: anywhere; }
.lang.is-base { color: var(--text); font-weight: 500; }
.value { padding: 12px; cursor: text; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 44px; }
.value:hover { background: var(--hover); }
.value.is-empty { color: var(--placeholder); }
.value-editor { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.value-editor .actions { display: flex; align-items: center; gap: 8px; }
.verify { align-self: center; margin: 0 8px; color: var(--verified); }
.verify.is-unverified { color: var(--warning); }
.verify:hover { color: var(--verified); }
.verify.is-unverified:hover { color: var(--warning); }
.verify svg { width: 20px; height: 20px; }
.verify svg circle { fill: currentColor; stroke: currentColor; }
.verify svg path { stroke: var(--surface); }
.term { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; cursor: help; }
.term-popover .term-entry + .term-entry { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }
.term-popover p { margin: 6px 0 0; font-size: 12px; }
.key-screenshots { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.key-screenshot { border: 1px solid var(--border); border-radius: 4px; overflow: hidden; line-height: 0; }
.key-screenshot:hover { border-color: var(--primary); }
.key-screenshot img { height: 64px; width: auto; max-width: 120px; object-fit: cover; }
@media (max-width: 720px) {
  .key { grid-template-columns: 1fr; }
  .key-info { border-right: 0; border-bottom: 1px solid var(--border); }
}

/* Glossary. */
.glossary-section { font-size: 16px; line-height: 20px; margin: 24px 0 8px; }
.glossary-table { table-layout: fixed; }
.glossary-table tbody tr { cursor: pointer; }
.glossary-table tbody tr:hover { background: var(--hover); }
.glossary-table td { overflow-wrap: anywhere; vertical-align: top; }
.glossary-term { font-weight: 500; }
.glossary-table .badges { margin-top: 4px; font-weight: 400; }

/* Upload. */
.upload-card { max-width: 860px; }
.drop-zone { border: 1px dashed var(--placeholder); border-radius: 8px; padding: 40px 16px; text-align: center; color: var(--muted); margin: 16px 0; }
.drop-zone .button { color: var(--text); }
.drop-zone.is-over { border-color: var(--primary); background: var(--hover); }
.upload-file { display: grid; grid-template-columns: minmax(0, 1fr) 180px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.upload-name { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.upload-status.is-failed { color: var(--danger); }
.upload-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }

/* Screenshots. */
.screenshot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.screenshot-card { display: flex; flex-direction: column; gap: 4px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; transition: border-color 0.2s ease; }
.screenshot-card:hover { border-color: var(--muted); }
.screenshot-card img { width: 100%; height: 220px; object-fit: contain; background: var(--surface-alt); border-radius: 4px; }
.screenshot-card-title { font-weight: 500; overflow-wrap: anywhere; }
.screenshot-card.is-linked { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.matched-keys { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.attach-dialog { width: min(900px, 94vw); }
.attach-dialog input[type="search"] { width: 100%; margin-bottom: 12px; }
.screenshot-dialog { width: min(1000px, 94vw); }
.screenshot-detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; }
.screenshot-preview { background: var(--surface-alt); border-radius: 4px; text-align: center; }
.screenshot-preview img { max-width: 100%; max-height: 78vh; }
.screenshot-keys { display: flex; flex-direction: column; gap: 4px; }
.screenshot-key { display: flex; justify-content: space-between; gap: 8px; }
.screenshot-key-results { display: flex; flex-direction: column; }
.screenshot-key-result { display: flex; flex-direction: column; padding: 6px 8px; border-radius: 4px; }
.screenshot-key-result:hover { background: var(--hover); }
@media (max-width: 720px) { .screenshot-detail { grid-template-columns: 1fr; } }
.lightbox { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; margin: 0; padding: 12px; border-radius: 0; background: rgba(0, 0, 0, 0.88); color: #ffffff; box-shadow: none; }
.lightbox[open] { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.lightbox-bar { display: flex; align-items: center; gap: 12px; width: 100%; }
.lightbox img { min-height: 0; max-width: 100%; flex: 1; object-fit: contain; }
.lightbox .button { border-color: #ffffff; color: #ffffff; }
.lightbox .button:hover { background: #ffffff; color: #000000; }

/* History. */
.history-dialog { width: min(720px, 92vw); }
.changes.card { padding: 0 24px; }
.change { padding: 16px 0; border-bottom: 1px solid var(--border); }
.change:last-child { border-bottom: 0; }
.change-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.change-author { font-weight: 500; }
.change-subject { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.change-field { display: grid; grid-template-columns: 120px 1fr; gap: 8px; margin-top: 6px; }
.change-values { display: flex; flex-direction: column; gap: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.change-values del { color: var(--muted); }
.change-values ins { text-decoration: none; }
