/* Base styles for every page (app, landing, login, privacy).
   All colours are variables in :root below (colour scheme in one place). Contains basic elements (buttons, fields,
   tables), layout, sidebar, cards and the toast message. */

/* Font (bundled locally, no Google server needed; licence: fonts/LICENSE-Inter.txt) */

@font-face {
  font-family: "Inter";
  src: url("../../fonts/Inter-Regular.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("../../fonts/Inter-SemiBold.woff") format("woff");
  font-weight: 500 650;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("../../fonts/Inter-Bold.woff") format("woff");
  font-weight: 700 900;
  font-display: swap;
}

@font-face {
  font-family: "Inter Display";
  src: url("../../fonts/InterDisplay-Bold.woff") format("woff");
  font-weight: 700 900;
  font-display: swap;
}

:root {
  --bg: #f4f6fa;
  --panel: #fff;
  --ink: #151b2a;
  --muted: #646d80; /* darker than before: at least 4.5:1 contrast on white and grey */
  --label: #596478;
  --line: #e5e8ef;
  --nav: #111827;
  --nav-hover: #222c41;
  --accent: #172033;
  --soft: #eef1f6;
  --green: #137a52;
  --red: #b84040;
  --orange: #c77700;
  --spending: var(--red); /* expenses: red everywhere */
  /* Brand colour (also logo and landing page): buttons, active menu item, progress */
  /* Main colour (Lila); the other accent colours are in themes.css */
  --brand: #6b40c4;
  --brand-hover: #56339e;
  --brand-soft: #efe9fb;
  --brand-light: #b89cff;
  --brand-text: var(--brand);
  /* Other surfaces, overridden in dark mode (see below) */
  --field: #fff;
  --line-strong: #bac2d0;
  --row-hover: rgba(23, 32, 51, 0.02);
  --track: #edf0f4;
  --bar: color-mix(in srgb, var(--orange) 45%, #fff); /* "Sparentwicklung": savings, orange */
  --bar-hover: var(--orange);
  --good-soft: #e8f4ee;
  --warn-soft: #fff4df;
  --warn-text: #845d17;
  --danger-line: #f0caca;
  --spending-text: var(--red);
  --orange-text: #9a5a00; /* orange for text (the bars stay --orange) */
  --shadow: 0 8px 28px rgba(25, 35, 55, 0.035);

  /* Text and icons on dark or coloured areas (menu, buttons, landing sections) */
  --on-dark: #fff;
  --on-dark-soft: #e1e6f0;
  --on-dark-muted: #aab2c4;
  --on-dark-faint: #8791a8;
  --on-dark-error: #ff9b9b;
  --on-dark-accent: #6fd3a3;
  --knob: #fff; /* round knob of the on/off switches */

  /* Menu (sidebar on the computer, top and bottom bar on the phone) */
  --nav-line: #303849;
  --nav-active: #33415c;

  /* Keyboard focus, light bulb button, dark toast */
  --focus-ring: #78a8ff;
  --bulb-glow: #ffd84d;
  --bulb-line: #b8860b;
  --bulb-line-on: #e0a800;
  --toast-dark: #2a3446;

  /* Colour choice under Settings → Appearance (dots) */
  --swatch-green: #0f6e4b;
  --swatch-blue: #1d5fc4;
  --swatch-violet: #6b40c4;
  --swatch-orange: #b3520c;
  --swatch-pink: #b8306b;

  /* Shadows and dimmed backgrounds */
  --shadow-small: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-tab: 0 1px 4px rgba(25, 35, 55, 0.12);
  --shadow-toast: 0 5px 25px rgba(0, 0, 0, 0.2);
  --shadow-menu: 0 18px 30px -18px rgba(0, 0, 0, 0.6);
  --shadow-popup: 0 18px 50px rgba(10, 15, 25, 0.28);
  --shadow-dialog: 0 24px 60px rgb(0 0 0 / 0.25);
  --shadow-hero: 0 30px 60px -28px rgba(17, 24, 39, 0.35), 0 2px 6px rgba(17, 24, 39, 0.05);
  --shadow-landing-large: 0 40px 80px -40px rgba(17, 24, 39, 0.45);
  --shadow-landing-medium: 0 18px 40px -24px rgba(17, 24, 39, 0.35);
  --shadow-landing-small: 0 6px 24px -12px rgba(17, 24, 39, 0.25);
  --overlay: rgba(10, 15, 25, 0.55); /* behind the guided tour */
  --backdrop: rgb(15 23 42 / 0.45); /* behind dialogs */
}

/* Dark mode
   Landing, login and privacy pages follow the device setting.
   In the app it can be fixed under Settings → Appearance
   (js/app/state.js then sets data-theme="light" or "dark" on <html>). */

:root {
  color-scheme: light dark; /* date pickers, scrollbars etc. adapt */
  --error-soft: #fbeaea;
  --saved: var(--orange); /* savings: orange everywhere */
}

:root[data-theme="light"] {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e131b;
    --panel: #161d28;
    --ink: #e7ebf2;
    --muted: #98a2b5;
    --label: #aeb7c7;
    --line: #273041;
    --nav: #0a0e14;
    --nav-hover: #1c2432;
    --soft: #212a38;
    --green: #4cc48b;
    --red: #f07c7c;
    --orange: #f0a845;
    --spending: var(--red); /* expenses: red everywhere */
    --brand-text: var(--brand-light);
    --brand-soft: color-mix(in srgb, var(--brand-light) 15%, var(--panel));
    --field: #10161f;
    --line-strong: #3d4a60;
    --row-hover: rgba(255, 255, 255, 0.025);
    --track: #232c3a;
    --bar: color-mix(in srgb, var(--orange) 50%, var(--panel));
    --bar-hover: var(--orange);
    --good-soft: rgba(76, 196, 139, 0.14);
    --warn-soft: rgba(240, 168, 69, 0.14);
    --warn-text: #f0bf6e;
    --danger-line: #5a2e33;
    --spending-text: var(--red);
  --orange-text: var(--orange);
    --orange-text: var(--orange);
    --shadow: none;
    --error-soft: rgba(240, 124, 124, 0.14);
    --saved: var(--orange); /* savings: orange everywhere */
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e131b;
  --panel: #161d28;
  --ink: #e7ebf2;
  --muted: #98a2b5;
  --label: #aeb7c7;
  --line: #273041;
  --nav: #0a0e14;
  --nav-hover: #1c2432;
  --soft: #212a38;
  --green: #4cc48b;
  --red: #f07c7c;
  --orange: #f0a845;
  --spending: var(--red); /* expenses: red everywhere */
  --brand-text: var(--brand-light);
  --brand-soft: color-mix(in srgb, var(--brand-light) 15%, var(--panel));
  --field: #10161f;
  --line-strong: #3d4a60;
  --row-hover: rgba(255, 255, 255, 0.025);
  --track: #232c3a;
  --bar: color-mix(in srgb, var(--orange) 50%, var(--panel));
  --bar-hover: var(--orange);
  --good-soft: rgba(76, 196, 139, 0.14);
  --warn-soft: rgba(240, 168, 69, 0.14);
  --warn-text: #f0bf6e;
  --danger-line: #5a2e33;
  --spending-text: var(--red);
  --orange-text: var(--orange);
  --shadow: none;
  --error-soft: rgba(240, 124, 124, 0.14);
  --saved: var(--orange); /* savings: orange everywhere */
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

/* Hide the page until it is translated into the chosen language (js/shared/i18n.js) */
.i18n-wait body {
  visibility: hidden;
}

/* The app stays hidden until the backend has confirmed the login (see start() in js/app/main.js) */
.checking-login body {
  visibility: hidden;
}

/* Nothing may make a page wider than the screen: on phones the page cannot be pushed sideways.
   "clip" (unlike "hidden") keeps position: sticky working. */
html,
body {
  max-width: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

/* Basic elements */

button,
input,
select {
  min-height: 46px;
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.primary,
.secondary {
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 650;
}

.primary {
  background: var(--brand);
  color: var(--on-dark);
}

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

.secondary {
  background: var(--soft);
  color: var(--ink);
}

.danger {
  border: 0;
  background: none;
  color: var(--red);
}

input,
select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
  color: var(--ink);
  font-size: 16px;
}

select {
  appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 20px, calc(100% - 12px) 20px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select:hover {
  border-color: var(--line-strong);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 600;
}

tr:hover td {
  background: var(--row-hover);
}

.money {
  text-align: right;
}

.good {
  color: var(--green);
}

.bad {
  color: var(--red);
}

.transfer {
  color: var(--orange);
}

/* Colours of amounts everywhere: income green, expenses red, savings orange */
.income-text {
  color: var(--green);
}

.spent-text {
  color: var(--red);
}

.saved-text {
  color: var(--orange-text);
}

.note,
.sub {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.sub {
  margin-top: 7px;
}

.empty {
  color: var(--muted);
  padding: 18px 0;
  text-align: center;
  width: 100%;
}

.sep {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 13px 0;
}

/* Layout */

.app {
  display: grid;
  grid-template-columns: 245px 1fr;
  min-height: 100vh;
  min-height: 100dvh; /* phones: follows the browser bar on iPhone */
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--nav);
  color: var(--on-dark);
  padding: 26px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
}

.sidebar-top {
  padding: 0 11px 26px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--on-dark);
  font-family: "Inter Display", Inter, ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.logo img {
  border-radius: 7px;
}

/* App logo: square in the chosen accent colour (Settings → Appearance) */
.logo-mark {
  flex-shrink: 0;
}

.logo-mark rect {
  fill: var(--brand);
}

.logo-mark path {
  fill: var(--on-dark);
}

/* Burger and month button only exist on phones */
.mobile-month,
.sidebar .burger {
  display: none;
}

/* Bottom of the sidebar: month, account, language, light */
.sidebar-menu {
  margin-top: auto;
}

.sidebar-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 18px 10px 0;
}

.sidebar .lang-select,
.sidebar .icon-button {
  border-color: var(--nav-line);
  background-color: var(--nav-hover);
  color: var(--on-dark);
}



.logo:focus-visible,

.nav button {
  display: block;
  width: 100%;
  border: 0;
  background: none;
  color: var(--on-dark-muted);
  padding: 13px 14px;
  margin: 3px 0;
  text-align: left;
  border-radius: 11px;
  font-size: 14px;
}

.nav button:hover,
.nav button.active {
  background: var(--nav-hover);
  color: var(--on-dark);
}

/* Active menu item: coloured bar on the left */
.nav button.active {
  box-shadow: inset 3px 0 0 var(--brand-light);
}

.nav button.active .nav-icon {
  color: var(--brand-light);
}

.nav-short {
  display: none;
}

.nav-icon {
  display: inline-block;
  margin-right: 10px;
}

.month-switch {
  margin: 22px 10px;
  color: var(--on-dark-muted);
  font-size: 14px;
  line-height: 1.6;
}

.month-switch button {
  width: 100%;
  margin-top: 10px;
}

.content {
  padding: 32px;
  max-width: 1500px;
  width: 100%;
  margin: auto;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.head h1 {
  margin: 0;
  font-size: 27px;
}

.head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.head-actions {
  display: flex;
  gap: 11px;
}

.head-actions select {
  max-width: 280px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 19px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.grid4,
.two {
  display: grid;
  gap: 14px;
}

.grid4 {
  grid-template-columns: repeat(4, 1fr);
}

.two {
  grid-template-columns: 1.25fr 0.75fr;
}

.section {
  margin-top: 14px;
}

.row {
  display: flex;
  gap: 11px;
  align-items: end;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 145px;
}

.field label {
  font-size: 14px;
  color: var(--label);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions button {
  font-size: 14px;
  padding: 8px 10px;
  min-width: 88px;
}

/* Sidebar: save status below the user name */

.save-status {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--on-dark-faint);
}

.save-status.error {
  color: var(--on-dark-error);
}

/* Toast */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: var(--accent);
  color: var(--on-dark);
  border-radius: 12px;
  padding: 14px 20px;
  box-shadow: var(--shadow-toast);
  max-width: 90vw;
  font-size: 14px;
}

/* Message with a "Rückgängig" button */
.toast.with-action {
  display: flex;
  white-space: nowrap;
  align-items: center;
  gap: 14px;
  padding: 8px 8px 8px 18px;
}

.toast-action {
  min-height: 36px;
  padding: 6px 12px;
  border: 0;
  border-radius: 9px;
  background: color-mix(in srgb, var(--on-dark) 16%, transparent);
  color: var(--on-dark);
  font-weight: 700;
  white-space: nowrap;
}

.toast-action:hover:not(:disabled) {
  background: color-mix(in srgb, var(--on-dark) 26%, transparent);
}

/* Collapsible sections (<details class="card fold">) */

.fold {
  align-self: start;
}

.fold > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  margin: -4px;
  padding: 4px;
  border-radius: 9px;
  list-style: none;
  cursor: pointer;
  font-weight: 700;
  user-select: none;
}

.fold > summary::-webkit-details-marker {
  display: none;
}

/* Arrow on the right: points down when closed, up when open */
.fold > summary::after {
  content: "";
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin: 0 6px 4px auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.fold[open] > summary::after {
  margin-bottom: -4px;
  transform: rotate(-135deg);
}

.fold > summary:hover::after {
  border-color: var(--ink);
}

.fold > summary:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.fold[open] > summary {
  margin-bottom: 8px;
}

.fold-title {
  min-width: 0;
}

/* The section titles are headings (h2) for screen readers, but look like before */
h2.fold-title {
  margin: 0;
  font: inherit;
}

/* Number of entries next to the title */
.fold-count {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-text);
  font-size: 12px;
  font-weight: 650;
}

.fold-count:empty {
  display: none;
}

.fold-body > .note:first-child,
.fold-body > .row:first-child {
  margin-top: 0;
}

/* Apprentice year tiles inside a card */
.year-grid .card {
  background: var(--bg);
  box-shadow: none;
}

/* A year before "Tracken ab" */
.year-grid .card.untracked {
  border-style: dashed;
  background: transparent;
  color: var(--muted);
}

/* Long lists: "Show all …" */

.more-row td,
tr.more-row:hover td {
  padding: 14px 0 2px;
  border-bottom: 0;
  background: none;
  text-align: center;
}

.more-button {
  min-height: 40px;
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 650;
}

.more-button:hover:not(:disabled) {
  border-color: var(--line-strong);
}

/* Shared controls: light switch, language, burger menu */

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  min-height: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
}

.icon-button:hover:not(:disabled) {
  border-color: var(--line-strong);
}

/* Light bulb: light = on (filled, with rays), dark = off */
.bulb {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bulb-glass {
  fill: var(--bulb-glow);
  stroke: var(--bulb-line);
  transition: fill 0.25s ease, stroke 0.25s ease;
}

.bulb-rays {
  stroke: var(--bulb-line-on);
  transition: opacity 0.25s ease, transform 0.25s ease;
  transform-origin: 12px 10px;
}

[aria-pressed="false"] .bulb-glass {
  fill: transparent;
  stroke: currentColor;
}

[aria-pressed="false"] .bulb-rays {
  opacity: 0;
  transform: scale(0.6);
}

.lang-select {
  width: auto;
  min-height: 40px;
  height: 40px;
  padding: 6px 30px 6px 10px;
  border-radius: 10px;
  background-color: var(--panel);
  background-position: calc(100% - 15px) 17px, calc(100% - 10px) 17px;
  font-size: 14px;
  font-weight: 600;
}

.lang-select.large {
  min-height: 46px;
  height: 46px;
  padding-left: 14px;
  background-position: calc(100% - 17px) 20px, calc(100% - 12px) 20px;
  font-size: 16px;
}

.page-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Burger icon: the three bars turn into an X when open */
.burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  min-height: 44px;
  height: 44px;
  padding: 0 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
}

.burger span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.25s ease, opacity 0.2s ease;
}

.burger[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.burger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.burger[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.burger:hover:not(:disabled) {
  transform: none;
  background: var(--soft);
}

/* Page transitions (cross-fade in browsers with view transitions) */

@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.25s;
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  .bulb-glass,
  .bulb-rays,
  .burger span {
    transition: none;
  }
}

/* Subtle app animations (off with reduced motion) */

@media (prefers-reduced-motion: no-preference) {
  /* Page change via the menu and switching tabs in the settings */
  .page.active,
  [data-settings-tab]:not(.tab-hidden) {
    animation: page-in 0.28s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  /* Opening a collapsible section */
  .fold[open] > .fold-body {
    animation: fold-in 0.22s ease both;
  }

  /* Toast message */
  .toast:not([hidden]) {
    animation: toast-in 0.25s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  /* "Choose pay month" pop-up */
  .month-dialog[open] {
    animation: page-in 0.35s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  @keyframes page-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
  }

  @keyframes fold-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
  }

  @keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
  }
}

/* Link styled as a button (e.g. "Change password" in the settings) */
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 650;
  text-decoration: none;
}

/* Blocks on the dashboard and the month page. The month page uses a fixed two-column grid;
   on the dashboard every block has its own width in percent (--w, phone: --wm) and can be
   moved and resized while arranging ("Anordnen", js/app/layout.js). */

.blocks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.block {
  position: relative;
  min-width: 0;
}

.block.span-2 {
  grid-column: 1 / -1;
}

.block > .card {
  height: 100%;
}

/* Dashboard: a grid of 24 columns. js/app/layout.js places every block (width and position, as high
   up in its columns as there is room); the blocks glide to their new place. */
.blocks[data-sortable] {
  --gap: 14px;
  position: relative;
  display: block;
  overflow-anchor: none; /* the page must not jump while blocks move */
}

.blocks[data-sortable] > .block {
  position: absolute;
  top: 0;
  left: 0;
  container-type: inline-size;
}

.blocks[data-sortable].animated > .block {
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), width 0.2s ease;
}

.block-bar,
.block-resize {
  display: none;
}

.arranging > .block {
  border: 2px dashed color-mix(in srgb, var(--brand) 45%, var(--line));
  border-radius: 18px;
  padding: 8px;
  background: color-mix(in srgb, var(--brand-soft) 40%, transparent);
}

.arranging .block-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--panel);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.arranging .block-bar:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.block-grip {
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.block-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Hidden blocks: gone from the dashboard; while arranging faded with "Ausgeblendet" */
[data-sortable]:not(.arranging) > .block-hidden {
  display: none;
}

.block-hidden-label {
  display: none;
}

.arranging > .block-hidden {
  border-style: dotted;
  background: transparent;
}

.arranging > .block-hidden > :not(.block-bar):not(.block-resize):not(.block-hidden-label) {
  opacity: 0.3;
}

.arranging > .block-hidden .block-name {
  opacity: 0.6;
}

/* "Ausgeblendet" over the faded content */
.arranging > .block-hidden > .block-hidden-label {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  display: block;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  transform: translate(-50%, -10%);
  pointer-events: none;
}

/* Eye button: open = shown, crossed out = hidden */
.block-bar .block-hide {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  min-width: 34px;
  min-height: 30px;
  padding: 0;
}

.block-hide svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.block-hide .eye-closed,
.block-hidden .block-hide .eye-open {
  display: none;
}

.block-hidden .block-hide .eye-closed {
  display: block;
}

/* Left and right edge: drag them to change the width */
.arranging .block-resize {
  position: absolute;
  top: 0;
  right: -9px;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  cursor: ew-resize;
  touch-action: none;
}

.arranging .block-resize::before {
  content: "";
  width: 6px;
  height: 44px;
  max-height: 60%;
  border-radius: 99px;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--panel);
  transition: height 0.15s ease;
}

