:root {
  --bg: #f4f5f8;
  --card: #ffffff;
  --text: #1c1e26;
  --muted: #8a8f9e;
  --accent: #5b6cff;
  --accent-soft: #eceeff;
  --danger: #e5484d;
  --border: #e4e6ec;
  --shadow: 0 1px 3px rgba(20, 22, 40, .07), 0 4px 16px rgba(20, 22, 40, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15161a;
    --card: #1f2127;
    --text: #eceef4;
    --muted: #7d8291;
    --accent: #7c89ff;
    --accent-soft: #2a2d45;
    --danger: #ff6369;
    --border: #2c2f37;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

.hidden { display: none !important; }

/* ---- login ---- */

.login {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 320px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px 24px;
  text-align: center;
}
.login-icon {
  display: block;
  width: 64px; height: 64px;
  margin: 0 auto 14px;
}
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card p { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  font-size: 17px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  margin-bottom: 10px;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.login-error { color: var(--danger); font-size: 14px; margin-top: 10px; min-height: 18px; }

/* ---- app ---- */

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 14px;
}
header h1 { font-size: 26px; letter-spacing: -.02em; }

.status {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #3dd68c;
  transition: background .3s;
}
.status.offline { background: var(--danger); }
.status.syncing { background: #f5a623; }

.add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.add-form input {
  flex: 1;
  padding: 13px 16px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  outline: none;
  box-shadow: var(--shadow);
}
.add-form input:focus { border-color: var(--accent); }
.add-form button {
  width: 48px;
  flex-shrink: 0;
  font-size: 24px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.add-form button:active { transform: scale(.96); }

.list { list-style: none; }

.task {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  animation: pop .15s ease-out;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-y;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.task.dragging {
  opacity: .95;
  transform: scale(1.03);
  box-shadow: 0 8px 24px rgba(20, 22, 40, .3);
  border: 1px solid var(--accent);
  animation: none;
  cursor: grabbing;
}

.placeholder {
  border: 2px dashed var(--accent);
  border-radius: 14px;
  background: var(--accent-soft);
  opacity: .55;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.task-text {
  flex: 1;
  font-size: 16px;
  line-height: 1.35;
  word-break: break-word;
}

.task-edit {
  flex: 1;
  font-size: 16px;
  font-family: inherit;
  border: none;
  border-bottom: 2px solid var(--accent);
  background: none;
  color: var(--text);
  outline: none;
  padding: 0 0 2px;
}

.del {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
.del:hover { color: var(--danger); background: var(--accent-soft); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 36px 0 20px;
  font-size: 16px;
}

.offline {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 10px;
  white-space: nowrap;
}
