:root {
  --paper: #e6ebef;
  --sheet: #f6f8fa;
  --ink: #15202c;
  --muted: #586674;
  --rule: #c5ced6;
  --accent: #2850c8;
  --accent-ink: #ffffff;
  --accent-soft: #dfe6fa;
  --warn: #8f4c06;
  --warn-soft: #f5e5cf;
  --ok: #1d6a42;
  --ok-soft: #dcefe3;
  --bad: #a3271d;
  --bad-soft: #f7dfdc;
  --focus: #2850c8;
  color-scheme: light;
  font-family: 'IBM Plex Sans Hebrew', 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

/* Dark colors: from the system setting unless the page is set to light, or
   chosen on the page. The two blocks hold the same values. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f151c;
    --sheet: #17202a;
    --ink: #e3e9ef;
    --muted: #93a1af;
    --rule: #2a3642;
    --accent: #8aa6ff;
    --accent-ink: #0f151c;
    --accent-soft: #1f2b47;
    --warn: #e6a660;
    --warn-soft: #2f2418;
    --ok: #69c394;
    --ok-soft: #16291f;
    --bad: #f0877c;
    --bad-soft: #33191a;
    --focus: #8aa6ff;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #0f151c;
  --sheet: #17202a;
  --ink: #e3e9ef;
  --muted: #93a1af;
  --rule: #2a3642;
  --accent: #8aa6ff;
  --accent-ink: #0f151c;
  --accent-soft: #1f2b47;
  --warn: #e6a660;
  --warn-soft: #2f2418;
  --ok: #69c394;
  --ok-soft: #16291f;
  --bad: #f0877c;
  --bad-soft: #33191a;
  --focus: #8aa6ff;
  color-scheme: dark;
}

/* Language and theme controls, above every screen */

.prefs {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 20px;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px 0;
  font-size: 15px;
}
.prefs .link-button { padding: 4px 0; }
.theme-picker { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.theme-picker select {
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  font-size: 16px;
  line-height: 1.5;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.loading { color: var(--muted); }

button { font: inherit; color: inherit; }

.nowrap { white-space: nowrap; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--sheet);
  cursor: pointer;
}
.button:hover:not(:disabled) { border-color: var(--muted); }
.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
}
.button:disabled { opacity: 0.5; cursor: default; }

.link-button {
  border: 0;
  background: none;
  padding: 8px 0;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-button:disabled { color: var(--muted); cursor: default; }

/* Header */

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.top h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}
.top .machine { color: var(--muted); font-size: 15px; }
.top .actions { display: flex; gap: 16px; }

/* The sheet with one section per tool */

.sheet {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 10px;
}

.tool {
  padding: 22px 20px 20px;
}
.tool + .tool { border-top: 1px solid var(--rule); }

.tool h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  color: var(--muted);
}

/* The signed-in account is the largest thing on the page. */
.current {
  margin: 6px 0 2px;
  font-size: clamp(30px, 8vw, 42px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  direction: ltr;
  text-align: left;
}
.current-domain {
  margin: 0;
  color: var(--muted);
  direction: ltr;
  text-align: left;
}
/* An e-mail address reads left to right, but sits on the page's starting side. */
[dir="rtl"] .current,
[dir="rtl"] .current-domain { text-align: right; }
.current.none {
  font-size: 22px;
  font-weight: 500;
  color: var(--muted);
  direction: inherit;
  text-align: start;
}

.note {
  margin: 14px 0 0;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 15px;
}
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.busy { background: var(--accent-soft); color: var(--ink); }

.note details { margin-top: 6px; color: var(--ink); }
.note summary { cursor: pointer; }
.note pre {
  margin: 8px 0 0;
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  border-radius: 4px;
  background: var(--sheet);
  font-size: 12.5px;
  line-height: 1.45;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
}

.swap-label {
  margin: 18px 0 8px;
  font-size: 15px;
  color: var(--muted);
}

.targets {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
}
.targets li + li { border-top: 1px solid var(--rule); }

.target {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  gap: 2px;
  min-height: 56px;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  text-align: start;
  cursor: pointer;
}
.target:hover:not(:disabled) { background: var(--accent-soft); }
.target:disabled { cursor: default; opacity: 0.55; }
.target-name {
  font-size: 18px;
  font-weight: 500;
  direction: ltr;
  overflow-wrap: anywhere;
}
.target-when { color: var(--muted); font-size: 14px; white-space: nowrap; }

.empty {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.tool-footer { margin-top: 10px; }

/* Sign-in and first-run screens */

.gate {
  max-width: 360px;
  margin: 12vh auto 0;
}
.gate h1 { font-size: 24px; margin: 0 0 4px; }
.gate p { color: var(--muted); margin: 0 0 20px; }
.gate label { display: block; font-size: 15px; margin: 14px 0 6px; }
.gate input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
}
.gate .button.primary { width: 100%; margin-top: 20px; }
.gate .link-button { margin-top: 10px; }

.generated {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--sheet);
}
.generated p { margin: 0; font-size: 15px; }
.generated output {
  display: block;
  margin: 6px 0 12px;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-align: left;
  overflow-wrap: anywhere;
  user-select: all;
}
.generated-actions { display: flex; align-items: center; gap: 16px; }
.generated-actions .link-button { margin-top: 0; }
.generated .hint { margin-top: 12px; color: var(--muted); }
.gate .note { margin-top: 16px; }

/* Confirmation dialog */

.confirm {
  width: min(440px, calc(100vw - 32px));
  padding: 22px 20px 18px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--sheet);
  color: var(--ink);
}
.confirm::backdrop { background: rgb(15 21 28 / 0.45); }
.confirm h2 { margin: 0 0 10px; font-size: 19px; font-weight: 600; }
.confirm-body p { margin: 0 0 10px; color: var(--muted); }
.confirm-body .warn-line { color: var(--warn); }
.confirm-body label { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 10px; }
.confirm-body input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); }
.confirm-body .folders { margin: 4px 0 0; padding-inline-start: 18px; }
.confirm-body .hint { margin: -4px 0 10px; padding-inline-start: 28px; font-size: 14px; }
.confirm-actions { display: flex; gap: 10px; margin-top: 16px; }

.restarted { margin: 8px 0 0; padding-inline-start: 18px; color: var(--ink); }
.restarted li + li { margin-top: 4px; }
.restarted li.failed { color: var(--warn); }

@media (prefers-reduced-motion: no-preference) {
  .current.changed { animation: settle 600ms ease-out; }
  @keyframes settle {
    from { color: var(--accent); }
    to { color: var(--ink); }
  }
}
