*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0d0d14;
  --surface:  #16161f;
  --border:   #252535;
  --text:     #e0e0f0;
  --muted:    #666680;
  --accent:   #6366f1;
  --accent-h: #4f46e5;
  --danger:   #ef4444;
  --radius:   14px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Layout ── */
.homescreen {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 2rem 6rem;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
}

.header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.4px;
}

/* ── App-Grid ── */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 1.2rem;
}

.app-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.app-item:hover { background: rgba(255,255,255,0.05); }
.app-item:active { background: rgba(255,255,255,0.08); transform: scale(0.96); }

.app-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  flex-shrink: 0;
}

.app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-name {
  font-size: 0.76rem;
  text-align: center;
  color: #b0b0c8;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 4rem 1rem;
  font-size: 0.95rem;
  line-height: 1.7;
}

/* ── Add-Button ── */
.btn-add {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(99,102,241,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
}

.btn-add:hover { background: var(--accent-h); transform: scale(1.06); }

/* ── Drop-Overlay ── */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,10,20,0.8);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border: 2px dashed var(--accent);
  pointer-events: none;
}

.drop-inner {
  text-align: center;
  color: #fff;
}

.drop-icon { font-size: 3.5rem; display: block; margin-bottom: 0.8rem; }
.drop-inner p { font-size: 1.2rem; font-weight: 600; }
.drop-inner span { color: var(--muted); font-size: 0.9rem; }

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.8rem;
  width: 380px;
  max-width: 100%;
}

.modal-box h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 1.4rem;
}

.modal-box label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
  margin-top: 1rem;
}

.modal-box label:first-of-type { margin-top: 0; }

.required { color: var(--accent); }
.optional { color: var(--muted); font-size: 0.75rem; text-transform: none; letter-spacing: 0; }

.modal-box input[type="text"],
.modal-box input[type="password"] {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.modal-box input[type="text"]:focus,
.modal-box input[type="password"]:focus {
  border-color: var(--accent);
}

/* Custom file input */
.file-input-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.35rem;
}

.file-btn {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s;
  white-space: nowrap;
  margin-top: 0;
  text-transform: none;
  letter-spacing: 0;
}

.file-btn:hover { border-color: var(--accent); }

.file-input-row span {
  font-size: 0.82rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Datei-Badge über Upload-Dialog */
.file-badge {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 99px;
  font-size: 0.8rem;
  color: #a5b4fc;
  margin-bottom: 1rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

/* Modal Actions */
.modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 1.4rem;
  flex-wrap: wrap;
}

/* Buttons */
.btn-primary {
  padding: 0.5rem 1.1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:disabled { background: #333; color: #666; cursor: not-allowed; }

.btn-secondary {
  padding: 0.5rem 1.1rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover { border-color: #555; color: var(--text); }

.btn-danger {
  padding: 0.5rem 1.1rem;
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.35);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.btn-danger:hover { background: rgba(239,68,68,0.1); }

.btn-ghost {
  padding: 0.4rem 0.9rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: color 0.15s, border-color 0.15s;
}
.btn-ghost:hover { color: var(--danger); border-color: var(--danger); }

/* Errors */
.form-error {
  color: #f87171;
  font-size: 0.83rem;
  margin-top: 0.6rem;
}

.hidden { display: none !important; }

/* ── Icon-Editor (Upload + Edit Modal) ── */
.icon-editor {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  transition: border-color 0.15s, background 0.15s;
  margin-top: 0.35rem;
}

.icon-editor.drop-target {
  border-color: var(--accent);
  background: rgba(99,102,241,0.08);
}

.icon-preview {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #2a2a3a;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}

.icon-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.icon-editor-hint {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.icon-editor-hint .drop-hint {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}

/* ── Edit-Mode Badge auf App-Kacheln ── */
.app-item {
  position: relative;
}

.edit-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  z-index: 1;
}

body.edit-mode .edit-badge { display: flex; }

body.edit-mode .app-item {
  animation: wiggle 0.4s ease-in-out infinite alternate;
}

@keyframes wiggle {
  from { transform: rotate(-1deg); }
  to   { transform: rotate(1deg); }
}

/* ── Modal-Actions gesplittet (Delete links, Rest rechts) ── */
.modal-actions-split {
  justify-content: space-between;
}

.modal-actions-split .actions-right {
  display: flex;
  gap: 0.6rem;
}

/* Header-Right: mehrere Buttons nebeneinander */
.header-right {
  display: flex;
  gap: 0.5rem;
}
