:root {
  --bg: #14110d;          /* sepia black */
  --panel: #1a1611;
  --ink: #eadfc8;         /* parchment */
  --muted: #a89a80;
  --line: rgba(201, 176, 135, 0.26);
  --grid: rgba(201, 176, 135, 0.055);
  --blue: #4f8fe8;
  --green: #5db36a;
  --red: #d8664f;
  --gold: #e0b34f;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 14px 14px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
}
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sheet { max-width: 1040px; margin: 0 auto; padding: 40px 20px 24px; }

.head { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 18px; }
h1 { font-weight: 400; font-size: 30px; letter-spacing: 0.02em; margin: 0; }
.arrows { color: var(--muted); padding: 0 4px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; }

.hint {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--line); background: rgba(79, 143, 232, 0.07);
  padding: 8px 12px; margin: 0 0 18px; font-size: 15px;
}
.hint-icon {
  display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: var(--bg);
  align-items: center; justify-content: center; vertical-align: middle; margin: 0 2px;
}
.hint-icon svg { width: 15px; height: 15px; stroke-width: 2.4; }
.hint-close { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1; }

/* Two boxes side by side; the swap button sits on the line between them, level with the language names. */
.grid { position: relative; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); background: rgba(20, 17, 13, 0.85); }
.cell { display: flex; flex-direction: column; min-width: 0; padding: 14px 16px; }
.cell.target { border-left: 1px solid var(--line); }
.cell-head, .cell-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 28px; }
.cell-head { border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 10px; font-size: 18px; letter-spacing: 0.03em; }
.cell.target .cell-head { padding-left: 26px; }            /* room for the swap button */
.cell-foot { margin-top: 8px; font-size: 13px; }
.tag { font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px solid var(--line); padding: 0 6px; margin-left: 6px; vertical-align: 2px; letter-spacing: 0; }

.swap {
  position: absolute; left: 50%; top: 32px; transform: translate(-50%, -50%); z-index: 2;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: border-color 0.2s, transform 0.3s;
}
.swap svg { width: 22px; height: 22px; }
.swap:hover, .swap:focus-visible { border-color: var(--ink); }
.swap.turn { transform: translate(-50%, -50%) rotate(180deg); }

textarea {
  width: 100%; resize: vertical; min-height: 150px;
  background: transparent; color: var(--ink); border: 0; outline: none;
  font: inherit; font-size: 19px; line-height: 1.5; padding: 0;
}
textarea::placeholder, .placeholder { color: #6f6553; }
.output { min-height: 150px; font-size: 19px; white-space: pre-wrap; overflow-wrap: anywhere; }
.output.stale { opacity: 0.55; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }

button { font: inherit; color: inherit; }
.go {
  margin-left: auto;
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: opacity 0.2s, transform 0.15s;
}
.go svg { width: 24px; height: 24px; stroke-width: 2.4; }
.go:hover:not(:disabled) { transform: translateX(2px); }
.go:disabled { opacity: 0.3; cursor: default; }
.primary {
  border: 1px solid var(--ink); background: var(--ink); color: var(--bg);
  padding: 8px 18px; cursor: pointer; letter-spacing: 0.02em;
}
.primary:hover { opacity: 0.9; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 15px; padding: 0; }
.link:hover { color: var(--ink); }

/* Status: blue pulse while translating, green when ready, red on error */
.dot { width: 12px; height: 12px; border-radius: 50%; background: transparent; flex: none; }
.dot.busy { background: var(--blue); animation: pulse 1.2s ease-in-out infinite; }
.dot.done { background: var(--green); box-shadow: 0 0 0 3px rgba(93, 179, 106, 0.18); transition: background 0.3s; }
.dot.error { background: var(--red); }
@keyframes pulse { 0%, 100% { opacity: 0.2; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1); } }