.arranging .block-resize-left {
  right: auto;
  left: -9px;
}

.arranging .block-resize:hover::before,
.block.resizing .block-resize::before {
  height: 64px;
}

.block.resizing,
.block.resizing .block-bar {
  cursor: ew-resize;
}

/* Current width while resizing */
.block.resizing::after {
  content: attr(data-size);
  position: absolute;
  top: 10px;
  right: 18px;
  z-index: 3;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--brand);
  color: var(--on-dark);
  font-size: 13px;
  font-weight: 650;
}

/* The block being moved floats above the page and follows the pointer */
.blocks[data-sortable] > .block.dragging {
  z-index: 20;
  transition: none;
  cursor: grabbing;
  background: color-mix(in srgb, var(--brand-soft) 55%, var(--panel));
  box-shadow: var(--shadow-dialog);
  pointer-events: none;
}

.block.dragging .block-bar {
  cursor: grabbing;
}

/* Where the moved block will land */
.block-placeholder {
  border: 2px dashed var(--brand);
  border-radius: 18px;
  background: color-mix(in srgb, var(--brand-soft) 70%, transparent);
}

.arranging .block .card {
  pointer-events: none;
}

.arrange-toggle[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-dark);
}

.arrange-help {
  margin: 10px 0 0;
}

.link-button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-button:hover:not(:disabled) {
  transform: none;
}

