:root {
  --container-max-width: 1000px;
  --search-max-width: 600px;
  --tiles-gap: 16px;
  --tiles-margin-top: 100px;
  --tile-icon-size: 40px;
  --highlight-color: #00ff00;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  background-color: #1a1a1a;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
  padding: 100px 0 10px;
  text-align: center;
}

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

.logo {
  width: 300px;
  max-width: 90%;
  margin: 0 auto;
  display: block;
  animation: fade-in 0.8s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes logo-flash {
  0% { filter: brightness(1.5) drop-shadow(0 0 24px #fff4); }
  40% { filter: brightness(2.2) drop-shadow(0 0 50px #fffa); }
  65% { filter: brightness(2) drop-shadow(0 0 32px #0f04); }
  100% { filter: brightness(1) drop-shadow(0 0 0 #0000); }
}

.logo.flash { animation: logo-flash 1s ease; }

.search-form {
  margin-top: 40px;
  display: flex;
  justify-content: center;
}

.search-wrapper {
  position: relative;
  width: 100%;
  max-width: var(--search-max-width);
  margin: 0 auto;
}

.google-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  pointer-events: none;
  z-index: 2;
}

.search-input {
  width: 100%;
  padding: 14px 48px;
  font-size: 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 30px;
  background: transparent;
  color: #fff;
  outline: none;
  backdrop-filter: blur(4px);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, border-radius 0.2s ease;
}

.search-input:focus,
.search-wrapper.suggestions-open .search-input {
  border-color: var(--highlight-color);
  box-shadow: 0 0 8px color-mix(in srgb, var(--highlight-color) 70%, transparent);
}

.search-wrapper.suggestions-open .search-input { border-radius: 24px 24px 0 0; }

.search-button {
  position: absolute;
  right: 16px;
  top: 24px;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  z-index: 3;
}

.search-button:hover {
  color: #fff;
  transform: translateY(-50%) scale(1.08);
}

.search-suggestions {
  position: absolute;
  top: calc(100% - 1px);
  left: 0;
  right: 0;
  z-index: 100;
  list-style: none;
  margin: 0;
  padding: 6px 0 8px;
  background: #202020;
  border: 1px solid var(--highlight-color);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0 0 18px 18px;
  box-shadow: 0 12px 24px #0008;
  overflow: hidden;
  text-align: left;
}

.search-suggestion {
  padding: 10px 48px;
  cursor: pointer;
  color: #eee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-suggestion::before {
  content: "⌕";
  display: inline-block;
  width: 22px;
  margin-left: -28px;
  color: #999;
}

.search-suggestion:hover,
.search-suggestion.active {
  background: #303030;
  color: #fff;
}

.categories {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 26px;
  margin: 28px auto 0;
}

.category-tab {
  --category-color: #00ff00;
  position: relative;
  padding: 7px 2px 10px;
  border: 0;
  background: transparent;
  color: #8e8e8e;
  cursor: pointer;
  transition: color 0.18s;
}

.category-tab::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 2px;
  left: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--category-color);
  box-shadow: 0 0 9px var(--category-color);
  opacity: 0;
  transform: scaleX(0.45);
  transition: opacity 0.18s, transform 0.18s;
}

.category-tab[data-category="social"] { --category-color: #ff354d; }
.category-tab[data-category="medien"] { --category-color: #b967ff; }
.category-tab[data-category="tools"] { --category-color: #329dff; }
.category-tab[data-category="privat"] { --category-color: #ff4fb8; }

.category-tab:hover,
.category-tab:focus-visible,
.category-tab[aria-pressed="true"] {
  color: #fff;
  outline: none;
}

.category-tab[aria-pressed="true"]::after {
  opacity: 1;
  transform: scaleX(1);
}

.tiles-status {
  min-height: 20px;
  margin: 26px auto -18px;
  color: #888;
  font-size: 0.9rem;
}

.tiles-status:empty { visibility: hidden; }

.tiles {
  margin: 34px auto 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--tiles-gap);
  width: 100%;
  max-width: var(--container-max-width);
  justify-items: center;
}

.tile-shell {
  position: relative;
  width: 100%;
  max-width: 210px;
  justify-self: center;
}

.tile {
  width: 100%;
  min-height: 68px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  border: 2px solid transparent;
  padding: 12px;
  text-decoration: none;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s, color 0.2s, transform 0.2s, border-color 0.2s;
  overflow: hidden;
}

.tile img {
  width: var(--tile-icon-size);
  height: var(--tile-icon-size);
  flex: 0 0 var(--tile-icon-size);
  object-fit: contain;
  transform: scale(var(--icon-scale, 1));
  transform-origin: center;
}

.tile img.inverted { filter: brightness(0) invert(1); }

.tile span {
  margin-left: 8px;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile:hover,
.tile:focus-visible {
  background: var(--tile-hover, rgba(255, 255, 255, 0.18));
  color: #fff;
  transform: translateY(-2px);
  outline: none;
}

body.admin-mode .tile[draggable="true"] { cursor: grab; }
body.admin-mode .tile[draggable="true"]:active { cursor: grabbing; }
.tile-shell.dragging { opacity: 0.48; }

.tile-shell.dragging .tile {
  border-color: #fff;
  border-style: dashed;
}

.tile-shell.drag-over .tile {
  border-color: var(--highlight-color);
  box-shadow: 0 0 10px color-mix(in srgb, var(--highlight-color) 60%, transparent);
}

.tile-delete,
.tile-edit {
  position: absolute;
  top: -8px;
  z-index: 5;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid #ff7777;
  background: #2c1111;
  color: #ff7777;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.15s, transform 0.15s, background 0.15s;
}

.tile-delete { right: -8px; }

.tile-edit {
  left: -8px;
  border-color: #7fbfff;
  background: #10233b;
  color: #7fbfff;
  font-size: 0.95rem;
}

.tile-shell:hover .tile-delete,
.tile-shell:hover .tile-edit,
.tile-delete:focus-visible,
.tile-edit:focus-visible {
  opacity: 1;
  transform: scale(1);
}

.tile-delete:hover {
  background: #9e1b1b;
  color: #fff;
}

.tile-edit:hover {
  background: #1763a8;
  color: #fff;
}

.weather-info {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 999;
  font-size: 1.08rem;
  color: #fff;
  background: rgba(20, 20, 20, 0.7);
  border: 0;
  padding: 4px 14px 4px 10px;
  border-radius: 20px;
  font-family: monospace;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.88;
  min-width: 72px;
  cursor: pointer;
}

.weather-info:hover,
.weather-info:focus-visible {
  opacity: 1;
  outline: 1px solid #555;
}

.weather-emoji { font-size: 1.15rem; }

.weather-panel {
  position: fixed;
  top: 56px;
  left: 18px;
  background: rgba(20, 20, 20, 0.96);
  color: #fff;
  border-radius: 18px;
  padding: 12px 20px;
  z-index: 1000;
  box-shadow: 0 8px 18px #0008;
  min-width: 205px;
  font-size: 0.97rem;
  text-align: left;
}

.forecast-title { margin-bottom: 8px; font-weight: bold; }

.forecast-day {
  display: grid;
  grid-template-columns: 32px 32px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}

.forecast-day:last-child { margin-bottom: 0; }

#lock-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 10px;
}

#clock {
  margin-right: 8px;
  font-size: 1.15rem;
  color: #fff;
  opacity: 0.75;
  letter-spacing: 1px;
  font-family: monospace;
  user-select: none;
}

.header-icon-btn {
  min-width: 34px;
  height: 34px;
  background: none;
  border: none;
  border-radius: 50%;
  font-size: 1.45rem;
  cursor: pointer;
  color: #ccc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s, transform 0.2s;
}

.header-icon-btn:hover,
.header-icon-btn:focus-visible {
  color: #fff;
  background: #ffffff12;
  transform: scale(1.05);
  outline: none;
}

#add-tile-btn { color: var(--highlight-color); font-size: 1.75rem; }

.version-info {
  display: block;
  width: fit-content;
  margin: 24px auto 8px;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  font-size: 0.92rem;
  color: #aaa;
  opacity: 0.8;
  letter-spacing: 1px;
  cursor: pointer;
  transition: color 0.2s, opacity 0.2s;
}

.version-info:hover,
.version-info:focus-visible {
  color: #fff;
  opacity: 1;
  outline: none;
}

.modal {
  position: fixed;
  z-index: 9999;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(2px);
  cursor: default;
}

.modal-content {
  width: min(100%, 460px);
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  background: #191c20;
  border: 1px solid #ffffff14;
  border-radius: 16px;
  box-shadow: 0 14px 42px #000a;
  padding: 24px 22px 20px;
  z-index: 2;
  position: relative;
  font-size: 1rem;
  color: #eee;
  animation: pop-in 0.14s ease;
  text-align: left;
}

.changelog-content { width: min(100%, 720px); }

@keyframes pop-in {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 18px;
  color: #fff;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.55rem;
  line-height: 1;
  color: #ae3537;
  cursor: pointer;
  margin-left: 10px;
  transition: color 0.2s;
}

.close-btn:hover,
.close-btn:focus-visible { color: #fff; outline: none; }

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.stacked-form label {
  margin-top: 4px;
  color: #d7d7d7;
  font-size: 0.94rem;
}

.stacked-form input:not([type="checkbox"]):not([type="color"]),
.stacked-form select {
  width: 100%;
  border: 1px solid #555;
  border-radius: 9px;
  background: #111418;
  color: #fff;
  padding: 10px 12px;
  outline: none;
}

.stacked-form input:not([type="checkbox"]):focus,
.stacked-form select:focus {
  border-color: var(--highlight-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--highlight-color) 18%, transparent);
}

.stacked-form input[type="color"] {
  width: 64px;
  height: 38px;
  padding: 3px;
  border: 1px solid #555;
  border-radius: 8px;
  background: #111418;
  cursor: pointer;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--highlight-color);
}

.optional { color: #888; font-weight: normal; }

.primary-btn {
  margin-top: 8px;
  border: 0;
  border-radius: 9px;
  padding: 10px 16px;
  background: var(--highlight-color);
  color: #071007;
  font-weight: bold;
  cursor: pointer;
  transition: filter 0.2s, transform 0.2s;
}

.primary-btn:hover:not(:disabled) {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

.primary-btn:disabled { opacity: 0.55; cursor: wait; }

.form-message {
  min-height: 20px;
  margin: 3px 0 0;
  color: #ff8585;
  font-size: 0.9rem;
}

.form-message.success { color: #79df92; }

.text-btn {
  align-self: center;
  border: 0;
  background: none;
  color: #aaa;
  padding: 5px 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.text-btn:hover,
.text-btn:focus-visible {
  color: #fff;
  text-decoration: underline;
  outline: none;
}

.changelog-block {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid #2b2e34;
}

.changelog-block:last-child { border-bottom: none; }

.changelog-version {
  min-width: 66px;
  color: #fff;
  font-weight: bold;
  font-size: 1rem;
  letter-spacing: 1px;
  margin-top: 2px;
}

.changelog-details {
  color: #ccc;
  line-height: 1.55;
  flex: 1;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 12000;
  max-width: min(90vw, 520px);
  padding: 11px 18px;
  border: 1px solid #ffffff20;
  border-radius: 12px;
  background: #282c31;
  color: #fff;
  box-shadow: 0 8px 24px #0009;
}

.toast.error {
  border-color: #a83f3f;
  background: #3a1d1d;
}

.hidden { display: none !important; }

@media (max-width: 600px) {
  :root { --tile-icon-size: 32px; }
  body { padding-top: 92px; }
  .logo { width: 240px; }
  .search-wrapper { width: 90%; max-width: none; }
  .search-suggestion { padding-left: 42px; padding-right: 42px; }
  .categories { width: 92%; gap: 14px; margin-top: 24px; }
  .tiles-status { margin-top: 22px; margin-bottom: -14px; }

  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 90%;
    max-width: none;
    gap: 12px;
    margin-top: 30px;
  }

  .tile { min-height: 60px; padding: 10px; gap: 6px; }
  .tile span { margin-left: 4px; font-size: 0.88rem; }
  .tile-delete,
  .tile-edit { opacity: 1; transform: scale(0.92); }
  .weather-info { top: 14px; left: 12px; }
  .weather-panel { left: 12px; }
  #lock-container { top: 12px; right: 10px; gap: 5px; }
  #clock { margin-right: 2px; font-size: 1rem; }
  .changelog-block { flex-direction: column; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