/* Feedback: a card under the translation that asks for an opinion */
.feedback {
  margin-top: 16px; border: 1px solid rgba(224, 179, 79, 0.55); background: rgba(224, 179, 79, 0.07);
  padding: 16px 18px; animation: arrive 0.45s ease-out, glow 1.6s ease-out 0.45s 1;
}
@keyframes arrive { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes glow { 0% { box-shadow: 0 0 0 0 rgba(224, 179, 79, 0.45); } 100% { box-shadow: 0 0 0 14px rgba(224, 179, 79, 0); } }
.feedback h2 { font-size: 19px; font-weight: 400; margin: 0; color: var(--gold); }
.feedback p { margin: 2px 0 0; }
.step { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.choices { display: flex; gap: 10px; flex-wrap: wrap; }
.choice {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); font-size: 16px; transition: border-color 0.2s, color 0.2s;
}
.choice svg { width: 20px; height: 20px; }
.choice.down svg { transform: rotate(180deg); }
.choice:hover { border-color: var(--ink); }
.choice.chosen[data-verdict="up"] { color: var(--green); border-color: var(--green); }
.choice.chosen[data-verdict="down"] { color: var(--red); border-color: var(--red); }

.stars, .correction, .thanks { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.stars { justify-content: flex-start; }
.star-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.star { background: none; border: 0; font-size: 34px; line-height: 1; color: #4d4537; cursor: pointer; padding: 0 3px; transition: transform 0.1s; }
.star:hover { transform: scale(1.12); }
.star.lit { color: var(--gold); }

.correction { display: block; }
.correction-title { font-size: 18px; margin: 0 0 10px; }
.pill { font-family: var(--mono); font-size: 12px; border: 1px solid var(--line); padding: 2px 8px; margin-left: 6px; vertical-align: 2px; white-space: nowrap; }
.pair { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; }
.pair dt { color: var(--muted); font-size: 14px; padding-top: 2px; }
.pair dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.pair .machine { color: var(--muted); }
.correction label { display: block; font-size: 15px; margin-bottom: 6px; }
.correction textarea { min-height: 80px; border: 1px solid var(--ink); padding: 8px 10px; font-size: 18px; background: rgba(20, 17, 13, 0.6); }
.actions { display: flex; align-items: center; gap: 16px; margin-top: 10px; }
.thanks { color: var(--green); margin-bottom: 0; }
.error { color: var(--red); margin: 10px 0 0; font-size: 15px; }

.foot { display: flex; justify-content: space-between; margin-top: 14px; font-size: 13px; font-family: var(--mono); }

@media (prefers-reduced-motion: reduce) {
  .dot.busy { animation-duration: 2.4s; }
  .feedback { animation: none; }
  .swap, .swap.turn { transition: none; }
}

@media (max-width: 760px) {
  .sheet { padding-top: 22px; }
  h1 { font-size: 24px; }
  .grid { grid-template-columns: 1fr; }
  .cell.target { border-left: 0; border-top: 1px solid var(--line); }
  .cell.target .cell-head { padding-left: 0; }
  /* Stacked boxes: the swap button sits on the line between them. */
  .swap { position: relative; left: auto; top: auto; transform: none; justify-self: center; margin: -22px 0; }
  .swap svg { transform: rotate(90deg); }
  .swap.turn { transform: rotate(180deg); }
  .go svg, .hint-icon svg { transform: rotate(90deg); }   /* translate "down" into the box below */
  textarea, .output { min-height: 110px; font-size: 18px; }
  .pair { grid-template-columns: 1fr; gap: 2px; }
  .pair dd { margin-bottom: 8px; }
}

.account { margin-top: 20px; padding: 14px 0; border-top: 1px solid var(--line); font-size: 15px; }
.account p { margin: 0 0 10px; }
.account summary { cursor: pointer; color: var(--gold); }
.foot { flex-wrap: wrap; gap: 8px 24px; }

#google-signin { margin-top: 12px; min-height: 44px; }
.credits { max-width: 100%; }
.credits summary { cursor: pointer; color: var(--muted); }
.credits dl { margin: 10px 0 0; }
.credits dt { color: var(--ink); }
.credits dd { margin: 0 0 10px; color: var(--muted); }