/* Questions and new names (instead of the browser's pop-ups) */

.app-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-dialog);
}

.app-dialog::backdrop {
  background: var(--backdrop);
}

.app-dialog h2 {
  margin: 0 0 6px;
  font-size: 19px;
}

.app-dialog .note:empty {
  display: none;
}

.app-dialog .field {
  margin-top: 14px;
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.dialog-buttons .danger-solid {
  background: var(--red);
  border-color: var(--red);
  color: var(--on-dark);
}

@media (max-width: 760px) {
  .blocks {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
}

/* Phones: small links get a tap area of about 44px without changing their look
   (base.css is loaded on every page) */
@media (max-width: 760px) {
  .link-button,
  a.back,
  .auth-links a,
  .footer-inner nav a,
  .security-link,
  .faq-list a {
    display: inline-block;
    padding: 11px 6px;
    margin: -11px -6px;
  }
}

/* "Neue Version verfügbar" (js/shared/update.js): pop-up in the middle, everything behind blurred */
body.update-open {
  overflow: hidden;
}

.update-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.update-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(360px, 100%);
  padding: 28px 24px 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  color: var(--ink);
  text-align: center;
  box-shadow: var(--shadow-dialog);
}

.update-card img {
  border-radius: 14px;
}

.update-card h2 {
  margin: 4px 0 0;
  font-size: 20px;
}

.update-card p {
  margin: 0 0 8px;
  color: var(--label);
  font-size: 15px;
  line-height: 1.5;
}

.update-reload {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: var(--on-dark);
  font-weight: 700;
}

.update-reload:hover:not(:disabled) {
  background: var(--brand-hover);
}
