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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --accent: #e94560;
  --text: #eee;
  --text-dim: #888;
  --radius: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* Auth */
.auth-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  gap: 16px;
  padding: 20px;
}

.auth-box h1 { font-size: 64px; }

.auth-box input {
  width: 100%;
  max-width: 300px;
  padding: 14px 16px;
  border: 2px solid var(--surface2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.auth-box input:focus { border-color: var(--accent); }

.auth-box button {
  width: 100%;
  max-width: 300px;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.auth-toggle {
  font-size: 14px;
  color: var(--text-dim);
}

.auth-toggle a {
  color: var(--accent);
  text-decoration: none;
}

.error-text {
  color: var(--accent);
  font-size: 14px;
  text-align: center;
  max-width: 300px;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

header h1 { font-size: 20px; font-weight: 700; }

.header-actions { display: flex; align-items: center; gap: 10px; }

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot.online { background: #4ade80; }
.dot.offline { background: var(--accent); }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

/* Add area */
#add-area { padding: 8px 20px 0; }

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

.input-wrap input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--surface2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.input-wrap input:focus { border-color: var(--accent); }

.input-wrap button, #add-btn {
  width: 48px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

/* Suggestions */
#suggestions {
  list-style: none;
  background: var(--surface);
  border-radius: var(--radius);
  margin-top: 4px;
  overflow: hidden;
}

#suggestions li {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 15px;
  border-bottom: 1px solid var(--surface2);
}

#suggestions li:last-child { border-bottom: none; }
#suggestions li:hover, #suggestions li.selected { background: var(--surface2); }
#suggestions li:active { background: var(--surface2); }

/* Item list */
#item-list, #checked-list {
  list-style: none;
  padding: 8px 20px;
}

#item-list li, #checked-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  animation: fadeIn 0.2s ease;
}

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

#item-list li .check, #checked-list li .check {
  width: 24px; height: 24px;
  border: 2px solid var(--text-dim);
  border-radius: 6px;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
}

#item-list li .check:hover { border-color: var(--accent); }

#checked-list li .check {
  background: var(--accent);
  border-color: var(--accent);
}

#item-list li .name, #checked-list li .name {
  flex: 1;
  font-size: 16px;
  word-break: break-word;
}

#checked-list li .name {
  text-decoration: line-through;
  color: var(--text-dim);
}

#item-list li .delete-btn, #checked-list li .delete-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.5;
}

#item-list li .delete-btn:hover, #checked-list li .delete-btn:hover { opacity: 1; color: var(--accent); }

/* Checked section */
#checked-section { padding: 0 20px 80px; }

.text-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 0;
}

/* Settings modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-content {
  background: var(--surface);
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px;
  padding-bottom: calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-content h2 { font-size: 18px; }

.setting label {
  display: block;
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.share-code {
  display: inline-block;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--accent);
  padding: 8px 0;
  font-family: monospace;
}

.auth-subtitle {
  font-size: 16px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.primary-btn {
  width: 100%;
  max-width: 300px;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hint {
  font-size: 12px;
  color: var(--text-dim);
  max-width: 300px;
  text-align: center;
}

.hint-success { color: #4ade80; }
.hint-error { color: var(--accent); }

.danger-btn {
  background: none;
  border: 2px solid var(--accent);
  color: var(--accent);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  width: 100%;
}

/* Bottom safe area padding */
#app-screen { padding-bottom: calc(20px + var(--safe-bottom)); }

/* Desktop tweaks */
@media (min-width: 600px) {
  #app-screen { max-width: 500px; margin: 0 auto; }
  .modal-content { border-radius: var(--radius); }
  .modal { align-items: center; }
}
