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

:root {
  --bg: #111;
  --bg2: #1c1c1e;
  --bg3: #2c2c2e;
  --text: #e5e5ea;
  --text2: #aeaeb2;
  --text3: #636366;
  --accent: #ff9f0a;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 24px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* === LOGIN === */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  padding-top: calc(var(--safe-top) + 24px);
}

.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.login-logo { margin-bottom: 8px; }
.login-title { font-size: 39px; font-weight: 700; }
.login-subtitle { color: var(--text3); text-align: center; font-size: 21px; line-height: 1.5; }

#email-input {
  width: 100%;
  background: var(--bg2);
  border: none;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 26px;
  color: var(--text);
  outline: none;
  margin-top: 8px;
}
#email-input::placeholder { color: var(--text3); }

#send-link-btn {
  width: 100%;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 26px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}

.login-message {
  font-size: 21px;
  color: var(--text2);
  text-align: center;
  min-height: 20px;
}

/* === APP SHELL === */
#app-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 8px;
  flex-shrink: 0;
}

/* === SEGMENTED CONTROL === */
.seg-ctrl {
  flex: 1;
  display: flex;
  background: var(--bg3);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}

.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text3);
  font-size: 21px;
  font-weight: 600;
  padding: 6px 4px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg-btn.active {
  background: var(--accent);
  color: #000;
}

/* === GEAR BUTTON === */
.gear-btn {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.gear-btn:active { background: var(--bg3); }

/* === SCREENS === */
.screen {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* === INPUT (Hinzufügen) === */
.input-wrapper {
  padding: 4px 12px 0;
  position: relative;
  flex-shrink: 0;
  z-index: 6;
}

.input-row {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 10px 14px;
  gap: 10px;
}

.input-icon { color: var(--text3); flex-shrink: 0; }

#add-input {
  flex: 1;
  background: none;
  border: none;
  font-size: 26px;
  color: var(--text);
  outline: none;
}
#add-input::placeholder { color: var(--text3); }

/* === SUGGESTIONS === */
.suggestions {
  position: absolute;
  left: 12px; right: 12px;
  top: calc(100% + 2px);
  background: var(--bg2);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  font-size: 24px;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--bg3);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:active { background: var(--bg3); }
.suggestion-item svg { color: var(--accent); flex-shrink: 0; }

/* === ITEM LIST === */
.item-list {
  list-style: none;
  padding: 8px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.item-row {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 13px 14px;
  gap: 12px;
  font-size: 26px;
  color: var(--text);
}

.item-text { flex: 1; }

.item-delete {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.item-delete:active { color: var(--text2); }

/* === SHOP LIST === */
.shop-list .item-row {
  font-size: 30px;
  padding: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.shop-label {
  display: block;
  width: 100%;
  padding: 16px 14px;
  cursor: pointer;
}

.shop-list .item-row.checked {
  color: var(--text3);
  text-decoration: line-through;
  background: #181818;
}

/* === HISTORY PANEL === */
.history-panel {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.history-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--bg3);
  font-size: 24px;
  font-weight: 700;
  flex-shrink: 0;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 4px;
  margin-left: auto;
  display: flex;
}

.history-hint {
  font-size: 18px;
  color: var(--text3);
  padding: 6px 16px;
  flex-shrink: 0;
}

.history-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0 0 16px;
}

.history-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  font-size: 24px;
  color: var(--text2);
  border-bottom: 1px solid var(--bg3);
  gap: 12px;
}

.history-row-text { flex: 1; }

.history-delete {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}
.history-delete:active { color: #ff453a; }

/* === UNDO TOAST === */
.undo-toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg3);
  border-radius: 24px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  z-index: 200;
  font-size: 21px;
}

#undo-text { color: var(--text2); }

#undo-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 21px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

/* === iOS HAPTIC SWITCH (off-screen, never visible) === */
.haptic-switch {
  position: fixed;
  top: -9999px;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* === SUGGESTIONS BACKDROP === */
.suggestions-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 5;
}
